You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a lot of longer footnotes on the website and sometimes depending on the format it makes some letters disappear from the front of paragraphs.
My sentence[^1][^2][^3][^4]
---
[^1]: This footnote uses tabs to indent the following paragraphs, you will notice the first 3 letters are missing:
Donec ac dolor blandit, laoreet est sed, ornare est. Nunc varius ligula sit amet leo varius tempus. Donec pharetra nisi at est pellentesque, non ultricies lorem fringilla.
Donec ac dolor blandit, laoreet est sed, ornare est. Nunc varius ligula sit amet leo varius tempus. Donec pharetra nisi at est pellentesque, non ultricies lorem fringilla.
[^2]:
This footnote uses tabs for all paragraphs.
Donec ac dolor blandit, laoreet est sed, ornare est. Nunc varius ligula sit amet leo varius tempus. Donec pharetra nisi at est pellentesque, non ultricies lorem fringilla.
Donec ac dolor blandit, laoreet est sed, ornare est. Nunc varius ligula sit amet leo varius tempus. Donec pharetra nisi at est pellentesque, non ultricies lorem fringilla.
[^3]: This footnote uses 4 spaces and it's working fine:
Donec ac dolor blandit, laoreet est sed, ornare est. Nunc varius ligula sit amet leo varius tempus. Donec pharetra nisi at est pellentesque, non ultricies lorem fringilla.
Donec ac dolor blandit, laoreet est sed, ornare est. Nunc varius ligula sit amet leo varius tempus. Donec pharetra nisi at est pellentesque, non ultricies lorem fringilla.
[^4]:
This footnote uses four spaces for indenting all paragraphs and it's fine.
Donec ac dolor blandit, laoreet est sed, ornare est. Nunc varius ligula sit amet leo varius tempus. Donec pharetra nisi at est pellentesque, non ultricies lorem fringilla.
Donec ac dolor blandit, laoreet est sed, ornare est. Nunc varius ligula sit amet leo varius tempus. Donec pharetra nisi at est pellentesque, non ultricies lorem fringilla.
You can see a screenshot of how it renders, you can see the first two footnotes are missing 3 letters in some places.
How to reproduce
Here's a test file from my Laravel app:
<?phpnamespaceTests\Unit;
useLeague\CommonMark\Extension\Footnote\FootnoteExtension;
useTests\TestCase;
useLeague\CommonMark\Environment\Environment;
useLeague\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
useLeague\CommonMark\MarkdownConverter;
classMarkdownFootnotesExtensionTestextendsTestCase
{
/** @test */publicfunctionmultiline_footnotes_with_tabs_are_rendered()
{
// Configure the Environment with all the CommonMark parsers/renderers$environment = newEnvironment();
$environment->addExtension(newCommonMarkCoreExtension());
// Add this extension$environment->addExtension(newFootnoteExtension());
// Instantiate the converter engine and start converting some Markdown!$converter = newMarkdownConverter($environment);
$markdown = <<<MARKDOWNSentence[^1][^1]: This footnote uses tabs to indent the following paragraphs Donec ac dolor blandit, laoreet est sed, ornare est. Donec ac dolor blandit, laoreet est sed, ornare est. MARKDOWN;
$this->assertEquals(<<<HTML<p>Sentence<sup id="fnref:1"><a class="footnote-ref" href="#fn:1" role="doc-noteref">1</a></sup></p><div class="footnotes" role="doc-endnotes"><hr /><ol><li class="footnote" id="fn:1" role="doc-endnote"><p>This footnote uses tabs to indent the following paragraphs</p><p>Donec ac dolor blandit, laoreet est sed, ornare est.</p><p>Donec ac dolor blandit, laoreet est sed, ornare est. <a class="footnote-backref" rev="footnote" href="#fnref:1" role="doc-backlink">↩</a></p></li></ol></div>HTML, (string) $converter->convert($markdown));
}
}
And the output that I receive:
--- Expected
+++ Actual
-<p>Donec ac dolor blandit, laoreet est sed, ornare est.</p>\n
-<p>Donec ac dolor blandit, laoreet est sed, ornare est. <a class="footnote-backref" rev="footnote" href="#fnref:1" role="doc-backlink">↩</a></p></li></ol></div>\n
+<p>ec ac dolor blandit, laoreet est sed, ornare est.</p>\n
+<p>ec ac dolor blandit, laoreet est sed, ornare est. <a class="footnote-backref" rev="footnote" href="#fnref:1" role="doc-backlink">↩</a></p></li></ol></div>\n
Possible solution
Well it's expecting a tab to have 4 spaces, so it should be able to optionally detect the tab character? By the time the code gets to the FootnoteRenderer class it's already been truncated... so it must be in the FootnoteStartParser class when it's trying to parse the block.
Additional context
No response
Did this project help you today? Did it make you happy in any way?
I love it but I wish there were more tutorials on how to make custom extensions! It looks super complicated... 🙈
The text was updated successfully, but these errors were encountered:
Your hunch was correct! We weren't expanding the tab to 4 spaces when handing the indentation. This is now fixed in versions 2.3.2 and 2.2.5. Thanks again for the report!
I love it but I wish there were more tutorials on how to make custom extensions! It looks super complicated... 🙈
It's easier than it looks, but I do agree the docs could use some work... especially some visual diagrams explaining what's happening under-the-hood. I'll try to carve out some time to spruce up those docs. In the mean time, if you want to try writing your own, I highly recommend finding an extension/parser/renderer that closely matches what you're looking for and then experiment with tweaking it :)
Version(s) affected
2.3.0
Description
We have a lot of longer footnotes on the website and sometimes depending on the format it makes some letters disappear from the front of paragraphs.
You can see a screenshot of how it renders, you can see the first two footnotes are missing 3 letters in some places.
How to reproduce
Here's a test file from my Laravel app:
And the output that I receive:
Possible solution
Well it's expecting a tab to have 4 spaces, so it should be able to optionally detect the tab character? By the time the code gets to the
FootnoteRenderer
class it's already been truncated... so it must be in theFootnoteStartParser
class when it's trying to parse the block.Additional context
No response
Did this project help you today? Did it make you happy in any way?
I love it but I wish there were more tutorials on how to make custom extensions! It looks super complicated... 🙈
The text was updated successfully, but these errors were encountered: