PandocNet icon indicating copy to clipboard operation
PandocNet copied to clipboard

No header link anchor generated

Open Scal-Human opened this issue 1 year ago • 3 comments

Hi,

Searching to automate ebook production, I was planning to use your library over Pandoc to produce Html from Markdown (and then ePub). The first test I make is a simple poem with a title which I was expecting to be marked (anchor) to have a link to the fragment. The first line of the poem is the title header:

# Ce qu'on ne dit pas à propos de l'amour

Using the Pandoc command-line (v 3.2.1)

pandoc "C:\...\Poem.md" -o "C:\...\Poem-Cmd.html"

the first line decomes:

<h1 id="ce-quon-ne-dit-pas-à-propos-de-lamour">Ce qu’on ne dit pas à propos de l’amour</h1>

Using the Pandoc library (v 3.1.1)

PandocInstance.Convert<CommonMarkIn, HtmlOut>(@"C:\...\Poem.md", @"C:\...\Poem-Lib.html");

the first line of the result is

<h1>Ce qu'on ne dit pas à propos de l'amour</h1>

FYI: I am using dotNet Sdk 8.0.303 targetting net8.0

I had a look in the parameters, but did not found anything related, and I am comparing the runs with the same "all defaults" for command-line and library.

Scal-Human avatar Aug 24 '24 08:08 Scal-Human

have you tried debuggin it and seeing if the command line parameters differ in any way?

SimonCropp avatar Aug 24 '24 10:08 SimonCropp

@SimonCropp No, and the command line executes too fast to get information from process explorer (even with 9s highlight). I tried to set the LogFile in the Options but it writes an empty json "[]". But note that Pandoc command line creates header id's without any parameter other than iput and output file.

Scal-Human avatar Aug 24 '24 21:08 Scal-Human

I added a test of my own in the tests project, and tried to break in it but the breakpoint is not taken into account by VSCode. The output result is the same, no ID on the h1 or h2 headers. And without breakpoint, I cannot go down to the command-line construction. But it is easily reproduced with markdown as

# Header text

The quick brown fox jumps over the lazy dog.

## Intro

Introdution.

and call like in test project

await PandocInstance.Convert<CommonMarkIn, HtmlOut>("sample.md", "output.html");

output is

<h1>Header text</h1>
<p>The quick brown fox jumps over the lazy dog.</p>
<h2>Intro</h2>
<p>Introdution</p>

Using the exact same file as input and the Pandoc command line, we have

<h1 id="header-text">Header text</h1>
<p>The quick brown fox jumps over the lazy dog.</p>
<h2 id="intro">Intro</h2>
<p>Introdution</p>

Scal-Human avatar Aug 24 '24 21:08 Scal-Human

CommonMark in pandoc does not seem to add the id. the same happens if i use the comand line

C:\Code>pandoc.exe a.md --from=commonmark --to=html
<h1>Header text</h1>

if u omit commonmark then the default is actuall PandocMdIn

await PandocInstance.Convert<PandocMdIn, HtmlOut>("sample.md", "output.html");

SimonCropp avatar Mar 17 '25 10:03 SimonCropp