cysouw / pandoc-ling

Pandoc Lua filter for linguistic examples
Creative Commons Zero v1.0 Universal
37 stars 6 forks source link

Links for cross-references with explicit an ID don't work with HTML output #18

Open somelinguist opened 9 months ago

somelinguist commented 9 months ago

With the following markdown from readme.md, the div's ID in the HTML output gets overwritten to ex4.13 instead of test.

::: {#test .ex}
This is a test
:::

https://github.com/cysouw/pandoc-ling/blob/a9eae71593c0d12e3db68342d0c7e22ec2b23deb/docs/readme.html#L722-L731

However, the cross-references using [@last], etc. maintain test as the ID to link to (the following is taken from readme.html, line 732):

<code>[@last]</code> will be formatted as <a href="#test">(4.13)</a>

Likewise, in line 733:

<code>[@last hA1l0]</code> will work also, leading to <a href="#test">(4.13 hA1l0)</a>

and line 717:

<code>[@test]</code>, leading to <a href="#test">(4.13)</a>

The ID for the div gets reset for HTML output in line 276 of pandoc-ling.lua

https://github.com/cysouw/pandoc-ling/blob/a9eae71593c0d12e3db68342d0c7e22ec2b23deb/pandoc-ling.lua#L268-L277

Following the proposal one should be able to link from an external source to something like webpage.url/#ex4.13, should the code that makes the cross-references for HTML also change the ID to #ex4.13 instead of #test?

https://github.com/cysouw/pandoc-ling/blob/a9eae71593c0d12e3db68342d0c7e22ec2b23deb/pandoc-ling.lua#L1538-L1547

somelinguist commented 9 months ago

Actually, for the HTML output, if you wanted, you could make a link using either #test or #ex4.13 work if line 276 set the div's ID to test, and then added an ID for something like the cell containing the example number itself to ex4.13:

https://github.com/cysouw/pandoc-ling/blob/a9eae71593c0d12e3db68342d0c7e22ec2b23deb/pandoc-ling.lua#L556-L558