REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 3.99 KB
Close
//proc/thread-self/root/home/byroehnu/.trash/node_modules11/markdown-it/lib/rules_inline/balance_pairs.mjs
Text
Base64
// For each opening emphasis-like marker find a matching closing one // function processDelimiters (delimiters) { const openersBottom = {} const max = delimiters.length if (!max) return // headerIdx is the first delimiter of the current (where closer is) delimiter run let headerIdx = 0 let lastTokenIdx = -2 // needs any value lower than -1 const jumps = [] for (let closerIdx = 0; closerIdx < max; closerIdx++) { const closer = delimiters[closerIdx] jumps.push(0) // markers belong to same delimiter run if: // - they have adjacent tokens // - AND markers are the same // if (delimiters[headerIdx].marker !== closer.marker || lastTokenIdx !== closer.token - 1) { headerIdx = closerIdx } lastTokenIdx = closer.token // Length is only used for emphasis-specific "rule of 3", // if it's not defined (in strikethrough or 3rd party plugins), // we can default it to 0 to disable those checks. // closer.length = closer.length || 0 if (!closer.close) continue // Previously calculated lower bounds (previous fails) // for each marker, each delimiter length modulo 3, // and for whether this closer can be an opener; // https://github.com/commonmark/cmark/commit/34250e12ccebdc6372b8b49c44fab57c72443460 /* eslint-disable-next-line no-prototype-builtins */ if (!openersBottom.hasOwnProperty(closer.marker)) { openersBottom[closer.marker] = [-1, -1, -1, -1, -1, -1] } const minOpenerIdx = openersBottom[closer.marker][(closer.open ? 3 : 0) + (closer.length % 3)] let openerIdx = headerIdx - jumps[headerIdx] - 1 let newMinOpenerIdx = openerIdx for (; openerIdx > minOpenerIdx; openerIdx -= jumps[openerIdx] + 1) { const opener = delimiters[openerIdx] if (opener.marker !== closer.marker) continue if (opener.open && opener.end < 0) { let isOddMatch = false // from spec: // // If one of the delimiters can both open and close emphasis, then the // sum of the lengths of the delimiter runs containing the opening and // closing delimiters must not be a multiple of 3 unless both lengths // are multiples of 3. // if (opener.close || closer.open) { if ((opener.length + closer.length) % 3 === 0) { if (opener.length % 3 !== 0 || closer.length % 3 !== 0) { isOddMatch = true } } } if (!isOddMatch) { // If previous delimiter cannot be an opener, we can safely skip // the entire sequence in future checks. This is required to make // sure algorithm has linear complexity (see *_*_*_*_*_... case). // const lastJump = openerIdx > 0 && !delimiters[openerIdx - 1].open ? jumps[openerIdx - 1] + 1 : 0 jumps[closerIdx] = closerIdx - openerIdx + lastJump jumps[openerIdx] = lastJump closer.open = false opener.end = closerIdx opener.close = false newMinOpenerIdx = -1 // treat next token as start of run, // it optimizes skips in **<...>**a**<...>** pathological case lastTokenIdx = -2 break } } } if (newMinOpenerIdx !== -1) { // If match for this delimiter run failed, we want to set lower bound for // future lookups. This is required to make sure algorithm has linear // complexity. // // See details here: // https://github.com/commonmark/cmark/issues/178#issuecomment-270417442 // openersBottom[closer.marker][(closer.open ? 3 : 0) + ((closer.length || 0) % 3)] = newMinOpenerIdx } } } export default function link_pairs (state) { const tokens_meta = state.tokens_meta const max = state.tokens_meta.length processDelimiters(state.delimiters) for (let curr = 0; curr < max; curr++) { if (tokens_meta[curr] && tokens_meta[curr].delimiters) { processDelimiters(tokens_meta[curr].delimiters) } } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 15
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
autolink.mjs
1.96 KB
lrw-r--r--
2026-02-28 00:28:22
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
backticks.mjs
1.63 KB
lrw-r--r--
2026-02-28 00:28:26
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
balance_pairs.mjs
3.99 KB
lrw-r--r--
2026-02-28 00:28:26
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
emphasis.mjs
3.44 KB
lrw-r--r--
2026-02-28 00:28:38
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
entity.mjs
1.45 KB
lrw-r--r--
2026-02-28 00:28:38
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
escape.mjs
1.39 KB
lrw-r--r--
2026-02-28 00:28:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
fragments_join.mjs
1.24 KB
lrw-r--r--
2026-02-28 00:28:44
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
html_inline.mjs
1.14 KB
lrw-r--r--
2026-02-28 00:28:54
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
image.mjs
3.55 KB
lrw-r--r--
2026-02-28 00:28:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
link.mjs
3.64 KB
lrw-r--r--
2026-02-28 00:29:04
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
linkify.mjs
1.86 KB
lrw-r--r--
2026-02-28 00:29:06
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
newline.mjs
1.17 KB
lrw-r--r--
2026-02-28 00:29:08
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
state_inline.mjs
3.41 KB
lrw-r--r--
2026-02-28 00:29:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
strikethrough.mjs
2.87 KB
lrw-r--r--
2026-02-28 00:29:32
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
text.mjs
2.05 KB
lrw-r--r--
2026-02-28 00:29:34
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).