From c2e7699b1535ec4ab666cbc71d2118a68ce02640 Mon Sep 17 00:00:00 2001 From: Thomas Lynch Date: Fri, 13 Nov 2020 10:57:06 +0000 Subject: [PATCH] change code blocks to [code][/code], try not to interfere with sjis as much reference #278 --- gulp/res/css/style.css | 2 +- helpers/posting/markdown.js | 6 +++--- views/custompages/faq.pug.example | 27 +++++++++++++++++++++++---- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/gulp/res/css/style.css b/gulp/res/css/style.css index 8f0b0d12..c43fcc6d 100644 --- a/gulp/res/css/style.css +++ b/gulp/res/css/style.css @@ -116,7 +116,7 @@ pre { white-space: pre; } -.code.aa { +.aa { font-family: Monapo, Mona, 'MS Pgothic', 'MS P繧エ繧キ繝�け', IPAMonaPGothic, 'IPA 繝「繝翫� P繧エ繧キ繝�け', submona !important; font-size: 16px; } diff --git a/helpers/posting/markdown.js b/helpers/posting/markdown.js index 972e2dc9..744c4e63 100644 --- a/helpers/posting/markdown.js +++ b/helpers/posting/markdown.js @@ -12,8 +12,8 @@ const greentextRegex = /^>((?!>\d+|>>/\w+(/\d*)?).*)/gm , detectedRegex = /(\(\(\(.+?\)\)\))/gm , linkRegex = /https?\://[^\s<>\[\]{}|\\^]+/g , codeRegex = /(?:(?[a-z+]{1,10})\r?\n)?(?[\s\S]+)/i - , includeSplitRegex = /(```[\s\S]+?```)/gm - , splitRegex = /```([\s\S]+?)```/gm + , includeSplitRegex = /(\[code\][\s\S]+?\[\/code\])/gm + , splitRegex = /\[code\]([\s\S]+?)\[\/code\]/gm , trimNewlineRegex = /^\s*(\r?\n)*|(\r?\n)*$/g , getDomain = (string) => string.split(/\/\/|\//)[1] //unused atm , escape = require(__dirname+'/escape.js') @@ -83,7 +83,7 @@ module.exports = { const { value } = highlight(lang, trimFix, true); return `language: ${lang}\n${value}`; } else if (lang === 'aa') { - return `${escape(matches.groups.code)}`; + return `${escape(matches.groups.code)}`; } return `${escape(trimFix)}`; }, diff --git a/views/custompages/faq.pug.example b/views/custompages/faq.pug.example index 0fc4c22c..6a093a49 100644 --- a/views/custompages/faq.pug.example +++ b/views/custompages/faq.pug.example @@ -152,6 +152,14 @@ block content td (((detected))) td span.detected (((detected))) + tr + td + | [aa]∧_∧ + | ( ・ω・) Let's try that again.[/aa] + td + pre.aa + | ∧_∧ + | ( ・ω・) Let's try that again. tr td ##2d9+3 td @@ -175,13 +183,24 @@ block content span.mono inline monospace tr td - | ```language + | [code]language br - | code block + | int main() {...} br - | ``` + | [/code] + td + span.code int main() {...} + tr + td + pre + | [code]aa + | ∧_∧ + | ( ・ω・) Let's try that again. + | [/code] td - span.code code block + pre.aa + | ∧_∧ + | ( ・ω・) Let's try that again. tr td(colspan=2) | The "language" of code blocks is optional. Without it, automatic language detection is used.