@readme/markdown 15.2.0 → 15.3.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.node.js CHANGED
@@ -19045,7 +19045,7 @@ module.exports = function () {
19045
19045
 
19046
19046
  /***/ },
19047
19047
 
19048
- /***/ 4359
19048
+ /***/ 5814
19049
19049
  (module, __webpack_exports__, __webpack_require__) {
19050
19050
 
19051
19051
  "use strict";
@@ -95982,6 +95982,7 @@ var allCSS2RNProps = __webpack_unused_export__ = flatten([allProps, CSS2RNProps]
95982
95982
 
95983
95983
 
95984
95984
 
95985
+
95985
95986
  /**
95986
95987
  * Extract word boundaries from camelCase strings (e.g., "borderWidth" -> ["border", "width"])
95987
95988
  */
@@ -96061,10 +96062,43 @@ const CUSTOM_PROP_BOUNDARIES = [
96061
96062
  */
96062
96063
  const RUNTIME_COMPONENT_TAGS = new Set(['Variable', 'variable', 'html-block', 'rdme-pin']);
96063
96064
  /**
96064
- * Standard HTML tags that should never be treated as custom components.
96065
- * Uses the html-tags package, converted to a Set<string> for efficient lookups.
96065
+ * Elements that are not actually standard HTML tags, or those that we intentionally
96066
+ * don't want to treat as one & is mute to check with. These include:
96067
+ * - SVG/MathML descendants
96068
+ * - Namespaced foreign content
96069
+ * - `image`, which the HTML tree builder rewrites to `img`
96070
+ * Most of these are bundled in parse5's `TAG_NAMES` set, but we can also add a few more.
96071
+ */
96072
+ const NON_STANDARD_TAGS = new Set([
96073
+ 'annotation-xml',
96074
+ 'desc',
96075
+ 'foreignObject',
96076
+ 'image',
96077
+ 'malignmark',
96078
+ 'mglyph',
96079
+ 'mi',
96080
+ 'mn',
96081
+ 'mo',
96082
+ 'ms',
96083
+ 'mtext',
96084
+ ]);
96085
+ /**
96086
+ * Standard HTML tags list.
96087
+ * A use case of this is to differentiate custom components tag vs standard HTML tags.
96088
+ *
96089
+ * Unioned from:
96090
+ * - `html-tags`: All modern spec HTML elements
96091
+ * - parse5's `TAG_NAMES`: Elements the HTML tree-construction algorithm has to special-case
96092
+ * This includes obsolete tags that are still rendered by browsers.
96093
+ * - NON_STANDARD_TAGS: We've had to filter because currently parse5's `TAG_NAMES` set over-enumerates
96094
+ * tags that are not actually standard HTML tags. It also allows custom tags to be filtered out.
96066
96095
  */
96067
- const STANDARD_HTML_TAGS = new Set(html_tags_namespaceObject);
96096
+ const STANDARD_HTML_TAGS = new Set([
96097
+ ...html_tags_namespaceObject,
96098
+ ...Object.values(TAG_NAMES),
96099
+ 'acronym', // Obselete tag not included either of the above sources. Add here if we have missed any.
96100
+ 'blink',
96101
+ ].filter(tag => !NON_STANDARD_TAGS.has(tag)));
96068
96102
  /**
96069
96103
  * Table structural tags. Blank lines inside these carry deliberate meaning for
96070
96104
  * `mdxishTables` (e.g. splitting cell content into paragraphs, or deciding
@@ -121641,27 +121675,6 @@ const mdastV6 = (doc, { rdmd }) => {
121641
121675
  };
121642
121676
  /* harmony default export */ const lib_mdastV6 = (mdastV6);
121643
121677
 
121644
- ;// ./processor/compile/anchor.ts
121645
-
121646
-
121647
- const anchor_anchor = (node) => {
121648
- const { href, label, target, title } = getHProps(node);
121649
- const attrs = {
121650
- ...(label && { label }),
121651
- ...(target && { target }),
121652
- href: href ?? '',
121653
- ...(title && { title }),
121654
- };
121655
- // Serialize children (phrasing content) back to markdown
121656
- // Wrap in paragraph to satisfy RootContent type requirement
121657
- const children = toMarkdown({
121658
- type: 'paragraph',
121659
- children: node.children,
121660
- }).trim();
121661
- return `<Anchor ${formatProps(attrs)}>${children}</Anchor>`;
121662
- };
121663
- /* harmony default export */ const compile_anchor = (anchor_anchor);
121664
-
121665
121678
  ;// ./processor/compile/callout.ts
121666
121679
 
121667
121680
  const callout = (node, _, state, info) => {
@@ -121819,7 +121832,6 @@ const compile_text_text = (node, parent, state, info) => {
121819
121832
 
121820
121833
 
121821
121834
 
121822
-
121823
121835
  function compilers(mdxish = false) {
121824
121836
  const data = this.data();
121825
121837
  const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
@@ -121839,7 +121851,6 @@ function compilers(mdxish = false) {
121839
121851
  plain: compile_plain,
121840
121852
  yaml: compile_compatibility,
121841
121853
  // needed only for mdxish
121842
- ...(mdxish && { [NodeTypes.anchor]: compile_anchor }),
121843
121854
  ...(mdxish && { list: compile_list }),
121844
121855
  ...(mdxish && { listItem: list_item }),
121845
121856
  ...(mdxish && { text: compile_text }),
@@ -123724,6 +123735,39 @@ const mdxComponentHandlers = {
123724
123735
  [NodeTypes.htmlBlock]: htmlBlockHandler,
123725
123736
  };
123726
123737
 
123738
+ ;// ./processor/transform/mdxish/anchor-to-jsx.ts
123739
+
123740
+
123741
+
123742
+ /**
123743
+ * Serializes mdxish anchors to JSX `<Anchor>` syntax. Handing the node to
123744
+ * `mdast-util-mdx-jsx` runs the label through the document's own serializer
123745
+ * state, so readme nodes (variables, emoji, glossary) reach their handlers.
123746
+ */
123747
+ const mdxishAnchorToJsx = () => tree => {
123748
+ visit(tree, NodeTypes.anchor, (node, index, parent) => {
123749
+ if (!parent || index === undefined)
123750
+ return;
123751
+ const { href, label, target, title } = getHProps(node);
123752
+ const jsx = {
123753
+ type: 'mdxJsxTextElement',
123754
+ name: 'Anchor',
123755
+ // An anchor always renders an `href`, even an empty one, so it's built
123756
+ // directly rather than through `toAttributes`, which drops empty values.
123757
+ attributes: [
123758
+ ...toAttributes({ label, target }),
123759
+ { type: 'mdxJsxAttribute', name: 'href', value: href ?? '' },
123760
+ ...toAttributes({ title }),
123761
+ ],
123762
+ children: node.children,
123763
+ position: node.position,
123764
+ };
123765
+ parent.children[index] = jsx;
123766
+ });
123767
+ return tree;
123768
+ };
123769
+ /* harmony default export */ const anchor_to_jsx = (mdxishAnchorToJsx);
123770
+
123727
123771
  ;// ./processor/transform/mdxish/callout-to-jsx.ts
123728
123772
 
123729
123773
 
@@ -125524,8 +125568,11 @@ var variable_dist_default = /*#__PURE__*/__webpack_require__.n(variable_dist);
125524
125568
  const HTML_TAG_RE = /<\/?([a-zA-Z][a-zA-Z0-9-]*)((?:[^>"']*(?:"[^"]*"|'[^']*'))*[^>"']*)>/g;
125525
125569
  /** Matches an HTML element from its opening tag to the matching closing tag. */
125526
125570
  const HTML_ELEMENT_BLOCK_RE = /<([a-zA-Z][a-zA-Z0-9-]*)[\s>][\s\S]*?<\/\1>/g;
125571
+ const NEWLINE_RE = /\n/g;
125527
125572
  /** Matches a newline with surrounding horizontal whitespace. */
125528
125573
  const NEWLINE_WITH_WHITESPACE_RE = /[^\S\n]*\n[^\S\n]*/g;
125574
+ /** Matches a run of two or more newlines (a blank line) with surrounding horizontal whitespace. */
125575
+ const BLANK_LINE_RE = /[^\S\n]*\n(?:[^\S\n]*\n)+[^\S\n]*/g;
125529
125576
  /** Matches a closing block-level tag followed by non-tag text or by a newline then non-blank content. */
125530
125577
  const CLOSE_BLOCK_TAG_BOUNDARY_RE = /<\/([a-zA-Z][a-zA-Z0-9-]*)>\s*(?:(?!<)(\S)|\n([^\n]))/g;
125531
125578
  /** Strips HTML open/close tags. Used to detect non-tag inner text content. */
@@ -125595,7 +125642,6 @@ const EMPTY_CODE_PLACEHOLDER = {
125595
125642
 
125596
125643
 
125597
125644
 
125598
-
125599
125645
  /**
125600
125646
  * Wraps a node in a "pinned" container if sidebar: true is set.
125601
125647
  */
@@ -125630,16 +125676,13 @@ const textToBlock = (text) => [{ children: textToInline(text), type: 'paragraph'
125630
125676
  */
125631
125677
  const ensureLeadingBreaks = (text) => text.replace(/^\n+/, match => '<br>'.repeat(match.length));
125632
125678
  /** Preprocesses magic block body content before parsing. */
125633
- const preprocessBody = (text) => {
125634
- return ensureLeadingBreaks(text);
125635
- };
125679
+ const preprocessBody = (text, hardBreaks) => (hardBreaks ? ensureLeadingBreaks(text) : text);
125636
125680
  const bodyExtensions = mdxishExtensions(FEATURES.magicBlockBody);
125637
125681
  /** Markdown parser */
125638
125682
  const contentParser = unified()
125639
125683
  .data('micromarkExtensions', bodyExtensions.micromarkExtensions)
125640
125684
  .data('fromMarkdownExtensions', bodyExtensions.fromMarkdownExtensions)
125641
125685
  .use(remarkParse)
125642
- .use(hard_breaks)
125643
125686
  .use(remarkGfm)
125644
125687
  .use(normalize_malformed_md_syntax);
125645
125688
  /**
@@ -125736,17 +125779,21 @@ const processMarkdownInHtmlString = (html) => {
125736
125779
  /**
125737
125780
  * Separate a closing block-level tag from the content that follows it.
125738
125781
  *
125739
- * Each \n in the original text becomes a <br> tag to preserve spacing, then a
125740
- * blank line (\n\n) is appended so CommonMark ends the HTML block and parses
125741
- * the following content as markdown.
125782
+ * A blank line (\n\n) is appended so CommonMark ends the HTML block and parses the
125783
+ * following content as markdown; with hard breaks each \n also becomes a <br> to keep its spacing.
125742
125784
  */
125743
- const separateBlockTagFromContent = (match, tag, inlineChar, nextLineChar) => {
125785
+ const separateBlockTagFromContent = (hardBreaks, match, tag, inlineChar, nextLineChar) => {
125744
125786
  if (!BLOCK_LEVEL_TAGS.has(tag.toLowerCase()))
125745
125787
  return match;
125746
- const newlineCount = (match.match(/\n/g) ?? []).length;
125788
+ const newlineCount = hardBreaks ? (match.match(NEWLINE_RE) ?? []).length : 0;
125747
125789
  const breaks = '<br>'.repeat(newlineCount);
125748
125790
  return `</${tag}>${breaks}\n\n${inlineChar || nextLineChar}`;
125749
125791
  };
125792
+ /**
125793
+ * Newlines inside an HTML block become <br> so CommonMark doesn't end the block on a blank
125794
+ * line. Without hard breaks only blank lines break, but they still have to be replaced.
125795
+ */
125796
+ const collapseHtmlBlockNewlines = (html, hardBreaks) => html.replace(hardBreaks ? NEWLINE_WITH_WHITESPACE_RE : BLANK_LINE_RE, '<br>');
125750
125797
  /** Escape a leading (possibly indented) `-`/`*`/`+` so cells don't become bullet lists. */
125751
125798
  const escapeLeadingListMarkers = (text) => text.replace(/^([ \t]*)([-*+])(?=[ \t]|$)/gm, '$1\\$2');
125752
125799
  /**
@@ -125754,15 +125801,13 @@ const escapeLeadingListMarkers = (text) => text.replace(/^([ \t]*)([-*+])(?=[ \t
125754
125801
  * so `<ul><li>_text_</li></ul>` won't convert underscores to emphasis.
125755
125802
  * We parse first, then visit html nodes and process their text content.
125756
125803
  */
125757
- const parseTableCell = (text) => {
125804
+ const parseTableCell = (text, hardBreaks) => {
125758
125805
  if (!text.trim())
125759
125806
  return [{ type: 'text', value: '' }];
125760
- // Convert \n (and surrounding whitespace) to <br> inside HTML blocks so
125761
- // CommonMark doesn't split them on blank lines.
125762
125807
  const escaped = processBackslashEscapes(text);
125763
125808
  const normalized = escaped
125764
- .replace(HTML_ELEMENT_BLOCK_RE, match => match.replace(NEWLINE_WITH_WHITESPACE_RE, '<br>'))
125765
- .replace(CLOSE_BLOCK_TAG_BOUNDARY_RE, separateBlockTagFromContent);
125809
+ .replace(HTML_ELEMENT_BLOCK_RE, match => collapseHtmlBlockNewlines(match, hardBreaks))
125810
+ .replace(CLOSE_BLOCK_TAG_BOUNDARY_RE, (match, tag, inlineChar, nextLineChar) => separateBlockTagFromContent(hardBreaks, match, tag, inlineChar, nextLineChar));
125766
125811
  const processed = escapeLeadingListMarkers(normalized);
125767
125812
  const tree = contentParser.runSync(contentParser.parse(processed));
125768
125813
  // Process markdown inside HTML blocks that have non-tag inner text (e.g. `<div>**x**`
@@ -125811,7 +125856,7 @@ const parseApiHeaderTitle = (text) => {
125811
125856
  * Transform a magicBlock node into final MDAST nodes.
125812
125857
  */
125813
125858
  function transformMagicBlock(blockType, data, rawValue, options = {}) {
125814
- const { compatibilityMode = false, safeMode = false } = options;
125859
+ const { compatibilityMode = false, hardBreaks = true, safeMode = false } = options;
125815
125860
  // Handle empty data by returning placeholder nodes for known block types
125816
125861
  // This allows the editor to show appropriate placeholder UI instead of nothing
125817
125862
  if (Object.keys(data).length < 1) {
@@ -125950,7 +125995,7 @@ function transformMagicBlock(blockType, data, rawValue, options = {}) {
125950
125995
  });
125951
125996
  }
125952
125997
  if (hasBody) {
125953
- const bodyBlocks = parseBlock(preprocessBody(calloutJson.body || ''));
125998
+ const bodyBlocks = parseBlock(preprocessBody(calloutJson.body || '', hardBreaks));
125954
125999
  children.push(...bodyBlocks);
125955
126000
  }
125956
126001
  const calloutElement = {
@@ -125982,12 +126027,12 @@ function transformMagicBlock(blockType, data, rawValue, options = {}) {
125982
126027
  mapped[rowIndex][colIndex] = v;
125983
126028
  return mapped;
125984
126029
  }, []);
125985
- const tokenizeCell = compatibilityMode
125986
- ? textToBlock
125987
- : parseTableCell;
126030
+ const tokenizeCell = compatibilityMode ? textToBlock : (text) => parseTableCell(text, hardBreaks);
125988
126031
  const tableChildren = Array.from({ length: rows + 1 }, (_, y) => ({
125989
126032
  children: Array.from({ length: cols }, (__, x) => ({
125990
- children: sparseData[y]?.[x] ? tokenizeCell(preprocessBody(sparseData[y][x])) : [{ type: 'text', value: '' }],
126033
+ children: sparseData[y]?.[x]
126034
+ ? tokenizeCell(preprocessBody(sparseData[y][x], hardBreaks))
126035
+ : [{ type: 'text', value: '' }],
125991
126036
  type: y === 0 ? 'tableHead' : 'tableCell',
125992
126037
  })),
125993
126038
  type: 'tableRow',
@@ -127824,6 +127869,7 @@ function loadComponents() {
127824
127869
 
127825
127870
 
127826
127871
 
127872
+
127827
127873
 
127828
127874
 
127829
127875
  const defaultTransformers = [
@@ -127862,7 +127908,7 @@ function preprocessContent(content, opts) {
127862
127908
  return processSnakeCaseComponent(result, { knownComponents });
127863
127909
  }
127864
127910
  function mdxishAstProcessor(mdContent, opts = {}) {
127865
- const { components: userComponents = {}, newEditorTypes = false, safeMode = false, useTailwind } = opts;
127911
+ const { components: userComponents = {}, hardBreaks: enableHardBreaks = true, newEditorTypes = false, safeMode = false, useTailwind, } = opts;
127866
127912
  const components = {
127867
127913
  ...loadComponents(),
127868
127914
  ...userComponents,
@@ -127891,7 +127937,7 @@ function mdxishAstProcessor(mdContent, opts = {}) {
127891
127937
  // The next few transformers must appear after mdxishMdxComponentBlocks
127892
127938
  // so nodes produced by the inline re-parse of component bodies
127893
127939
  // (e.g. code/image/embed inside <Tabs>) get visited too
127894
- .use(magic_block_transformer)
127940
+ .use(magic_block_transformer, { hardBreaks: enableHardBreaks })
127895
127941
  .use(transform_images, { isMdxish: true })
127896
127942
  .use(defaultTransformers)
127897
127943
  .use(newEditorTypes ? inline_mdx_blocks : undefined) // Merge inline html components (e.g. <Anchor>) into MDAST nodes
@@ -127926,6 +127972,7 @@ function mdxishMdastToMd(mdast) {
127926
127972
  .use(remarkGfm)
127927
127973
  .use(callout_to_jsx)
127928
127974
  .use(mdxish_tables_to_jsx)
127975
+ .use(anchor_to_jsx)
127929
127976
  .use(mdxishCompilers)
127930
127977
  .use(mdxJsxStringify)
127931
127978
  .use(remarkStringify, {
@@ -127947,7 +127994,7 @@ function mdxishMdastToMd(mdast) {
127947
127994
  * @see .claude/context/MDXish/Processor Overview.md
127948
127995
  */
127949
127996
  function mdxish(mdContent, opts = {}) {
127950
- const { components: userComponents = {}, safeMode = false, variables } = opts;
127997
+ const { components: userComponents = {}, hardBreaks: enableHardBreaks = true, safeMode = false, variables } = opts;
127951
127998
  const components = {
127952
127999
  ...loadComponents(),
127953
128000
  ...userComponents,
@@ -127959,7 +128006,7 @@ function mdxish(mdContent, opts = {}) {
127959
128006
  const { processor, parserReadyContent } = mdxishAstProcessor(contentWithoutComments, opts);
127960
128007
  processor
127961
128008
  .use(safeMode ? undefined : evaluate_exports) // Evaluate `export const/function` and stash scope on file.data.mdxishScope
127962
- .use(hard_breaks) // Must precede evaluateExpressions to avoid splitting the \n in an evaluated template literal into a <br> node
128009
+ .use(enableHardBreaks ? hard_breaks : undefined) // Must precede evaluateExpressions to avoid splitting the \n in an evaluated template literal into a <br> node
127963
128010
  .use(safeMode ? undefined : evaluate_expressions) // Evaluate self-contained MDX expressions (e.g. `{1+1}`)
127964
128011
  .use(safeMode ? undefined : evaluate_style_block_expressions) // Evaluate `<style>{`...`}</style>` template literals into plain CSS
127965
128012
  .use(variables_code, { variables }) // Resolve <<...>> and {user.*} inside code and inline code nodes
@@ -129006,7 +129053,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"*":["about","acceptCharset","accessK
129006
129053
  /******/ // startup
129007
129054
  /******/ // Load entry module and return exports
129008
129055
  /******/ // This entry module used 'module' so it can't be inlined
129009
- /******/ let __webpack_exports__ = __webpack_require__(4359);
129056
+ /******/ let __webpack_exports__ = __webpack_require__(5814);
129010
129057
  /******/ module.exports = __webpack_exports__;
129011
129058
  /******/
129012
129059
  /******/ })()