mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-24 10:15:37 +03:00
Cache another regex
This commit is contained in:
parent
66e8bfe18c
commit
f85cf22558
1 changed files with 2 additions and 1 deletions
|
@ -28,6 +28,7 @@ const INLINE_CODE_REGEX = /`[^`]+`/;
|
|||
const TWITTER_DOMAIN_REGEX = /(twitter|x)\.com/i;
|
||||
const TWITTER_MENTION_REGEX = /@[a-zA-Z0-9_]+@(twitter|x)\.com/;
|
||||
const TWITTER_MENTION_CAPTURE_REGEX = /(@([a-zA-Z0-9_]+)@(twitter|x)\.com)/g;
|
||||
const CODE_INLINE_CAPTURE_REGEX = /(`[^]+?`)/g;
|
||||
|
||||
function createDOM(html, isDocumentFragment) {
|
||||
if (isDocumentFragment) {
|
||||
|
@ -197,7 +198,7 @@ function _enhanceContent(content, opts = {}) {
|
|||
for (const node of textNodes) {
|
||||
let html = escapeHTML(node.nodeValue);
|
||||
if (INLINE_CODE_REGEX.test(html)) {
|
||||
html = html.replaceAll(/(`[^]+?`)/g, '<code>$1</code>');
|
||||
html = html.replaceAll(CODE_INLINE_CAPTURE_REGEX, '<code>$1</code>');
|
||||
}
|
||||
fauxDiv.innerHTML = html;
|
||||
// const nodes = [...fauxDiv.childNodes];
|
||||
|
|
Loading…
Reference in a new issue