mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 14:54:48 +08:00
hoist pre blocks last
This commit is contained in:
parent
568adc49c0
commit
d8d849ee84
|
@ -188,14 +188,6 @@ function hoistCodeBlocksAndSpans(text) {
|
|||
|
||||
// /!\ the order is important /!\
|
||||
|
||||
// <pre>...</pre> code blocks
|
||||
text = text.replace(/(\s|^)<pre>([\s\S]*?)<\/pre>/ig, function(_, before, content) {
|
||||
var hash = md5(content);
|
||||
hoisted[hash] = escape(showBackslashEscapedCharacters(removeEmptyLines(content)));
|
||||
return before + "<pre>" + hash + "</pre>";
|
||||
});
|
||||
|
||||
|
||||
// fenced code blocks (AKA GitHub code blocks)
|
||||
text = text.replace(/(^\n*|\n)```([a-z0-9\-]*)\n([\s\S]*?)\n```/g, function(_, before, language, content) {
|
||||
var hash = md5(content);
|
||||
|
@ -219,6 +211,13 @@ function hoistCodeBlocksAndSpans(text) {
|
|||
return before + " " + hash + "\n";
|
||||
});
|
||||
|
||||
// <pre>...</pre> code blocks
|
||||
text = text.replace(/(\s|^)<pre>([\s\S]*?)<\/pre>/ig, function(_, before, content) {
|
||||
var hash = md5(content);
|
||||
hoisted[hash] = escape(showBackslashEscapedCharacters(removeEmptyLines(content)));
|
||||
return before + "<pre>" + hash + "</pre>";
|
||||
});
|
||||
|
||||
// code spans (double & single `)
|
||||
["``", "`"].forEach(function(delimiter) {
|
||||
var regexp = new RegExp("(^|[^`])" + delimiter + "([^`\\n]+?)" + delimiter + "([^`]|$)", "g");
|
||||
|
|
Loading…
Reference in New Issue
Block a user