tstenner / luarefnos Goto Github PK
View Code? Open in Web Editor NEWPure lua demo for Pandoc cross-references
License: BSD 2-Clause "Simplified" License
Pure lua demo for Pandoc cross-references
License: BSD 2-Clause "Simplified" License
Since pandoc-xnos seems to be dead for now and it doesn't really support pandoc 3.x (e.g. pandoc-fignos
is broken due to the new AST format), migrating to this native LUA implementation sounds like a good idea. But it would be beneficial if we could keep the documents written for pandoc-xnos...
So one of the differences is the "clever references" feature available in pandoc-xnos
. The difference is the following:
pandoc-xnos:
@fig:myfigure
is simply replaced with the number of the figure (e.g. 1
).+@fig:myfigure
is replaced with the caption + number (e.g. Figure 1
)luarefnos:
@fig:myfigure
is replaced with the caption + number (e.g. Figure 1
)Ideally, my suggestion is to implement exactly the same syntax as pandoc-xnos.
But if that is too complex, maybe it is possible to implement deletion of the +
sign right before the reference.
Explanation:
@fig:myfigure
in luarefnos does the same as +@fig:myfigure
in pandoc-xnos. Namely, it emits caption + number (e.g. Figure 1
)Please see +@fig:myfigure for more details.
Please see +Figure 1 for more details.
+
that should not be there...Since pandoc-xnos seems to be dead for now and it doesn't really support pandoc 3.x (e.g. pandoc-fignos
is broken due to the new AST format), migrating to this native LUA implementation sounds like a good idea. But it would be beneficial if we could keep the documents written for pandoc-xnos...
So one of the differences is the fact that tables in pandoc-xnos
are abbreviates with tbl:
, while luarefnos
uses tab:
by default. I fixed it for myself, by adding a duplicate line for tbl
here:
Lines 367 to 381 in 4ae8fbc
E.g.:
en = {
tab = {ref = 'Table', plural = 'Tables', abbrev = 'Tab.'},
tbl = {ref = 'Table', plural = 'Tables', abbrev = 'Tab.'},
With this change, I can render the documents that have links like @tbl:silly
Apparently, I couldn't just replace "tab" with "tbl", because is some other places it is used...
I suggest adding "official" support for this.
On pandoc 3.1.11.1:
% pandoc --version
pandoc 3.1.11.1
Features: +server +lua
Scripting engine: Lua 5.4
Trying to render a simple table without ID (the filter is not expected to do anything here):
% cat table.md
Revision Date Change Description
---------- ------------ --------------------
0.5 2022-07-05 Initial Draft
This results in failure:
% pandoc table.md --lua-filter refnos.lua -o table.html
Error running filter refnos.lua:
refnos.lua:71: attempt to index a nil value (field 'integer index')
stack traceback:
refnos.lua:247: in function <refnos.lua:244>
The problem seems to be here:
Line 245 in 4ae8fbc
I fixed it by replacing this line with:
if tbl.attr.identifier ~= "" then
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.