fletcher / peg-multimarkdown

An implementation of MultiMarkdown in C, using a PEG grammar - a fork of jgm's peg-markdown. No longer under active development - see MMD 5.
Other
523 stars 55 forks source link

Broken auto-referencing for headlines #92

Closed x3ro closed 12 years ago

x3ro commented 12 years ago

If there is any kind of (HTML-style) comment on the line before a headline, then auto-referencing will not work for that headline, for example:

This works

<!-- \newpage -->

# Some headline
Some very important text.

# Another headline
Some reference to [Some headline][]

And will result in: \newpage

\part{Some headline}
\label{someheadline}

Some very important text.

\part{Another headline}
\label{anotherheadline}

Some reference to Some headline (\autoref{some headline})

This does NOT work

<!-- \newpage -->
# Some headline
Some very important text.

# Another headline
Some reference to [Some headline][]

And will therefore result in:

\newpage 

\part{Some headline}
\label{someheadline}

Some very important text.

\part{Another headline}
\label{anotherheadline}

Some reference to [Some headline][]

Note the last line, where the reference should be. This is always reproducible and will happen even with an empty comment, that is <!-- -->.

fletcher commented 12 years ago

All you need to do is insert a blank line before the heading, e.g.:

<!-- \newpage -->

# Some headline
Some very important text.

# Another headline
Some reference to [Some headline][]
x3ro commented 12 years ago

Yeah, thanks. However I do think that this should be fixed, because it took me hours to find out what was causing this, and it is clearly unexpected behavior, right?

fletcher commented 12 years ago

When I get time, I'll try to add a workaround for this. But in general it's good practice to include a blank line before block level elements to minimize divergent behavior between various Markdown variants.

fletcher commented 12 years ago

Actually, may have found easy fix and pushed to development branch. Will need some more testing, but might work.

x3ro commented 12 years ago

Thanks. I can see how one should add a blank line, and I wouldn't care if MMD had given me a notices of some kind that my reference had been dropped (because of the missing newline), but it was really confusing for me because I couldn't figure out why it did not create the reference.