Use Markdown::Perl for GitHub-style fenced code blocks (#57)#71
Merged
Conversation
af35341 to
ffed416
Compare
#57) Text::MultiMarkdown has no support for GitHub-style fenced code blocks: a backtick fence was parsed as a single inline <code> span (collapsing the whole block onto one line) and ~~~ fences were ignored entirely. Switch the Markdown engine to Markdown::Perl in GitHub mode, which handles fenced code blocks (with language-foo info-string classes), tables, and the rest of GFM natively. This replaces an earlier hand-rolled fence preprocessor with a maintained CommonMark/GFM implementation. Markdown::Perl follows CommonMark and HTML-escapes " to " during conversion, which would stop Plerd::SmartyPants from curling literal double quotes; drop '"' from html_escaped_characters so quotes survive for SmartyPants (quotes inside code are still escaped via the separate html_escaped_code_characters option). SmartyPants is still required for curly quotes, dashes, and ellipses. Markdown::Perl requires Perl 5.26, so raise the floor in cpanfile. Also declare Capture::Tiny, a long-standing undeclared test dependency of t/init.t: it had been satisfied transitively through the Text::Markdown stack, so removing that stack exposed it. t/code_blocks.t covers backtick and tilde fences, language classes, line preservation, escaping, and untouched inline code. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ffed416 to
fc62437
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #57.
Diagnosis
Text::MultiMarkdownonly understands indented (4-space) code blocks — it has no support for GitHub-style fences. A triple-backtick block was parsed as a single inline<code>span, so every line collapsed together (the reporter's "wrapped block of code rather than each line on a new line"), and~~~fences were ignored entirely.Approach
Rather than pre-processing fences by hand, swap the Markdown engine to
Markdown::Perlin GitHub mode. It's a maintained, pure-Perl CommonMark + GFM implementation that handles fenced code blocks (withlanguage-fooinfo-string classes), tables, and the rest of GFM natively. The hand-rolled fence preprocessor is gone.SmartyPants interaction
Markdown::Perlfollows CommonMark and HTML-escapes"→"during conversion, which would stopPlerd::SmartyPantsfrom curling literal double quotes into typographic ones. We drop"fromhtml_escaped_charactersso quotes survive for SmartyPants; quotes inside code spans/blocks are still escaped via the separatehtml_escaped_code_charactersoption. SmartyPants is still required (and kept) for curly quotes, en/em dashes, and ellipses —Markdown::Perldoes no typographic substitution of its own.Notes
cpanfile):Markdown::Perlrequires it.Makefile.PLis regenerated by Minilla at release, per the existing house pattern for dependency changes.cpanfile: dropText::MultiMarkdown, addMarkdown::Perl(pure Perl, no compiler/C library).CLAUDE.mdupdated to describe the new engine.Tests
t/code_blocks.tcovers backtick and tilde fences, language classes, line preservation, escaping, and untouched inline code. Full suite (84 tests) passes, including the existing MultiMarkdown table test.