Skip to main content
Topic: Footnotes eat newlines when used at the end of a line (Read 1546 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Footnotes eat newlines when used at the end of a line

Example.[1]

Another paragraph.

A third paragraph.

And here we stick in only one linebreak.[2]
Newline.
Blabla
lala

Re: Footnotes eat newlines when used at the end of a line

Reply #1

Looking into this, setting BLOCK_LEVEL to false removes the problem. I assume it's set to true for nesting reasons or some such? Assuming the block level setting is important, I'd propose changing line 372 as follows to resolve the issue:

Code: [Select]
if ($tag[Codes::ATTR_BLOCK_LEVEL] && $tag[Codes::ATTR_TAG] !== 'footnote' && isset($this->message[$this->pos]) && substr_compare($this->message, '<br />', $this->pos, 6) === 0)

Re: Footnotes eat newlines when used at the end of a line

Reply #2

I think that is what will be needed, footnotes are kind of special.

Josh has a good testbed for the parser here: https://github.com/joshuaadickerson/BBC-Parser under the tests area.  We should get in the habit of running that when making changes to the parser just to avoid (even more) unforeseen consequences!

Re: Footnotes eat newlines when used at the end of a line

Reply #3

Unit tests ftw, except I'm not really sure how to run these tests or anything. xD