Dont show relevance or predicted language until we have a better way to handle translation inside markdown handlers

indiachan-spamvector
Thomas Lynch 1 year ago
parent a275b8620c
commit 0a5b74ea31
  1. 1
      CHANGELOG.md
  2. 8
      lib/post/markdown/markdown.js

@ -19,6 +19,7 @@ Now, back to the program. Here are the changes for 1.0.0, with one especially no
- Customflags will now show correctly when editing a post on a board with custom flags enabled.
- Security improvement to the 2FA validation flow during login.
- Log a few more errors related to hcaptcha/recaptcha, for debugging purposes. (already caught and returned in a friendly manner)
- Remove showing language and relevance data when auto detecting highlighted code block language
- More minor bugfixes to permissions pages displays.
### 0.11.3

@ -76,7 +76,7 @@ module.exports = {
const newlineFix = escaped.replace(/^\r?\n/,''); //fix ending newline because of codeblock
chunks[i] = module.exports.processRegularChunk(newlineFix, permissions);
} else if (permissions.get(Permissions.USE_MARKDOWN_CODE)){
chunks[i] = module.exports.processCodeChunk(chunks[i], highlightOptions);
chunks[i] = module.exports.ww(chunks[i], highlightOptions);
}
}
return chunks.join('');
@ -91,15 +91,15 @@ module.exports = {
}
if (!lang) {
//no language specified, try automatic syntax highlighting
const { language, relevance, value } = highlightAuto(trimFix, highlightOptions.languageSubset);
const { relevance, value } = highlightAuto(trimFix, highlightOptions.languageSubset);
if (relevance > highlightOptions.threshold) {
return `<span class='code hljs'><small>possible language: ${language}, relevance: ${relevance}</small>\n${value}</span>`;
return `<span class='code hljs'>${value}</span>`;
}
} else if (lang === 'aa') {
return `<span class='aa'>${simpleEscape(matches.groups.code)}</span>`;
} else if (validLanguages.includes(lang)) {
const { value } = highlight(trimFix, { language: lang, ignoreIllegals: true });
return `<span class='code hljs'><small>language: ${lang}</small>\n${value}</span>`;
return `<span class='code hljs'>${value}</span>`;
}
//else, auto highlight relevance threshold was too low, lang was not a valid language, or lang was 'plain'
return `<span class='code'>${simpleEscape(trimFix)}</span>`;

Loading…
Cancel
Save