@readme/markdown 11.8.1 → 11.8.2

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.
@@ -1,4 +1,5 @@
1
1
  export interface BlockHit {
2
+ key: string;
2
3
  raw: string;
3
4
  token: string;
4
5
  }
package/dist/main.js CHANGED
@@ -93905,18 +93905,13 @@ function parseMagicBlock(raw, options = {}) {
93905
93905
  const magicBlockRestorer = ({ blocks }) => tree => {
93906
93906
  if (!blocks.length)
93907
93907
  return;
93908
- // Build lookup map: token string → original raw magic block content
93909
- // Tokens are stored with backticks (`__MAGIC_BLOCK_0__`) but parsed as
93910
- // inlineCode nodes without the backticks, so we normalize here
93911
- const tokenLookup = new Map(blocks.map(({ token, raw }) => {
93912
- const normalizedToken = token.replace(/^`|`$/g, '');
93913
- return [normalizedToken, raw];
93914
- }));
93908
+ // Map: key → original raw magic block content
93909
+ const magicBlockKeys = new Map(blocks.map(({ key, raw }) => [key, raw]));
93915
93910
  // Find inlineCode nodes that match our placeholder tokens
93916
93911
  visit(tree, 'inlineCode', (node, index, parent) => {
93917
93912
  if (!parent || index == null)
93918
93913
  return;
93919
- const raw = tokenLookup.get(node.value);
93914
+ const raw = magicBlockKeys.get(node.value);
93920
93915
  if (!raw)
93921
93916
  return;
93922
93917
  // Parse the original magic block and replace the placeholder with the result
@@ -94012,12 +94007,16 @@ function extractMagicBlocks(markdown) {
94012
94007
  let index = 0;
94013
94008
  const replaced = markdown.replace(MAGIC_BLOCK_REGEX, match => {
94014
94009
  /**
94010
+ * Key is the unique identifier for the magic block
94011
+ * Token is a wrapper around the key to serialize & influences how the block is parsed in the pipeline
94012
+ * with the temporary key
94015
94013
  * - Use backticks so it becomes a code span, preventing remarkParse from parsing
94016
94014
  * special characters in the token as markdown syntax
94017
94015
  * - Prepend a newline to the token to ensure it is parsed as a block level node
94018
94016
  */
94019
- const token = `\n\`__MAGIC_BLOCK_${index}__\``;
94020
- blocks.push({ token, raw: match });
94017
+ const key = `__MAGIC_BLOCK_${index}__`;
94018
+ const token = `\n\`${key}\``;
94019
+ blocks.push({ key, raw: match, token });
94021
94020
  index += 1;
94022
94021
  return token;
94023
94022
  });
package/dist/main.node.js CHANGED
@@ -114109,18 +114109,13 @@ function parseMagicBlock(raw, options = {}) {
114109
114109
  const magicBlockRestorer = ({ blocks }) => tree => {
114110
114110
  if (!blocks.length)
114111
114111
  return;
114112
- // Build lookup map: token string → original raw magic block content
114113
- // Tokens are stored with backticks (`__MAGIC_BLOCK_0__`) but parsed as
114114
- // inlineCode nodes without the backticks, so we normalize here
114115
- const tokenLookup = new Map(blocks.map(({ token, raw }) => {
114116
- const normalizedToken = token.replace(/^`|`$/g, '');
114117
- return [normalizedToken, raw];
114118
- }));
114112
+ // Map: key → original raw magic block content
114113
+ const magicBlockKeys = new Map(blocks.map(({ key, raw }) => [key, raw]));
114119
114114
  // Find inlineCode nodes that match our placeholder tokens
114120
114115
  visit(tree, 'inlineCode', (node, index, parent) => {
114121
114116
  if (!parent || index == null)
114122
114117
  return;
114123
- const raw = tokenLookup.get(node.value);
114118
+ const raw = magicBlockKeys.get(node.value);
114124
114119
  if (!raw)
114125
114120
  return;
114126
114121
  // Parse the original magic block and replace the placeholder with the result
@@ -114216,12 +114211,16 @@ function extractMagicBlocks(markdown) {
114216
114211
  let index = 0;
114217
114212
  const replaced = markdown.replace(MAGIC_BLOCK_REGEX, match => {
114218
114213
  /**
114214
+ * Key is the unique identifier for the magic block
114215
+ * Token is a wrapper around the key to serialize & influences how the block is parsed in the pipeline
114216
+ * with the temporary key
114219
114217
  * - Use backticks so it becomes a code span, preventing remarkParse from parsing
114220
114218
  * special characters in the token as markdown syntax
114221
114219
  * - Prepend a newline to the token to ensure it is parsed as a block level node
114222
114220
  */
114223
- const token = `\n\`__MAGIC_BLOCK_${index}__\``;
114224
- blocks.push({ token, raw: match });
114221
+ const key = `__MAGIC_BLOCK_${index}__`;
114222
+ const token = `\n\`${key}\``;
114223
+ blocks.push({ key, raw: match, token });
114225
114224
  index += 1;
114226
114225
  return token;
114227
114226
  });