Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2023-04-18 23:50:26 +02:00
parent 7dda1155d4
commit e76a9ec8aa

View file

@ -57,6 +57,28 @@ export const UNESCAPE_ITALIC_UNDERSCORE: TextMatchTransformer = {
type: 'text-match', type: 'text-match',
}; };
const UNESCAPE_ITALIC_STAR_IMPORT_REGEX =
/([\*])(?<!(?:\1|\w).)(?![_*\s])(.*?[^_*\s])(?=\1)([\*])(?!\w|\3)/;
const UNESCAPE_ITALIC_STAR_REGEX =
/([\*])(?<!(?:\1|\w).)(?![_*\s])(.*?[^_*\s])(?=\1)([\*])(?!\w|\3)/;
export const UNESCAPE_ITALIC_STAR: TextMatchTransformer = {
dependencies: [],
export: () => null,
importRegExp: UNESCAPE_ITALIC_STAR_IMPORT_REGEX,
regExp: UNESCAPE_ITALIC_STAR_REGEX,
replace: (textNode, _) => {
const notEscapedStarRegex = /(?<![\\]{1})[\*]{1}/g;
const textContent = replaceUnescapedChars(textNode.getTextContent(), [
notEscapedStarRegex,
]);
textNode.setTextContent(replaceEscapedChars(textContent));
textNode.setFormat('italic');
},
trigger: '*',
type: 'text-match',
};
const UNESCAPE_BACKSLASH_IMPORT_REGEX = /(\\(?:\\\\)?).*?\1*[\~\*\_\{\}\[\]\(\)\#\+\-\.\!]/; const UNESCAPE_BACKSLASH_IMPORT_REGEX = /(\\(?:\\\\)?).*?\1*[\~\*\_\{\}\[\]\(\)\#\+\-\.\!]/;
const UNESCAPE_BACKSLASH_REGEX = /(\\(?:\\\\)?).*?\1*[\~\*\_\{\}\[\]\(\)\#\+\-\.\!]$/; const UNESCAPE_BACKSLASH_REGEX = /(\\(?:\\\\)?).*?\1*[\~\*\_\{\}\[\]\(\)\#\+\-\.\!]$/;
@ -82,7 +104,7 @@ export const TO_WYSIWYG_TRANSFORMERS = [
BOLD_UNDERSCORE, BOLD_UNDERSCORE,
STRIKETHROUGH, STRIKETHROUGH,
UNESCAPE_ITALIC_UNDERSCORE, UNESCAPE_ITALIC_UNDERSCORE,
// UNESCAPE_ITALIC_STAR, UNESCAPE_ITALIC_STAR,
INLINE_CODE, INLINE_CODE,
HEADING, HEADING,
QUOTE, QUOTE,