Skip to content

Commit

Permalink
fix(bbcode): highlight.js does not work after changing post content
Browse files Browse the repository at this point in the history
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
  • Loading branch information
SychO9 committed Apr 30, 2023
1 parent 919c3bb commit 8081e9b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions extensions/bbcode/extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,15 @@
$config->BBCodes->addFromRepository('CENTER');
$config->BBCodes->addFromRepository('SIZE');
$config->BBCodes->addFromRepository('*');

// Fix for highlight JS not working after changing post content.
$codeTag = $config->tags->get('CODE');
$script = '
<script>
if(window.hljsLoader && !document.currentScript.parentNode.hasAttribute(\'data-s9e-livepreview-onupdate\')) {
window.hljsLoader.highlightBlocks(document.currentScript.parentNode);
}
</script>';
$codeTag->template = str_replace('</pre>', $script.'</pre>', $codeTag->template);
}),
];

0 comments on commit 8081e9b

Please sign in to comment.