blog: take non-labelled code blocks into account

Peter Cai 2020-04-15 21:06:30 +08:00
parent 5f790e4b37
commit 3a1520f0db
No known key found for this signature in database
GPG Key ID: 71F5FB4E4F3FD54F
1 changed files with 1 additions and 1 deletions

View File

@ -253,7 +253,7 @@ impl PostContentCache {
// We don't match the end tag because it may span multiple lines
// trying to match the end tag could result in accidentally matching
// the end tag of another code block.
let regex_code = RegExp::new("<pre><code class=\"language-([^\"]*)\">", "ig");
let regex_code = RegExp::new("<pre><code( class=\"language-([^\"]*)\")?>", "ig");
let js_html = js_html.replace_by_pattern(&regex_code, "<pre><code class=\"hljs\">");
// Transform all non-self-refernece links (does not start with "#") to target="_blank"