FIX: Ability to trigger emoji after indented code block (#18478)

This commit is contained in:
Keegan George 2022-10-05 10:33:08 -07:00 committed by GitHub
parent 94aba90c56
commit 15f192447b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 14 deletions

View File

@ -460,18 +460,18 @@ export function postRNWebviewMessage(prop, value) {
} }
const CODE_BLOCKS_REGEX = const CODE_BLOCKS_REGEX =
/^( |\t).*|`[^`]+`|^```[^]*?^```|\[code\][^]*?\[\/code\]/gm; /^( |\t).*|`[^`]+`|^```[^]*?^```|\[code\][^]*?\[\/code\]/gm;
// | ^ | ^ | ^ | ^ | //| ^ | ^ | ^ | ^ |
// | | | | // | | | |
// | | | code blocks between [code] // | | | code blocks between [code]
// | | | // | | |
// | | +--- code blocks between three backticks // | | +--- code blocks between three backticks
// | | // | |
// | +----- inline code between backticks // | +----- inline code between backticks
// | // |
// +------- paragraphs starting with 4 spaces or tab // +------- paragraphs starting with 2 spaces or tab
const OPEN_CODE_BLOCKS_REGEX = /`[^`]+|^```[^]*?|\[code\][^]*?/gm; const OPEN_CODE_BLOCKS_REGEX = /^( |\t).*|`[^`]+|^```[^]*?|\[code\][^]*?/gm;
export function inCodeBlock(text, pos) { export function inCodeBlock(text, pos) {
let end = 0; let end = 0;

View File

@ -271,18 +271,23 @@ discourseModule("Unit | Utilities", function () {
test("inCodeBlock", function (assert) { test("inCodeBlock", function (assert) {
const texts = [ const texts = [
// closed code blocks // CLOSED CODE BLOCKS:
"000\n\n 111\n\n000", "000\n\n 111\n\n000",
"000 `111` 000", "000 `111` 000",
"000\n```\n111\n```\n000", "000\n```\n111\n```\n000",
"000\n[code]111[/code]\n000", "000\n[code]111[/code]\n000",
// open code blocks // OPEN CODE BLOCKS:
"000\n\n 111", "000\n\n 111",
"000 `111", "000 `111",
"000\n```\n111", "000\n```\n111",
"000\n[code]111", "000\n[code]111",
// complex test // COMPLEX TEST:
"000\n\n```\n111\n```\n\n000\n\n`111 111`\n\n000\n\n[code]\n111\n[/code]\n\n 111\n\t111\n\n000`111", "000\n\n```\n111\n```\n\n000\n\n`111 111`\n\n000\n\n[code]\n111\n[/code]\n\n 111\n\t111\n\n000`111",
// INDENTED OPEN CODE BLOCKS:
// - Using tab
"000\n\t```111\n\t111\n\t111```\n000",
// - Using spaces
`000\n \`\`\`111\n 111\n 111\`\`\`\n000`,
]; ];
texts.forEach((text) => { texts.forEach((text) => {