tstenner / luarefnos

Pure lua demo for Pandoc cross-references
BSD 2-Clause "Simplified" License
12 stars 3 forks source link

Suggest to support "tbl:" syntax for tables, for compatibility with pandoc-xnos users #4

Closed dmitryperets closed 9 months ago

dmitryperets commented 9 months ago

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:

https://github.com/tstenner/luarefnos/blob/4ae8fbca1d72c76481c975ab83649764c9557abb/refnos.lua#L367-L381

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.

tstenner commented 9 months ago

That should be doable. From a quick glance, the only changes needed are in the HandleTable function.

I tried something in 9015d5203cd6f497d560e73b3e64414a5fc2d49d. Could you check if that works for you?

dmitryperets commented 9 months ago

@tstenner unfortunately, it still fails. The problem is actually here, I think: https://github.com/tstenner/luarefnos/blob/9015d5203cd6f497d560e73b3e64414a5fc2d49d/refnos.lua#L71

Specifically, the Cap[namespace] - it doesn't have tbl there.

tstenner commented 9 months ago

In my tests I added it in the front matter of the sample document:

---
title: Pandoc-fignos Demo
lang: de
luarefnos:
  strs:
    de:
      tbl: {ref: 'Tableu', plural: 'Tableus'}
...

In the markdown names, I find tbl: to be slightly better to read, but the abbreviation in the text is Tab. in both cases, so I'm not entirely convinced the duplicated mapping for the tbl it should be included by default.

dmitryperets commented 9 months ago

Oh I see, you specify the mapping in the metavars... This sounds ok, I guess! The whole idea to support tbl: is because "pandoc-xnos" is using this notation, so anyone having a large document written for pandoc-xnos would need to rename all their tables. But if it is only to add a metavar, then it's fine!

wenbopeng commented 8 months ago

Helpful, thanks! I've given up on Pandoc-crossref and fully embraced luarefnos!