@readme/markdown 14.1.3 → 14.1.4

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
@@ -92101,7 +92101,7 @@ const hasFlowContent = (nodes) => {
92101
92101
  * a markdown table (phrasing-only) or keep as JSX <Table> (has flow content).
92102
92102
  */
92103
92103
  const processTableNode = (node, index, parent, documentPosition) => {
92104
- if (node.name !== 'Table')
92104
+ if (node.name !== 'Table' && node.name !== 'table')
92105
92105
  return;
92106
92106
  const position = documentPosition ?? node.position;
92107
92107
  const { align: alignAttr } = getAttrs(node);
@@ -92215,7 +92215,7 @@ const mdxishTables = () => tree => {
92215
92215
  const node = _node;
92216
92216
  if (typeof index !== 'number' || !parent || !('children' in parent))
92217
92217
  return;
92218
- if (!node.value.startsWith('<Table'))
92218
+ if (!node.value.startsWith('<Table') && !node.value.startsWith('<table'))
92219
92219
  return;
92220
92220
  try {
92221
92221
  const parsed = tableNodeProcessor.runSync(tableNodeProcessor.parse(node.value));
@@ -92237,13 +92237,10 @@ const mdxishTables = () => tree => {
92237
92237
  }
92238
92238
  });
92239
92239
  visit(parsed, isMDXElement, (tableNode) => {
92240
- if (tableNode.name === 'Table') {
92241
- processTableNode(tableNode, index, parent, node.position);
92242
- // Stop after the outermost Table so nested Tables don't overwrite parent.children[index]
92243
- // we let it get handled naturally
92244
- return EXIT;
92245
- }
92246
- return undefined;
92240
+ if (tableNode.name !== 'Table' && tableNode.name !== 'table')
92241
+ return undefined;
92242
+ processTableNode(tableNode, index, parent, node.position);
92243
+ return EXIT;
92247
92244
  });
92248
92245
  }
92249
92246
  catch {
@@ -119108,8 +119105,8 @@ const HTML_ELEMENT_BLOCK_RE = /<([a-zA-Z][a-zA-Z0-9-]*)[\s>][\s\S]*?<\/\1>/g;
119108
119105
  const NEWLINE_WITH_WHITESPACE_RE = /[^\S\n]*\n[^\S\n]*/g;
119109
119106
  /** Matches a closing block-level tag followed by non-tag text or by a newline then non-blank content. */
119110
119107
  const CLOSE_BLOCK_TAG_BOUNDARY_RE = /<\/([a-zA-Z][a-zA-Z0-9-]*)>\s*(?:(?!<)(\S)|\n([^\n]))/g;
119111
- /** Tests whether a string contains a complete HTML element (open + close tag). */
119112
- const COMPLETE_HTML_ELEMENT_RE = /<[a-zA-Z][^>]*>[\s\S]*<\/[a-zA-Z]/;
119108
+ /** Strips HTML open/close tags. Used to detect non-tag inner text content. */
119109
+ const HTML_TAG_STRIP_RE = /<\/?[a-zA-Z][^>]*>/g;
119113
119110
 
119114
119111
  ;// ./processor/transform/mdxish/magic-blocks/placeholder.ts
119115
119112
  const EMPTY_IMAGE_PLACEHOLDER = {
@@ -119349,10 +119346,12 @@ const parseTableCell = (text) => {
119349
119346
  const trimmedLines = normalized.split('\n').map(line => line.trimStart());
119350
119347
  const processed = trimmedLines.join('\n');
119351
119348
  const tree = contentParser.runSync(contentParser.parse(processed));
119352
- // Process markdown inside complete HTML elements (e.g. _emphasis_ within <li>).
119353
- // Bare tags like "<i>" are left for rehypeRaw since rehype-parse would mangle them.
119349
+ // Process markdown inside HTML blocks that have non-tag inner text (e.g. `<div>**x**`
119350
+ // or `<ul><li>_x_</li></ul>`). Pure bare tags like "<i>" or "<br>" are left for rehypeRaw
119351
+ // since rehype-parse would mangle them (auto-closing void/inline elements).
119354
119352
  visit(tree, 'html', (node) => {
119355
- if (COMPLETE_HTML_ELEMENT_RE.test(node.value)) {
119353
+ const hasInnerText = node.value.replace(HTML_TAG_STRIP_RE, '').trim().length > 0;
119354
+ if (hasInnerText) {
119356
119355
  node.value = processMarkdownInHtmlString(node.value);
119357
119356
  }
119358
119357
  else {
@@ -121741,8 +121740,7 @@ function tokenizeJsxTable(effects, ok, nok) {
121741
121740
  let codeSpanOpenSize = 0;
121742
121741
  let codeSpanCloseSize = 0;
121743
121742
  let depth = 1;
121744
- const TABLE_NAME = [codes.uppercaseT, codes.lowercaseA, codes.lowercaseB, codes.lowercaseL, codes.lowercaseE];
121745
- const ABLE_SUFFIX = TABLE_NAME.slice(1);
121743
+ const ABLE_SUFFIX = [codes.lowercaseA, codes.lowercaseB, codes.lowercaseL, codes.lowercaseE];
121746
121744
  /** Build a state chain that matches a sequence of character codes. */
121747
121745
  function matchChars(chars, onMatch, onFail) {
121748
121746
  if (chars.length === 0)
@@ -121762,7 +121760,14 @@ function tokenizeJsxTable(effects, ok, nok) {
121762
121760
  effects.enter('jsxTable');
121763
121761
  effects.enter('jsxTableData');
121764
121762
  effects.consume(code);
121765
- return matchChars(TABLE_NAME, afterTagName, nok);
121763
+ return afterLessThan;
121764
+ }
121765
+ function afterLessThan(code) {
121766
+ if (code === codes.uppercaseT || code === codes.lowercaseT) {
121767
+ effects.consume(code);
121768
+ return matchChars(ABLE_SUFFIX, afterTagName, nok);
121769
+ }
121770
+ return nok(code);
121766
121771
  }
121767
121772
  function afterTagName(code) {
121768
121773
  if (code === codes.greaterThan || code === codes.slash || code === codes.space || code === codes.horizontalTab) {
@@ -121834,14 +121839,21 @@ function tokenizeJsxTable(effects, ok, nok) {
121834
121839
  function closeSlash(code) {
121835
121840
  if (code === codes.slash) {
121836
121841
  effects.consume(code);
121837
- return matchChars(TABLE_NAME, closeGt, body);
121842
+ return closeTagFirstChar;
121838
121843
  }
121839
- if (code === codes.uppercaseT) {
121844
+ if (code === codes.uppercaseT || code === codes.lowercaseT) {
121840
121845
  effects.consume(code);
121841
121846
  return matchChars(ABLE_SUFFIX, openAfterTagName, body);
121842
121847
  }
121843
121848
  return body(code);
121844
121849
  }
121850
+ function closeTagFirstChar(code) {
121851
+ if (code === codes.uppercaseT || code === codes.lowercaseT) {
121852
+ effects.consume(code);
121853
+ return matchChars(ABLE_SUFFIX, closeGt, body);
121854
+ }
121855
+ return body(code);
121856
+ }
121845
121857
  function openAfterTagName(code) {
121846
121858
  if (code === codes.greaterThan || code === codes.slash || code === codes.space || code === codes.horizontalTab) {
121847
121859
  depth += 1;
@@ -121917,10 +121929,10 @@ function jsx_table_syntax_tokenizeNonLazyContinuationStart(effects, ok, nok) {
121917
121929
  }
121918
121930
  }
121919
121931
  /**
121920
- * Micromark extension that tokenizes `<Table>...</Table>` as a single flow block.
121932
+ * Micromark extension that tokenizes `<Table>...</Table>` and `<table>...</table>`
121933
+ * as a single flow block.
121921
121934
  *
121922
- * Prevents CommonMark HTML block type 6 from matching `<Table>` (case-insensitive
121923
- * match against `table`) and fragmenting it at blank lines.
121935
+ * Prevents CommonMark HTML block type 6 from fragmenting table blocks at blank lines.
121924
121936
  */
121925
121937
  function jsxTable() {
121926
121938
  return {