Skip to content

Commit

Permalink
work around syntaxhighlighter bug causing empty blocks on perlsecret
Browse files Browse the repository at this point in the history
perlsecret.pod has some code blocks that are very short. The syntax
highlighter has a bug when it attempts to strip <![CDATA[ ]]> blocks,
which ends up entirely erasing short code block content. The CDATA
stripping is only enabled when the useScriptTags option is enabled,
which we don't need or want. Work around the bug by disabling
useScriptTags.

This bug had previously been fixed by patching the vendor library to fix
the CDATA stripping. That change was lost in the conversion to
node_modules.
  • Loading branch information
haarg committed Nov 13, 2024
1 parent 73dc5d1 commit 16f077c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions root/static/js/syntaxhighlighter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ SyntaxHighlighter.regexLib['url'] = /[a-z][a-z0-9.+-]*:\/\/[\w-./?%&=:@;#~]*[\w-
// Use regular spaces, not &nbsp;
SyntaxHighlighter.config.space = ' ';

// We aren't using <script type="syntaxhighlighter" />, and when enabled it
// attempts to strip <![CDATA[ ]]> sections. That code is buggy, and breaks
// short code blocks, such as on perlsecret.pod
SyntaxHighlighter.config.useScriptTags = false;

// https://metacpan.org/source/RWSTAUNER/Acme-Syntax-Examples-0.001/lib/Acme/Syntax/Examples.pm

// TODO: Might be easier to do the regexp on the plain string (before
Expand Down

0 comments on commit 16f077c

Please sign in to comment.