@readme/markdown 13.1.4 → 13.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js
CHANGED
|
@@ -94031,9 +94031,12 @@ const evaluateExpressions = ({ context = {} } = {}) => tree => {
|
|
|
94031
94031
|
}
|
|
94032
94032
|
catch (_error) {
|
|
94033
94033
|
// If evaluation fails, leave the expression as-is (fallback to text)
|
|
94034
|
+
// we still need to manually escape escaped characters because the expression
|
|
94035
|
+
// parser treats the contents as code instead of text, skipping the backslash escapes
|
|
94036
|
+
const processed = expression.replace(/\\([!-/:-@[-`{-~])/g, '$1');
|
|
94034
94037
|
parent.children.splice(index, 1, {
|
|
94035
94038
|
type: 'text',
|
|
94036
|
-
value: `{${
|
|
94039
|
+
value: `{${processed}}`,
|
|
94037
94040
|
position: node.position,
|
|
94038
94041
|
});
|
|
94039
94042
|
}
|
|
@@ -94126,11 +94129,11 @@ const MARKER_PATTERNS = [
|
|
|
94126
94129
|
// trailingSpace1 is for "** text **" pattern, trailingSpace2 is for "**text **" pattern
|
|
94127
94130
|
const asteriskBoldRegex = /([^*\s]+)?\s*(\*\*)(?:\s+((?:[^*\n]|\*(?!\*))+?)(\s*)\2|((?:[^*\n]|\*(?!\*))+?)(\s+)\2)(\S|$)?/g;
|
|
94128
94131
|
// Pattern for __ bold __
|
|
94129
|
-
const underscoreBoldRegex = /([^_\s]+)?\s*(__)(?:\s+((?:[^_\n]
|
|
94132
|
+
const underscoreBoldRegex = /([^_\s]+)?\s*(__)(?:\s+((?:__(?! )|_(?!_)|[^_\n])+?)(\s*)\2|((?:__(?! )|_(?!_)|[^_\n])+?)(\s+)\2)(\S|$)?/g;
|
|
94130
94133
|
// Pattern for * italic *
|
|
94131
94134
|
const asteriskItalicRegex = /([^*\s]+)?\s*(\*)(?!\*)(?:\s+([^*\n]+?)(\s*)\2|([^*\n]+?)(\s+)\2)(\S|$)?/g;
|
|
94132
94135
|
// Pattern for _ italic _
|
|
94133
|
-
const underscoreItalicRegex = /([^_\s]+)?\s*(_)(?!_)(?:\s+([^_\n]+?)(\s*)\2|([^_\n]+?)(\s+)\2)(\S|$)?/g;
|
|
94136
|
+
const underscoreItalicRegex = /([^_\s]+)?\s*(_)(?!_)(?:\s+((?:[^_\n]|_(?! ))+?)(\s*)\2|((?:[^_\n]|_(?! ))+?)(\s+)\2)(\S|$)?/g;
|
|
94134
94137
|
// CommonMark ignores intraword underscores or asteriks, but we want to italicize/bold the inner part
|
|
94135
94138
|
// Pattern for intraword _word_ in words like hello_world_
|
|
94136
94139
|
const intrawordUnderscoreItalicRegex = /(\w)_(?!_)([a-zA-Z0-9]+)_(?![\w_])/g;
|
|
@@ -95854,6 +95857,9 @@ const restoreBooleanProperties = () => tree => {
|
|
|
95854
95857
|
|
|
95855
95858
|
const STANDALONE_HTML_LINE_REGEX = /^(<[a-z][^<>]*>|<\/[a-z][^<>]*>)+\s*$/;
|
|
95856
95859
|
const HTML_LINE_WITH_CONTENT_REGEX = /^<[a-z][^<>]*>.*<\/[a-z][^<>]*>(?:[^<]*)$/;
|
|
95860
|
+
function isLineHtml(line) {
|
|
95861
|
+
return STANDALONE_HTML_LINE_REGEX.test(line) || HTML_LINE_WITH_CONTENT_REGEX.test(line);
|
|
95862
|
+
}
|
|
95857
95863
|
/**
|
|
95858
95864
|
* Preprocessor to terminate HTML flow blocks.
|
|
95859
95865
|
*
|
|
@@ -95865,14 +95871,14 @@ const HTML_LINE_WITH_CONTENT_REGEX = /^<[a-z][^<>]*>.*<\/[a-z][^<>]*>(?:[^<]*)$/
|
|
|
95865
95871
|
* @link https://spec.commonmark.org/0.29/#html-blocks
|
|
95866
95872
|
*
|
|
95867
95873
|
* This preprocessor inserts a blank line after standalone HTML lines when the
|
|
95868
|
-
* next line is non-blank
|
|
95869
|
-
* and subsequent content is parsed independently.
|
|
95874
|
+
* next line is non-blank and not an HTML construct (because they still might be part of the HTML flow),
|
|
95875
|
+
* ensuring micromark's HTML flow tokenizer terminates and subsequent content is parsed independently.
|
|
95870
95876
|
*
|
|
95871
|
-
*
|
|
95877
|
+
* Conditions:
|
|
95878
|
+
* 1. Only targets non-indented lines with lowercase tag names. Uppercase tags
|
|
95872
95879
|
* (e.g., `<Table>`, `<MyComponent>`) are JSX custom components and don't
|
|
95873
95880
|
* trigger CommonMark HTML blocks, so they are left untouched.
|
|
95874
|
-
*
|
|
95875
|
-
* Lines inside fenced code blocks are skipped entirely.
|
|
95881
|
+
* 2. Lines inside protected blocks (e.g., code blocks) should be left untouched.
|
|
95876
95882
|
*/
|
|
95877
95883
|
function terminateHtmlFlowBlocks(content) {
|
|
95878
95884
|
const { protectedContent, protectedCode } = protectCodeBlocks(content);
|
|
@@ -95880,9 +95886,14 @@ function terminateHtmlFlowBlocks(content) {
|
|
|
95880
95886
|
const result = [];
|
|
95881
95887
|
for (let i = 0; i < lines.length; i += 1) {
|
|
95882
95888
|
result.push(lines[i]);
|
|
95883
|
-
|
|
95884
|
-
|
|
95885
|
-
|
|
95889
|
+
// Skip blank & indented lines
|
|
95890
|
+
if (i >= lines.length - 1 || lines[i + 1].trim().length === 0 || lines[i + 1].startsWith(' ') || lines[i + 1].startsWith('\t')) {
|
|
95891
|
+
// eslint-disable-next-line no-continue
|
|
95892
|
+
continue;
|
|
95893
|
+
}
|
|
95894
|
+
const isCurrentLineHtml = isLineHtml(lines[i]);
|
|
95895
|
+
const isNextLineHtml = isLineHtml(lines[i + 1]);
|
|
95896
|
+
if (isCurrentLineHtml && !isNextLineHtml) {
|
|
95886
95897
|
result.push('');
|
|
95887
95898
|
}
|
|
95888
95899
|
}
|
|
@@ -97866,7 +97877,8 @@ async function stripComments(doc, { mdx, mdxish } = {}) {
|
|
|
97866
97877
|
if (mdxish) {
|
|
97867
97878
|
processor
|
|
97868
97879
|
.data('micromarkExtensions', [mdxExpression({ allowEmpty: true })])
|
|
97869
|
-
.data('fromMarkdownExtensions', [mdxExpressionFromMarkdown()])
|
|
97880
|
+
.data('fromMarkdownExtensions', [mdxExpressionFromMarkdown()])
|
|
97881
|
+
.data('toMarkdownExtensions', [mdxExpressionToMarkdown()]);
|
|
97870
97882
|
}
|
|
97871
97883
|
processor
|
|
97872
97884
|
.use(remarkParse)
|
|
@@ -97891,9 +97903,7 @@ async function stripComments(doc, { mdx, mdxish } = {}) {
|
|
|
97891
97903
|
// Our markdown renderer uses this to group these code blocks into a tabbed interface.
|
|
97892
97904
|
(left, right) => {
|
|
97893
97905
|
if (left.type === 'code' && right.type === 'code') {
|
|
97894
|
-
const isTight = left.position &&
|
|
97895
|
-
right.position &&
|
|
97896
|
-
right.position.start.line - left.position.end.line === 1; // Are the blocks on adjacent lines?
|
|
97906
|
+
const isTight = left.position && right.position && right.position.start.line - left.position.end.line === 1; // Are the blocks on adjacent lines?
|
|
97897
97907
|
// 0 = no newline between blocks
|
|
97898
97908
|
return isTight ? 0 : undefined;
|
|
97899
97909
|
}
|
package/dist/main.node.js
CHANGED
|
@@ -114235,9 +114235,12 @@ const evaluateExpressions = ({ context = {} } = {}) => tree => {
|
|
|
114235
114235
|
}
|
|
114236
114236
|
catch (_error) {
|
|
114237
114237
|
// If evaluation fails, leave the expression as-is (fallback to text)
|
|
114238
|
+
// we still need to manually escape escaped characters because the expression
|
|
114239
|
+
// parser treats the contents as code instead of text, skipping the backslash escapes
|
|
114240
|
+
const processed = expression.replace(/\\([!-/:-@[-`{-~])/g, '$1');
|
|
114238
114241
|
parent.children.splice(index, 1, {
|
|
114239
114242
|
type: 'text',
|
|
114240
|
-
value: `{${
|
|
114243
|
+
value: `{${processed}}`,
|
|
114241
114244
|
position: node.position,
|
|
114242
114245
|
});
|
|
114243
114246
|
}
|
|
@@ -114330,11 +114333,11 @@ const MARKER_PATTERNS = [
|
|
|
114330
114333
|
// trailingSpace1 is for "** text **" pattern, trailingSpace2 is for "**text **" pattern
|
|
114331
114334
|
const asteriskBoldRegex = /([^*\s]+)?\s*(\*\*)(?:\s+((?:[^*\n]|\*(?!\*))+?)(\s*)\2|((?:[^*\n]|\*(?!\*))+?)(\s+)\2)(\S|$)?/g;
|
|
114332
114335
|
// Pattern for __ bold __
|
|
114333
|
-
const underscoreBoldRegex = /([^_\s]+)?\s*(__)(?:\s+((?:[^_\n]
|
|
114336
|
+
const underscoreBoldRegex = /([^_\s]+)?\s*(__)(?:\s+((?:__(?! )|_(?!_)|[^_\n])+?)(\s*)\2|((?:__(?! )|_(?!_)|[^_\n])+?)(\s+)\2)(\S|$)?/g;
|
|
114334
114337
|
// Pattern for * italic *
|
|
114335
114338
|
const asteriskItalicRegex = /([^*\s]+)?\s*(\*)(?!\*)(?:\s+([^*\n]+?)(\s*)\2|([^*\n]+?)(\s+)\2)(\S|$)?/g;
|
|
114336
114339
|
// Pattern for _ italic _
|
|
114337
|
-
const underscoreItalicRegex = /([^_\s]+)?\s*(_)(?!_)(?:\s+([^_\n]+?)(\s*)\2|([^_\n]+?)(\s+)\2)(\S|$)?/g;
|
|
114340
|
+
const underscoreItalicRegex = /([^_\s]+)?\s*(_)(?!_)(?:\s+((?:[^_\n]|_(?! ))+?)(\s*)\2|((?:[^_\n]|_(?! ))+?)(\s+)\2)(\S|$)?/g;
|
|
114338
114341
|
// CommonMark ignores intraword underscores or asteriks, but we want to italicize/bold the inner part
|
|
114339
114342
|
// Pattern for intraword _word_ in words like hello_world_
|
|
114340
114343
|
const intrawordUnderscoreItalicRegex = /(\w)_(?!_)([a-zA-Z0-9]+)_(?![\w_])/g;
|
|
@@ -116058,6 +116061,9 @@ const restoreBooleanProperties = () => tree => {
|
|
|
116058
116061
|
|
|
116059
116062
|
const STANDALONE_HTML_LINE_REGEX = /^(<[a-z][^<>]*>|<\/[a-z][^<>]*>)+\s*$/;
|
|
116060
116063
|
const HTML_LINE_WITH_CONTENT_REGEX = /^<[a-z][^<>]*>.*<\/[a-z][^<>]*>(?:[^<]*)$/;
|
|
116064
|
+
function isLineHtml(line) {
|
|
116065
|
+
return STANDALONE_HTML_LINE_REGEX.test(line) || HTML_LINE_WITH_CONTENT_REGEX.test(line);
|
|
116066
|
+
}
|
|
116061
116067
|
/**
|
|
116062
116068
|
* Preprocessor to terminate HTML flow blocks.
|
|
116063
116069
|
*
|
|
@@ -116069,14 +116075,14 @@ const HTML_LINE_WITH_CONTENT_REGEX = /^<[a-z][^<>]*>.*<\/[a-z][^<>]*>(?:[^<]*)$/
|
|
|
116069
116075
|
* @link https://spec.commonmark.org/0.29/#html-blocks
|
|
116070
116076
|
*
|
|
116071
116077
|
* This preprocessor inserts a blank line after standalone HTML lines when the
|
|
116072
|
-
* next line is non-blank
|
|
116073
|
-
* and subsequent content is parsed independently.
|
|
116078
|
+
* next line is non-blank and not an HTML construct (because they still might be part of the HTML flow),
|
|
116079
|
+
* ensuring micromark's HTML flow tokenizer terminates and subsequent content is parsed independently.
|
|
116074
116080
|
*
|
|
116075
|
-
*
|
|
116081
|
+
* Conditions:
|
|
116082
|
+
* 1. Only targets non-indented lines with lowercase tag names. Uppercase tags
|
|
116076
116083
|
* (e.g., `<Table>`, `<MyComponent>`) are JSX custom components and don't
|
|
116077
116084
|
* trigger CommonMark HTML blocks, so they are left untouched.
|
|
116078
|
-
*
|
|
116079
|
-
* Lines inside fenced code blocks are skipped entirely.
|
|
116085
|
+
* 2. Lines inside protected blocks (e.g., code blocks) should be left untouched.
|
|
116080
116086
|
*/
|
|
116081
116087
|
function terminateHtmlFlowBlocks(content) {
|
|
116082
116088
|
const { protectedContent, protectedCode } = protectCodeBlocks(content);
|
|
@@ -116084,9 +116090,14 @@ function terminateHtmlFlowBlocks(content) {
|
|
|
116084
116090
|
const result = [];
|
|
116085
116091
|
for (let i = 0; i < lines.length; i += 1) {
|
|
116086
116092
|
result.push(lines[i]);
|
|
116087
|
-
|
|
116088
|
-
|
|
116089
|
-
|
|
116093
|
+
// Skip blank & indented lines
|
|
116094
|
+
if (i >= lines.length - 1 || lines[i + 1].trim().length === 0 || lines[i + 1].startsWith(' ') || lines[i + 1].startsWith('\t')) {
|
|
116095
|
+
// eslint-disable-next-line no-continue
|
|
116096
|
+
continue;
|
|
116097
|
+
}
|
|
116098
|
+
const isCurrentLineHtml = isLineHtml(lines[i]);
|
|
116099
|
+
const isNextLineHtml = isLineHtml(lines[i + 1]);
|
|
116100
|
+
if (isCurrentLineHtml && !isNextLineHtml) {
|
|
116090
116101
|
result.push('');
|
|
116091
116102
|
}
|
|
116092
116103
|
}
|
|
@@ -118070,7 +118081,8 @@ async function stripComments(doc, { mdx, mdxish } = {}) {
|
|
|
118070
118081
|
if (mdxish) {
|
|
118071
118082
|
processor
|
|
118072
118083
|
.data('micromarkExtensions', [mdxExpression({ allowEmpty: true })])
|
|
118073
|
-
.data('fromMarkdownExtensions', [mdxExpressionFromMarkdown()])
|
|
118084
|
+
.data('fromMarkdownExtensions', [mdxExpressionFromMarkdown()])
|
|
118085
|
+
.data('toMarkdownExtensions', [mdxExpressionToMarkdown()]);
|
|
118074
118086
|
}
|
|
118075
118087
|
processor
|
|
118076
118088
|
.use(remarkParse)
|
|
@@ -118095,9 +118107,7 @@ async function stripComments(doc, { mdx, mdxish } = {}) {
|
|
|
118095
118107
|
// Our markdown renderer uses this to group these code blocks into a tabbed interface.
|
|
118096
118108
|
(left, right) => {
|
|
118097
118109
|
if (left.type === 'code' && right.type === 'code') {
|
|
118098
|
-
const isTight = left.position &&
|
|
118099
|
-
right.position &&
|
|
118100
|
-
right.position.start.line - left.position.end.line === 1; // Are the blocks on adjacent lines?
|
|
118110
|
+
const isTight = left.position && right.position && right.position.start.line - left.position.end.line === 1; // Are the blocks on adjacent lines?
|
|
118101
118111
|
// 0 = no newline between blocks
|
|
118102
118112
|
return isTight ? 0 : undefined;
|
|
118103
118113
|
}
|