Skip to content

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

Description

@somelinguist

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
:::

<div id="ex4.13">
<table class="linguistic-example">
<tbody>
<tr class="odd">
<td class="linguistic-example-number" style="vertical-align: top;">(4.13)</td>
<td class="linguistic-example-content" style="text-align: left;">This is a test</td>
</tr>
</tbody>
</table>
</div>

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

pandoc-ling/pandoc-ling.lua

Lines 268 to 277 in a9eae71

-- reformat!
local example
if FORMAT:match "latex" or FORMAT:match "beamer" then
example = texMakeExample(parsedDiv)
else
example = parsedDiv.examples
example = pandocMakeExample(parsedDiv)
example = pandoc.Div(example)
example.attr = {id = "ex"..parsedDiv.number}
end

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?

pandoc-ling/pandoc-ling.lua

Lines 1538 to 1547 in a9eae71

-- make the cross-reference
if FORMAT:match "latex" then
if latexPackage == "expex" then
return pandoc.RawInline("latex", "(\\getref{"..id.."}"..suffix..")")
else
return pandoc.RawInline("latex", "(\\ref{"..id.."}"..suffix..")")
end
else
return pandoc.Link("("..indexEx[id]..suffix..")", "#"..id)
end

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions