Skip to content

Commit

Permalink
resolves #124 allow format codes in Code blocks
Browse files Browse the repository at this point in the history
Although it only took a change in the Code block template in `Website/plugins/ogdenwebb`, getting it to work with highlighting was not obvious. Basically all HTML tags are replaced with 0xFF chars before highlighting, then put back.
  • Loading branch information
finanalyst committed May 7, 2023
1 parent 52549cf commit fd5c69d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Website/plugins/ogdenwebb/ogdenwebb-replacements.raku
Expand Up @@ -236,8 +236,13 @@ use v6.d;
},
#placeholder
block-code => sub (%prm, %tml) { # previous block-code is set by 02-highlighter
my token tag { <?after <-[ B C E I K L N P R T U V X Z ]> > '<' ~ '>' [ '/'? <-[ > ]>+ ] }
my @tokens;
%prm<contents> .= subst(/ <tag> / , { @tokens.push( ~$/ ); "\xFF\xFF" }, :g );
my $hl = %tml.prior('block-code').(%prm, %tml);
$hl .= subst( / '<pre class="' /, '<pre class="cm-s-ayaya ');
$hl .= subst( / "\xFF\xFF" /, { @tokens.shift }, :g );
$hl .= subst( / '<pre class="' /, '<pre class="cm-s-ayaya ');
qq[
<div class="raku-code raku-lang">
<button class="copy-raku-code" title="Copy code"><i class="far fa-clipboard"></i></button>
Expand Down

0 comments on commit fd5c69d

Please sign in to comment.