@khanacademy/pure-markdown 0.3.26 → 0.4.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/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Copyright 2022 Khan Academy
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to use,
6
+ copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
+ Software, and to permit persons to whom the Software is furnished to do so, subject
8
+ to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
17
+ AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/dist/es/index.js CHANGED
@@ -1,19 +1,51 @@
1
- import { addLibraryVersionToPerseusDebug } from '@khanacademy/perseus-core';
1
+ import _extends from '@babel/runtime/helpers/extends';
2
2
  import SimpleMarkdown from '@khanacademy/simple-markdown';
3
3
 
4
- function _extends() {
5
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
6
- for (var e = 1; e < arguments.length; e++) {
7
- var t = arguments[e];
8
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
4
+ /**
5
+ * Adds the given perseus library version information to the __perseus_debug__
6
+ * object and ensures that the object is attached to `globalThis` (`window` in
7
+ * browser environments).
8
+ *
9
+ * This allows each library to provide runtime version information to assist in
10
+ * debugging in production environments.
11
+ */
12
+ const addLibraryVersionToPerseusDebug = (libraryName, libraryVersion) => {
13
+ // If the library version is the default value, then we don't want to
14
+ // prefix it with a "v" to indicate that it is a version number.
15
+ let prefix = "v";
16
+ if (libraryVersion === "__lib_version__") {
17
+ prefix = "";
18
+ }
19
+ const formattedVersion = `${prefix}${libraryVersion}`;
20
+ if (typeof globalThis !== "undefined") {
21
+ var _globalThis$__perseus;
22
+ globalThis.__perseus_debug__ = (_globalThis$__perseus = globalThis.__perseus_debug__) != null ? _globalThis$__perseus : {};
23
+ const existingVersionEntry = globalThis.__perseus_debug__[libraryName];
24
+ if (existingVersionEntry) {
25
+ // If we already have an entry and it doesn't match the registered
26
+ // version, we morph the entry into an array and log a warning.
27
+ if (existingVersionEntry !== formattedVersion) {
28
+ // Existing entry might be an array already (oops, at least 2
29
+ // versions of the library already loaded!).
30
+ const allVersions = Array.isArray(existingVersionEntry) ? existingVersionEntry : [existingVersionEntry];
31
+ allVersions.push(formattedVersion);
32
+ globalThis.__perseus_debug__[libraryName] = allVersions;
33
+
34
+ // eslint-disable-next-line no-console
35
+ console.warn(`Multiple versions of ${libraryName} loaded on this page: ${allVersions.sort().join(", ")}`);
36
+ }
37
+ } else {
38
+ globalThis.__perseus_debug__[libraryName] = formattedVersion;
9
39
  }
10
- return n;
11
- }, _extends.apply(null, arguments);
12
- }
40
+ } else {
41
+ // eslint-disable-next-line no-console
42
+ console.warn(`globalThis not found found (${formattedVersion})`);
43
+ }
44
+ };
13
45
 
14
46
  // This file is processed by a Rollup plugin (replace) to inject the production
15
47
  const libName = "@khanacademy/pure-markdown";
16
- const libVersion = "0.3.26";
48
+ const libVersion = "0.4.0";
17
49
  addLibraryVersionToPerseusDebug(libName, libVersion);
18
50
 
19
51
  const rWidgetRule = /^\[\[\u2603 (([a-z-]+) ([0-9]+))\]\]/;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../node_modules/@babel/runtime/helpers/esm/extends.js","../../src/version.ts","../../src/index.ts"],"sourcesContent":["function _extends() {\n return _extends = Object.assign ? Object.assign.bind() : function (n) {\n for (var e = 1; e < arguments.length; e++) {\n var t = arguments[e];\n for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);\n }\n return n;\n }, _extends.apply(null, arguments);\n}\nexport { _extends as default };","// This file is processed by a Rollup plugin (replace) to inject the production\n// version number during the release build.\n// In dev, you'll never see the version number.\n\nimport {addLibraryVersionToPerseusDebug} from \"@khanacademy/perseus-core\";\n\nconst libName = \"@khanacademy/pure-markdown\";\nexport const libVersion = \"__lib_version__\";\n\naddLibraryVersionToPerseusDebug(libName, libVersion);\n","/**\n * Contains markdown related functions in pure javascript,\n * extracted from perseus-markdown.jsx\n * Note that this file may be used in stand alone nodejs, thus\n * do not import anything from Perseus\n */\nexport {libVersion} from \"./version\";\n\nimport SimpleMarkdown from \"@khanacademy/simple-markdown\";\n\nconst rWidgetRule = /^\\[\\[\\u2603 (([a-z-]+) ([0-9]+))\\]\\]/;\n\n/**\n * This match function matches math in `$`s, such as:\n *\n * $y = x + 1$\n *\n * It functions roughly like the following regex:\n * /\\$([^\\$]*)\\$/\n *\n * Unfortunately, math may have other `$`s inside it, as\n * long as they are inside `{` braces `}`, mostly for\n * `\\text{ $math$ }`.\n *\n * To parse this, we can't use a regex, since we\n * should support arbitrary nesting (even though\n * MathJax actually only supports two levels of nesting\n * here, which we *could* parse with a regex).\n *\n * Non-regex matchers like this are now a first-class\n * concept in simple-markdown. Yay!\n *\n * This can also match block-math, which is math alone in a paragraph.\n */\nconst mathMatcher = (source: any, state: any, isBlock: boolean) => {\n const length = source.length;\n let index = 0;\n\n // When looking for blocks, skip over leading spaces\n if (isBlock) {\n if (state.inline) {\n return null;\n }\n while (index < length && source[index] === \" \") {\n index++;\n }\n }\n\n // Our source must start with a \"$\"\n if (!(index < length && source[index] === \"$\")) {\n return null;\n }\n\n index++;\n const startIndex = index;\n let braceLevel = 0;\n\n // Loop through the source, looking for a closing '$'\n // closing '$'s only count if they are not escaped with\n // a `\\`, and we are not in nested `{}` braces.\n while (index < length) {\n const character = source[index];\n\n if (character === \"\\\\\") {\n // Consume both the `\\` and the escaped char as a single\n // token.\n // This is so that the second `$` in `$\\\\$` closes\n // the math expression, since the first `\\` is escaping\n // the second `\\`, but the second `\\` is not escaping\n // the second `$`.\n // This also handles the case of escaping `$`s or\n // braces `\\{`\n index++;\n } else if (braceLevel <= 0 && character === \"$\") {\n let endIndex = index + 1;\n if (isBlock) {\n // Look for two trailing newlines after the closing `$`\n const match = /^(?: *\\n){2,}/.exec(source.slice(endIndex));\n // @ts-expect-error - TS2322 - Type 'number | null' is not assignable to type 'number'.\n endIndex = match ? endIndex + match[0].length : null;\n }\n\n // Return an array that looks like the results of a\n // regex's .exec function:\n // capture[0] is the whole string\n // capture[1] is the first \"paren\" match, which is the\n // content of the math here, as if we wrote the regex\n // /\\$([^\\$]*)\\$/\n if (endIndex) {\n return [\n source.substring(0, endIndex),\n source.substring(startIndex, index),\n ];\n }\n return null;\n } else if (character === \"{\") {\n braceLevel++;\n } else if (character === \"}\") {\n braceLevel--;\n } else if (character === \"\\n\" && source[index - 1] === \"\\n\") {\n // This is a weird case we supported in the old\n // math implementation--double newlines break\n // math. I'm preserving it for now because content\n // creators might have questions with single '$'s\n // in paragraphs...\n return null;\n }\n\n index++;\n }\n\n // we didn't find a closing `$`\n return null;\n};\nconst mathMatch = (source: any, state: any): any =>\n mathMatcher(source, state, false);\nconst blockMathMatch = (source: any, state: any): any =>\n mathMatcher(source, state, true);\n\nconst TITLED_TABLE_REGEX = new RegExp(\n \"^\\\\|\\\\| +(.*) +\\\\|\\\\| *\\\\n\" +\n \"(\" +\n // The simple-markdown nptable regex, without\n // the leading `^`\n // @ts-expect-error - TS2532 - Object is possibly 'undefined'.\n SimpleMarkdown.defaultRules.nptable.match.regex.source.substring(1) +\n \")\",\n);\n\nconst crowdinJiptMatcher = SimpleMarkdown.blockRegex(/^(crwdns.*)\\n\\s*\\n/);\n\nexport const pureMarkdownRules = {\n ...SimpleMarkdown.defaultRules,\n\n // NOTE: basically ignored by JIPT. wraps everything at the outer layer\n columns: {\n order: -2,\n match: SimpleMarkdown.blockRegex(\n /^([\\s\\S]*\\n\\n)={5,}\\n\\n([\\s\\S]*)/,\n ) as any,\n parse: (capture: any, parse: any, state: any): any => {\n return {\n col1: parse(capture[1], state),\n col2: parse(capture[2], state),\n };\n },\n },\n crowdinId: {\n order: -1,\n match: (source: any, state: any, prevCapture: any): any => {\n // Only match on the just-in-place translation site\n if (state.isJipt) {\n return crowdinJiptMatcher(source, state, prevCapture);\n }\n return null;\n },\n parse: (capture: any, parse: any, state: any): any => ({\n id: capture[1],\n }),\n },\n // This is pretty much horrible, but we have a regex here to capture an\n // entire table + a title. capture[1] is the title. capture[2] of the\n // regex is a copy of the simple-markdown nptable regex. Then we turn\n // our capture[2] into tableCapture[0], and any further captures in\n // our table regex into tableCapture[1..], and we pass tableCapture to\n // our nptable regex\n titledTable: {\n // process immediately before nptables\n order: SimpleMarkdown.defaultRules.nptable.order - 0.5,\n match: SimpleMarkdown.blockRegex(TITLED_TABLE_REGEX) as any,\n parse: (capture: any, parse: any, state: any): any => {\n const title = SimpleMarkdown.parseInline(parse, capture[1], state);\n\n // Remove our [0] and [1] captures, and pass the rest to\n // the nptable parser\n const tableCapture = capture.slice(2);\n const table = SimpleMarkdown.defaultRules.nptable.parse(\n tableCapture,\n parse,\n state,\n );\n return {\n title: title,\n table: table,\n };\n },\n },\n widget: {\n order: SimpleMarkdown.defaultRules.link.order - 0.75,\n match: SimpleMarkdown.inlineRegex(rWidgetRule) as any,\n parse: (capture: any, parse: any, state: any): any => {\n return {\n id: capture[1],\n widgetType: capture[2],\n };\n },\n },\n blockMath: {\n order: (SimpleMarkdown.defaultRules.codeBlock.order + 0.5) as any,\n match: blockMathMatch,\n parse: (capture: any, parse: any, state: any): any => {\n return {\n content: capture[1],\n };\n },\n },\n math: {\n order: SimpleMarkdown.defaultRules.link.order - 0.25,\n match: mathMatch,\n parse: (capture: any, parse: any, state: any): any => {\n return {\n content: capture[1],\n };\n },\n },\n unescapedDollar: {\n order: SimpleMarkdown.defaultRules.link.order - 0.24,\n match: SimpleMarkdown.inlineRegex(/^(?!\\\\)\\$/) as any,\n parse: (capture: any, parse: any, state: any): any => {\n return {};\n },\n },\n fence: {\n ...SimpleMarkdown.defaultRules.fence,\n parse: (capture: any, parse: any, state: any): any => {\n const node = SimpleMarkdown.defaultRules.fence.parse(\n capture,\n parse,\n state,\n );\n\n // support screenreader-only text with ```alt\n if (node.lang === \"alt\") {\n return {\n type: \"codeBlock\",\n lang: \"alt\",\n // default codeBlock parsing doesn't parse the contents.\n // We need to parse the contents for things like table\n // support :).\n // The \\n\\n is because the inside of the codeblock might\n // not end in double newlines for block rules, because\n // ordinarily we don't parse this :).\n content: parse(node.content + \"\\n\\n\", state),\n };\n }\n return node;\n },\n },\n blockQuote: {\n ...SimpleMarkdown.defaultRules.blockQuote,\n // Replace the less restrictive blockquote regex from SimpleMarkdown\n // with a more restrictive one. The only difference should be that\n //\n // > A blockquote\n //\n // > Another blockquote\n //\n // will now match as two different blockQuotes instead of a single\n // blockquote with some paragraph breaks in it.\n //\n // The main motivation for doing this is to provide better support for\n // translators translating blockquotes with multiple paragraphs in\n // them. When translating articles, we split up paragraphs, translate\n // them separately, and then recombine them. We do this so that\n // translators don't have to translate an entire article at a time,\n // they can instead translate paragraph-by-paragraph.That system\n // doesn't understand blockquotes, so it will split up blockquotes into\n // more than one paragraph. A way to solve this would be to make that\n // system understand blockquotes, but then translators would have to\n // translate an entire, multi-paragraph blockquote at a time. Instead,\n // we choose to modify our blockquote matching to split up\n // multi-paragraph blockquotes into multiple blockquotes.\n //\n // There is also precedence for doing this splitting up in other\n // libraries, for instance CommonMark also splits up blockquotes with\n // empty lines into multiple blockquotes:\n // https://spec.commonmark.org/0.28/#example-205\n match: SimpleMarkdown.blockRegex(\n /^ *>[^\\n]+(\\n( *>)?[^\\n]+)*\\n{2,}/,\n ) as any,\n },\n // The lint rule never actually matches anything.\n // We check for lint after parsing, and, if we find any, we\n // transform the tree to add lint nodes. This rule is here\n // just for the react() function\n lint: {\n order: 1000,\n match: (s: any): any => null,\n parse: (capture: any, parse: any, state: any): any => ({}),\n },\n} as const;\n\n// @ts-expect-error - TS2345 - Argument of type '{ readonly columns: { readonly order: -2; readonly match: any; readonly parse: (capture: any, parse: any, state: any) => any; }; readonly crowdinId: { readonly order: -1; readonly match: (source: any, state: any, prevCapture: any) => any; readonly parse: (capture: any, parse: any, state: any) => any; }; ... 34 more ...' is not assignable to parameter of type 'ParserRules'.\nconst builtParser = SimpleMarkdown.parserFor(pureMarkdownRules);\n\nexport const parse = (source: string, state?: any): any => {\n const paragraphedSource = source + \"\\n\\n\";\n\n return builtParser(paragraphedSource, {\n ...state,\n inline: false,\n });\n};\n"],"names":["libName","libVersion","addLibraryVersionToPerseusDebug","rWidgetRule","mathMatcher","source","state","isBlock","length","index","inline","startIndex","braceLevel","character","endIndex","match","exec","slice","substring","mathMatch","blockMathMatch","TITLED_TABLE_REGEX","RegExp","SimpleMarkdown","defaultRules","nptable","regex","crowdinJiptMatcher","blockRegex","pureMarkdownRules","_extends","columns","order","parse","capture","col1","col2","crowdinId","prevCapture","isJipt","id","titledTable","title","parseInline","tableCapture","table","widget","link","inlineRegex","widgetType","blockMath","codeBlock","content","math","unescapedDollar","fence","node","lang","type","blockQuote","lint","s","builtParser","parserFor","paragraphedSource"],"mappings":";;;AAAA,SAAS,QAAQ,GAAG;AACpB,EAAE,OAAO,QAAQ,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,UAAU,CAAC,EAAE;AACxE,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC/C,MAAM,IAAI,CAAC,GAAG,SAAS,CA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A;AACRI,IAAAA,MAAM,EAAE,KAAA;AAAK,GAAA,CAChB,CAAC,CAAA;AACN;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../utils/shared/add-library-version-to-perseus-debug.ts","../../src/version.ts","../../src/index.ts"],"sourcesContent":["/**\n * Adds the given perseus library version information to the __perseus_debug__\n * object and ensures that the object is attached to `globalThis` (`window` in\n * browser environments).\n *\n * This allows each library to provide runtime version information to assist in\n * debugging in production environments.\n */\nexport const addLibraryVersionToPerseusDebug = (\n libraryName: string,\n libraryVersion: string,\n) => {\n // If the library version is the default value, then we don't want to\n // prefix it with a \"v\" to indicate that it is a version number.\n let prefix = \"v\";\n if (libraryVersion === \"__lib_version__\") {\n prefix = \"\";\n }\n const formattedVersion = `${prefix}${libraryVersion}`;\n\n if (typeof globalThis !== \"undefined\") {\n globalThis.__perseus_debug__ = globalThis.__perseus_debug__ ?? {};\n\n const existingVersionEntry = globalThis.__perseus_debug__[libraryName];\n if (existingVersionEntry) {\n // If we already have an entry and it doesn't match the registered\n // version, we morph the entry into an array and log a warning.\n if (existingVersionEntry !== formattedVersion) {\n // Existing entry might be an array already (oops, at least 2\n // versions of the library already loaded!).\n const allVersions = Array.isArray(existingVersionEntry)\n ? existingVersionEntry\n : [existingVersionEntry];\n allVersions.push(formattedVersion);\n\n globalThis.__perseus_debug__[libraryName] = allVersions;\n\n // eslint-disable-next-line no-console\n console.warn(\n `Multiple versions of ${libraryName} loaded on this page: ${allVersions\n .sort()\n .join(\", \")}`,\n );\n }\n } else {\n globalThis.__perseus_debug__[libraryName] = formattedVersion;\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn(`globalThis not found found (${formattedVersion})`);\n }\n};\n","// This file is processed by a Rollup plugin (replace) to inject the production\n// version number during the release build.\n// In dev, you'll never see the version number.\n\n// We use a shared, symlinked directory to bring in this function so that we\n// don't need to have cross-package dependencies just for a few hundred bytes\n// of shared code.\n// ESLint's import/no-relative-packages doesn't understand symlinks! If this\n// lint suppression is removed, it autofixes the import path to an invalid\n// package+path entry.\n// eslint-disable-next-line import/no-relative-packages\nimport {addLibraryVersionToPerseusDebug} from \"./shared-utils/add-library-version-to-perseus-debug\";\n\nconst libName = \"@khanacademy/pure-markdown\";\nexport const libVersion = \"__lib_version__\";\n\naddLibraryVersionToPerseusDebug(libName, libVersion);\n","/**\n * Contains markdown related functions in pure javascript,\n * extracted from perseus-markdown.jsx\n * Note that this file may be used in stand alone nodejs, thus\n * do not import anything from Perseus\n */\nexport {libVersion} from \"./version\";\n\nimport SimpleMarkdown from \"@khanacademy/simple-markdown\";\n\nconst rWidgetRule = /^\\[\\[\\u2603 (([a-z-]+) ([0-9]+))\\]\\]/;\n\n/**\n * This match function matches math in `$`s, such as:\n *\n * $y = x + 1$\n *\n * It functions roughly like the following regex:\n * /\\$([^\\$]*)\\$/\n *\n * Unfortunately, math may have other `$`s inside it, as\n * long as they are inside `{` braces `}`, mostly for\n * `\\text{ $math$ }`.\n *\n * To parse this, we can't use a regex, since we\n * should support arbitrary nesting (even though\n * MathJax actually only supports two levels of nesting\n * here, which we *could* parse with a regex).\n *\n * Non-regex matchers like this are now a first-class\n * concept in simple-markdown. Yay!\n *\n * This can also match block-math, which is math alone in a paragraph.\n */\nconst mathMatcher = (source: any, state: any, isBlock: boolean) => {\n const length = source.length;\n let index = 0;\n\n // When looking for blocks, skip over leading spaces\n if (isBlock) {\n if (state.inline) {\n return null;\n }\n while (index < length && source[index] === \" \") {\n index++;\n }\n }\n\n // Our source must start with a \"$\"\n if (!(index < length && source[index] === \"$\")) {\n return null;\n }\n\n index++;\n const startIndex = index;\n let braceLevel = 0;\n\n // Loop through the source, looking for a closing '$'\n // closing '$'s only count if they are not escaped with\n // a `\\`, and we are not in nested `{}` braces.\n while (index < length) {\n const character = source[index];\n\n if (character === \"\\\\\") {\n // Consume both the `\\` and the escaped char as a single\n // token.\n // This is so that the second `$` in `$\\\\$` closes\n // the math expression, since the first `\\` is escaping\n // the second `\\`, but the second `\\` is not escaping\n // the second `$`.\n // This also handles the case of escaping `$`s or\n // braces `\\{`\n index++;\n } else if (braceLevel <= 0 && character === \"$\") {\n let endIndex = index + 1;\n if (isBlock) {\n // Look for two trailing newlines after the closing `$`\n const match = /^(?: *\\n){2,}/.exec(source.slice(endIndex));\n // @ts-expect-error - TS2322 - Type 'number | null' is not assignable to type 'number'.\n endIndex = match ? endIndex + match[0].length : null;\n }\n\n // Return an array that looks like the results of a\n // regex's .exec function:\n // capture[0] is the whole string\n // capture[1] is the first \"paren\" match, which is the\n // content of the math here, as if we wrote the regex\n // /\\$([^\\$]*)\\$/\n if (endIndex) {\n return [\n source.substring(0, endIndex),\n source.substring(startIndex, index),\n ];\n }\n return null;\n } else if (character === \"{\") {\n braceLevel++;\n } else if (character === \"}\") {\n braceLevel--;\n } else if (character === \"\\n\" && source[index - 1] === \"\\n\") {\n // This is a weird case we supported in the old\n // math implementation--double newlines break\n // math. I'm preserving it for now because content\n // creators might have questions with single '$'s\n // in paragraphs...\n return null;\n }\n\n index++;\n }\n\n // we didn't find a closing `$`\n return null;\n};\nconst mathMatch = (source: any, state: any): any =>\n mathMatcher(source, state, false);\nconst blockMathMatch = (source: any, state: any): any =>\n mathMatcher(source, state, true);\n\nconst TITLED_TABLE_REGEX = new RegExp(\n \"^\\\\|\\\\| +(.*) +\\\\|\\\\| *\\\\n\" +\n \"(\" +\n // The simple-markdown nptable regex, without\n // the leading `^`\n // @ts-expect-error - TS2532 - Object is possibly 'undefined'.\n SimpleMarkdown.defaultRules.nptable.match.regex.source.substring(1) +\n \")\",\n);\n\nconst crowdinJiptMatcher = SimpleMarkdown.blockRegex(/^(crwdns.*)\\n\\s*\\n/);\n\nexport const pureMarkdownRules = {\n ...SimpleMarkdown.defaultRules,\n\n // NOTE: basically ignored by JIPT. wraps everything at the outer layer\n columns: {\n order: -2,\n match: SimpleMarkdown.blockRegex(\n /^([\\s\\S]*\\n\\n)={5,}\\n\\n([\\s\\S]*)/,\n ) as any,\n parse: (capture: any, parse: any, state: any): any => {\n return {\n col1: parse(capture[1], state),\n col2: parse(capture[2], state),\n };\n },\n },\n crowdinId: {\n order: -1,\n match: (source: any, state: any, prevCapture: any): any => {\n // Only match on the just-in-place translation site\n if (state.isJipt) {\n return crowdinJiptMatcher(source, state, prevCapture);\n }\n return null;\n },\n parse: (capture: any, parse: any, state: any): any => ({\n id: capture[1],\n }),\n },\n // This is pretty much horrible, but we have a regex here to capture an\n // entire table + a title. capture[1] is the title. capture[2] of the\n // regex is a copy of the simple-markdown nptable regex. Then we turn\n // our capture[2] into tableCapture[0], and any further captures in\n // our table regex into tableCapture[1..], and we pass tableCapture to\n // our nptable regex\n titledTable: {\n // process immediately before nptables\n order: SimpleMarkdown.defaultRules.nptable.order - 0.5,\n match: SimpleMarkdown.blockRegex(TITLED_TABLE_REGEX) as any,\n parse: (capture: any, parse: any, state: any): any => {\n const title = SimpleMarkdown.parseInline(parse, capture[1], state);\n\n // Remove our [0] and [1] captures, and pass the rest to\n // the nptable parser\n const tableCapture = capture.slice(2);\n const table = SimpleMarkdown.defaultRules.nptable.parse(\n tableCapture,\n parse,\n state,\n );\n return {\n title: title,\n table: table,\n };\n },\n },\n widget: {\n order: SimpleMarkdown.defaultRules.link.order - 0.75,\n match: SimpleMarkdown.inlineRegex(rWidgetRule) as any,\n parse: (capture: any, parse: any, state: any): any => {\n return {\n id: capture[1],\n widgetType: capture[2],\n };\n },\n },\n blockMath: {\n order: (SimpleMarkdown.defaultRules.codeBlock.order + 0.5) as any,\n match: blockMathMatch,\n parse: (capture: any, parse: any, state: any): any => {\n return {\n content: capture[1],\n };\n },\n },\n math: {\n order: SimpleMarkdown.defaultRules.link.order - 0.25,\n match: mathMatch,\n parse: (capture: any, parse: any, state: any): any => {\n return {\n content: capture[1],\n };\n },\n },\n unescapedDollar: {\n order: SimpleMarkdown.defaultRules.link.order - 0.24,\n match: SimpleMarkdown.inlineRegex(/^(?!\\\\)\\$/) as any,\n parse: (capture: any, parse: any, state: any): any => {\n return {};\n },\n },\n fence: {\n ...SimpleMarkdown.defaultRules.fence,\n parse: (capture: any, parse: any, state: any): any => {\n const node = SimpleMarkdown.defaultRules.fence.parse(\n capture,\n parse,\n state,\n );\n\n // support screenreader-only text with ```alt\n if (node.lang === \"alt\") {\n return {\n type: \"codeBlock\",\n lang: \"alt\",\n // default codeBlock parsing doesn't parse the contents.\n // We need to parse the contents for things like table\n // support :).\n // The \\n\\n is because the inside of the codeblock might\n // not end in double newlines for block rules, because\n // ordinarily we don't parse this :).\n content: parse(node.content + \"\\n\\n\", state),\n };\n }\n return node;\n },\n },\n blockQuote: {\n ...SimpleMarkdown.defaultRules.blockQuote,\n // Replace the less restrictive blockquote regex from SimpleMarkdown\n // with a more restrictive one. The only difference should be that\n //\n // > A blockquote\n //\n // > Another blockquote\n //\n // will now match as two different blockQuotes instead of a single\n // blockquote with some paragraph breaks in it.\n //\n // The main motivation for doing this is to provide better support for\n // translators translating blockquotes with multiple paragraphs in\n // them. When translating articles, we split up paragraphs, translate\n // them separately, and then recombine them. We do this so that\n // translators don't have to translate an entire article at a time,\n // they can instead translate paragraph-by-paragraph.That system\n // doesn't understand blockquotes, so it will split up blockquotes into\n // more than one paragraph. A way to solve this would be to make that\n // system understand blockquotes, but then translators would have to\n // translate an entire, multi-paragraph blockquote at a time. Instead,\n // we choose to modify our blockquote matching to split up\n // multi-paragraph blockquotes into multiple blockquotes.\n //\n // There is also precedence for doing this splitting up in other\n // libraries, for instance CommonMark also splits up blockquotes with\n // empty lines into multiple blockquotes:\n // https://spec.commonmark.org/0.28/#example-205\n match: SimpleMarkdown.blockRegex(\n /^ *>[^\\n]+(\\n( *>)?[^\\n]+)*\\n{2,}/,\n ) as any,\n },\n // The lint rule never actually matches anything.\n // We check for lint after parsing, and, if we find any, we\n // transform the tree to add lint nodes. This rule is here\n // just for the react() function\n lint: {\n order: 1000,\n match: (s: any): any => null,\n parse: (capture: any, parse: any, state: any): any => ({}),\n },\n} as const;\n\n// @ts-expect-error - TS2345 - Argument of type '{ readonly columns: { readonly order: -2; readonly match: any; readonly parse: (capture: any, parse: any, state: any) => any; }; readonly crowdinId: { readonly order: -1; readonly match: (source: any, state: any, prevCapture: any) => any; readonly parse: (capture: any, parse: any, state: any) => any; }; ... 34 more ...' is not assignable to parameter of type 'ParserRules'.\nconst builtParser = SimpleMarkdown.parserFor(pureMarkdownRules);\n\nexport const parse = (source: string, state?: any): any => {\n const paragraphedSource = source + \"\\n\\n\";\n\n return builtParser(paragraphedSource, {\n ...state,\n inline: false,\n });\n};\n"],"names":["addLibraryVersionToPerseusDebug","libraryName","libraryVersion","prefix","formattedVersion","globalThis","_globalThis$__perseus","__perseus_debug__","existingVersionEntry","allVersions","Array","isArray","push","console","warn","sort","join","libName","libVersion","rWidgetRule","mathMatcher","source","state","isBlock","length","index","inline","startIndex","braceLevel","character","endIndex","match","exec","slice","substring","mathMatch","blockMathMatch","TITLED_TABLE_REGEX","RegExp","SimpleMarkdown","defaultRules","nptable","regex","crowdinJiptMatcher","blockRegex","pureMarkdownRules","_extends","columns","order","parse","capture","col1","col2","crowdinId","prevCapture","isJipt","id","titledTable","title","parseInline","tableCapture","table","widget","link","inlineRegex","widgetType","blockMath","codeBlock","content","math","unescapedDollar","fence","node","lang","type","blockQuote","lint","s","builtParser","parserFor","paragraphedSource"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,+BAA+B,GAAGA,CAC3CC,WAAmB,EACnBC,cAAsB,KACrB;AACD;AACA;EACA,IAAIC,MAAM,GAAG,GAAG,CAAA;EAChB,IAAID,cAAc,KAAK,iBAAiB,EAAE;AACtCC,IAAAA,MAAM,GAAG,EAAE,CAAA;AACf,GAAA;AACA,EAAA,MAAMC,gBAAgB,GAAG,CAAA,EAAGD,MAAM,CAAA,EAAGD,cAAc,CAAE,CAAA,CAAA;AAErD,EAAA,IAAI,OAAOG,UAAU,KAAK,WAAW,EAAE;AAAA,IAAA,IAAAC,qBAAA,CAAA;AACnCD,IAAAA,U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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA5C,IAAAA,KAAK,EAAEQ,cAAc,CAACK,UAAU,CAC5B,mCACJ,CAAA;GACH,CAAA;AACD;AACA;AACA;AACA;AACAgC,EAAAA,IAAI,EAAE;AACF5B,IAAAA,KAAK,EAAE,IAAI;IACXjB,KAAK,EAAG8C,CAAM,IAAU,IAAI;IAC5B5B,KAAK,EAAEA,CAACC,OAAY,EAAED,KAAU,EAAE3B,KAAU,MAAW,EAAE,CAAA;AAC7D,GAAA;AAAC,CACK,EAAA;;AAEV;AACA,MAAMwD,WAAW,GAAGvC,cAAc,CAACwC,SAAS,CAAClC,iBAAiB,CAAC,CAAA;MAElDI,KAAK,GAAGA,CAAC5B,MAAc,EAAEC,KAAW,KAAU;AACvD,EAAA,MAAM0D,iBAAiB,GAAG3D,MAAM,GAAG,MAAM,CAAA;AAEzC,EAAA,OAAOyD,WAAW,CAACE,iBAAiB,EAAAlC,QAAA,KAC7BxB,KAAK,EAAA;AACRI,IAAAA,MAAM,EAAE,KAAA;AAAK,GAAA,CAChB,CAAC,CAAA;AACN;;;;"}
package/dist/index.js CHANGED
@@ -2,17 +2,57 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var perseusCore = require('@khanacademy/perseus-core');
6
5
  var SimpleMarkdown = require('@khanacademy/simple-markdown');
7
6
 
8
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
8
 
10
9
  var SimpleMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(SimpleMarkdown);
11
10
 
11
+ /**
12
+ * Adds the given perseus library version information to the __perseus_debug__
13
+ * object and ensures that the object is attached to `globalThis` (`window` in
14
+ * browser environments).
15
+ *
16
+ * This allows each library to provide runtime version information to assist in
17
+ * debugging in production environments.
18
+ */
19
+ const addLibraryVersionToPerseusDebug = (libraryName, libraryVersion) => {
20
+ // If the library version is the default value, then we don't want to
21
+ // prefix it with a "v" to indicate that it is a version number.
22
+ let prefix = "v";
23
+ if (libraryVersion === "__lib_version__") {
24
+ prefix = "";
25
+ }
26
+ const formattedVersion = `${prefix}${libraryVersion}`;
27
+ if (typeof globalThis !== "undefined") {
28
+ globalThis.__perseus_debug__ = globalThis.__perseus_debug__ ?? {};
29
+ const existingVersionEntry = globalThis.__perseus_debug__[libraryName];
30
+ if (existingVersionEntry) {
31
+ // If we already have an entry and it doesn't match the registered
32
+ // version, we morph the entry into an array and log a warning.
33
+ if (existingVersionEntry !== formattedVersion) {
34
+ // Existing entry might be an array already (oops, at least 2
35
+ // versions of the library already loaded!).
36
+ const allVersions = Array.isArray(existingVersionEntry) ? existingVersionEntry : [existingVersionEntry];
37
+ allVersions.push(formattedVersion);
38
+ globalThis.__perseus_debug__[libraryName] = allVersions;
39
+
40
+ // eslint-disable-next-line no-console
41
+ console.warn(`Multiple versions of ${libraryName} loaded on this page: ${allVersions.sort().join(", ")}`);
42
+ }
43
+ } else {
44
+ globalThis.__perseus_debug__[libraryName] = formattedVersion;
45
+ }
46
+ } else {
47
+ // eslint-disable-next-line no-console
48
+ console.warn(`globalThis not found found (${formattedVersion})`);
49
+ }
50
+ };
51
+
12
52
  // This file is processed by a Rollup plugin (replace) to inject the production
13
53
  const libName = "@khanacademy/pure-markdown";
14
- const libVersion = "0.3.26";
15
- perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
54
+ const libVersion = "0.4.0";
55
+ addLibraryVersionToPerseusDebug(libName, libVersion);
16
56
 
17
57
  /**
18
58
  * Contains markdown related functions in pure javascript,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/version.ts","../src/index.ts"],"sourcesContent":["// This file is processed by a Rollup plugin (replace) to inject the production\n// version number during the release build.\n// In dev, you'll never see the version number.\n\nimport {addLibraryVersionToPerseusDebug} from \"@khanacademy/perseus-core\";\n\nconst libName = \"@khanacademy/pure-markdown\";\nexport const libVersion = \"__lib_version__\";\n\naddLibraryVersionToPerseusDebug(libName, libVersion);\n","/**\n * Contains markdown related functions in pure javascript,\n * extracted from perseus-markdown.jsx\n * Note that this file may be used in stand alone nodejs, thus\n * do not import anything from Perseus\n */\nexport {libVersion} from \"./version\";\n\nimport SimpleMarkdown from \"@khanacademy/simple-markdown\";\n\nconst rWidgetRule = /^\\[\\[\\u2603 (([a-z-]+) ([0-9]+))\\]\\]/;\n\n/**\n * This match function matches math in `$`s, such as:\n *\n * $y = x + 1$\n *\n * It functions roughly like the following regex:\n * /\\$([^\\$]*)\\$/\n *\n * Unfortunately, math may have other `$`s inside it, as\n * long as they are inside `{` braces `}`, mostly for\n * `\\text{ $math$ }`.\n *\n * To parse this, we can't use a regex, since we\n * should support arbitrary nesting (even though\n * MathJax actually only supports two levels of nesting\n * here, which we *could* parse with a regex).\n *\n * Non-regex matchers like this are now a first-class\n * concept in simple-markdown. Yay!\n *\n * This can also match block-math, which is math alone in a paragraph.\n */\nconst mathMatcher = (source: any, state: any, isBlock: boolean) => {\n const length = source.length;\n let index = 0;\n\n // When looking for blocks, skip over leading spaces\n if (isBlock) {\n if (state.inline) {\n return null;\n }\n while (index < length && source[index] === \" \") {\n index++;\n }\n }\n\n // Our source must start with a \"$\"\n if (!(index < length && source[index] === \"$\")) {\n return null;\n }\n\n index++;\n const startIndex = index;\n let braceLevel = 0;\n\n // Loop through the source, looking for a closing '$'\n // closing '$'s only count if they are not escaped with\n // a `\\`, and we are not in nested `{}` braces.\n while (index < length) {\n const character = source[index];\n\n if (character === \"\\\\\") {\n // Consume both the `\\` and the escaped char as a single\n // token.\n // This is so that the second `$` in `$\\\\$` closes\n // the math expression, since the first `\\` is escaping\n // the second `\\`, but the second `\\` is not escaping\n // the second `$`.\n // This also handles the case of escaping `$`s or\n // braces `\\{`\n index++;\n } else if (braceLevel <= 0 && character === \"$\") {\n let endIndex = index + 1;\n if (isBlock) {\n // Look for two trailing newlines after the closing `$`\n const match = /^(?: *\\n){2,}/.exec(source.slice(endIndex));\n // @ts-expect-error - TS2322 - Type 'number | null' is not assignable to type 'number'.\n endIndex = match ? endIndex + match[0].length : null;\n }\n\n // Return an array that looks like the results of a\n // regex's .exec function:\n // capture[0] is the whole string\n // capture[1] is the first \"paren\" match, which is the\n // content of the math here, as if we wrote the regex\n // /\\$([^\\$]*)\\$/\n if (endIndex) {\n return [\n source.substring(0, endIndex),\n source.substring(startIndex, index),\n ];\n }\n return null;\n } else if (character === \"{\") {\n braceLevel++;\n } else if (character === \"}\") {\n braceLevel--;\n } else if (character === \"\\n\" && source[index - 1] === \"\\n\") {\n // This is a weird case we supported in the old\n // math implementation--double newlines break\n // math. I'm preserving it for now because content\n // creators might have questions with single '$'s\n // in paragraphs...\n return null;\n }\n\n index++;\n }\n\n // we didn't find a closing `$`\n return null;\n};\nconst mathMatch = (source: any, state: any): any =>\n mathMatcher(source, state, false);\nconst blockMathMatch = (source: any, state: any): any =>\n mathMatcher(source, state, true);\n\nconst TITLED_TABLE_REGEX = new RegExp(\n \"^\\\\|\\\\| +(.*) +\\\\|\\\\| *\\\\n\" +\n \"(\" +\n // The simple-markdown nptable regex, without\n // the leading `^`\n // @ts-expect-error - TS2532 - Object is possibly 'undefined'.\n SimpleMarkdown.defaultRules.nptable.match.regex.source.substring(1) +\n \")\",\n);\n\nconst crowdinJiptMatcher = SimpleMarkdown.blockRegex(/^(crwdns.*)\\n\\s*\\n/);\n\nexport const pureMarkdownRules = {\n ...SimpleMarkdown.defaultRules,\n\n // NOTE: basically ignored by JIPT. wraps everything at the outer layer\n columns: {\n order: -2,\n match: SimpleMarkdown.blockRegex(\n /^([\\s\\S]*\\n\\n)={5,}\\n\\n([\\s\\S]*)/,\n ) as any,\n parse: (capture: any, parse: any, state: any): any => {\n return {\n col1: parse(capture[1], state),\n col2: parse(capture[2], state),\n };\n },\n },\n crowdinId: {\n order: -1,\n match: (source: any, state: any, prevCapture: any): any => {\n // Only match on the just-in-place translation site\n if (state.isJipt) {\n return crowdinJiptMatcher(source, state, prevCapture);\n }\n return null;\n },\n parse: (capture: any, parse: any, state: any): any => ({\n id: capture[1],\n }),\n },\n // This is pretty much horrible, but we have a regex here to capture an\n // entire table + a title. capture[1] is the title. capture[2] of the\n // regex is a copy of the simple-markdown nptable regex. Then we turn\n // our capture[2] into tableCapture[0], and any further captures in\n // our table regex into tableCapture[1..], and we pass tableCapture to\n // our nptable regex\n titledTable: {\n // process immediately before nptables\n order: SimpleMarkdown.defaultRules.nptable.order - 0.5,\n match: SimpleMarkdown.blockRegex(TITLED_TABLE_REGEX) as any,\n parse: (capture: any, parse: any, state: any): any => {\n const title = SimpleMarkdown.parseInline(parse, capture[1], state);\n\n // Remove our [0] and [1] captures, and pass the rest to\n // the nptable parser\n const tableCapture = capture.slice(2);\n const table = SimpleMarkdown.defaultRules.nptable.parse(\n tableCapture,\n parse,\n state,\n );\n return {\n title: title,\n table: table,\n };\n },\n },\n widget: {\n order: SimpleMarkdown.defaultRules.link.order - 0.75,\n match: SimpleMarkdown.inlineRegex(rWidgetRule) as any,\n parse: (capture: any, parse: any, state: any): any => {\n return {\n id: capture[1],\n widgetType: capture[2],\n };\n },\n },\n blockMath: {\n order: (SimpleMarkdown.defaultRules.codeBlock.order + 0.5) as any,\n match: blockMathMatch,\n parse: (capture: any, parse: any, state: any): any => {\n return {\n content: capture[1],\n };\n },\n },\n math: {\n order: SimpleMarkdown.defaultRules.link.order - 0.25,\n match: mathMatch,\n parse: (capture: any, parse: any, state: any): any => {\n return {\n content: capture[1],\n };\n },\n },\n unescapedDollar: {\n order: SimpleMarkdown.defaultRules.link.order - 0.24,\n match: SimpleMarkdown.inlineRegex(/^(?!\\\\)\\$/) as any,\n parse: (capture: any, parse: any, state: any): any => {\n return {};\n },\n },\n fence: {\n ...SimpleMarkdown.defaultRules.fence,\n parse: (capture: any, parse: any, state: any): any => {\n const node = SimpleMarkdown.defaultRules.fence.parse(\n capture,\n parse,\n state,\n );\n\n // support screenreader-only text with ```alt\n if (node.lang === \"alt\") {\n return {\n type: \"codeBlock\",\n lang: \"alt\",\n // default codeBlock parsing doesn't parse the contents.\n // We need to parse the contents for things like table\n // support :).\n // The \\n\\n is because the inside of the codeblock might\n // not end in double newlines for block rules, because\n // ordinarily we don't parse this :).\n content: parse(node.content + \"\\n\\n\", state),\n };\n }\n return node;\n },\n },\n blockQuote: {\n ...SimpleMarkdown.defaultRules.blockQuote,\n // Replace the less restrictive blockquote regex from SimpleMarkdown\n // with a more restrictive one. The only difference should be that\n //\n // > A blockquote\n //\n // > Another blockquote\n //\n // will now match as two different blockQuotes instead of a single\n // blockquote with some paragraph breaks in it.\n //\n // The main motivation for doing this is to provide better support for\n // translators translating blockquotes with multiple paragraphs in\n // them. When translating articles, we split up paragraphs, translate\n // them separately, and then recombine them. We do this so that\n // translators don't have to translate an entire article at a time,\n // they can instead translate paragraph-by-paragraph.That system\n // doesn't understand blockquotes, so it will split up blockquotes into\n // more than one paragraph. A way to solve this would be to make that\n // system understand blockquotes, but then translators would have to\n // translate an entire, multi-paragraph blockquote at a time. Instead,\n // we choose to modify our blockquote matching to split up\n // multi-paragraph blockquotes into multiple blockquotes.\n //\n // There is also precedence for doing this splitting up in other\n // libraries, for instance CommonMark also splits up blockquotes with\n // empty lines into multiple blockquotes:\n // https://spec.commonmark.org/0.28/#example-205\n match: SimpleMarkdown.blockRegex(\n /^ *>[^\\n]+(\\n( *>)?[^\\n]+)*\\n{2,}/,\n ) as any,\n },\n // The lint rule never actually matches anything.\n // We check for lint after parsing, and, if we find any, we\n // transform the tree to add lint nodes. This rule is here\n // just for the react() function\n lint: {\n order: 1000,\n match: (s: any): any => null,\n parse: (capture: any, parse: any, state: any): any => ({}),\n },\n} as const;\n\n// @ts-expect-error - TS2345 - Argument of type '{ readonly columns: { readonly order: -2; readonly match: any; readonly parse: (capture: any, parse: any, state: any) => any; }; readonly crowdinId: { readonly order: -1; readonly match: (source: any, state: any, prevCapture: any) => any; readonly parse: (capture: any, parse: any, state: any) => any; }; ... 34 more ...' is not assignable to parameter of type 'ParserRules'.\nconst builtParser = SimpleMarkdown.parserFor(pureMarkdownRules);\n\nexport const parse = (source: string, state?: any): any => {\n const paragraphedSource = source + \"\\n\\n\";\n\n return builtParser(paragraphedSource, {\n ...state,\n inline: false,\n });\n};\n"],"names":["libName","libVersion","addLibraryVersionToPerseusDebug","rWidgetRule","mathMatcher","source","state","isBlock","length","index","inline","startIndex","braceLevel","character","endIndex","match","exec","slice","substring","mathMatch","blockMathMatch","TITLED_TABLE_REGEX","RegExp","SimpleMarkdown","defaultRules","nptable","regex","crowdinJiptMatcher","blockRegex","pureMarkdownRules","columns","order","parse","capture","col1","col2","crowdinId","prevCapture","isJipt","id","titledTable","title","parseInline","tableCapture","table","widget","link","inlineRegex","widgetType","blockMath","codeBlock","content","math","unescapedDollar","fence","node","lang","type","blockQuote","lint","s","builtParser","parserFor","paragraphedSource"],"mappings":";;;;;;;;;;;AAAA;AAMA,MAAMA,OAAO,GAAG,4BAA4B,CAAA;AACrC,MAAMC,UAAU,GAAG,SAAiB;AAE3CC,2CAA+B,CAACF,OAAO,EAAEC,UAAU,CAAC;;ACTpD;AACA;AACA;AACA;AACA;AACA;AAKA,MAAME,WAAW,GAAG,sCAAsC,CAAA;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAAGA,CAACC,MAAW,EAAEC,KAAU,EAAEC,OAAgB,KAAK;AAC/D,EAAA,MAAMC,MAAM,GAAGH,MAAM,CAACG,MAAM,CAAA;EAC5B,IAAIC,KAAK,GAAG,CAAC,CAAA;;AAEb;AACA,EAAA,IAAIF,OAAO,EAAE;IACT,IAAID,KAAK,CAACI,MAAM,EAAE;AACd,MAAA,OAAO,IAAI,CAAA;AACf,KAAA;IACA,OAAOD,KAAK,GAAGD,MAAM,IAAIH,MAAM,CAACI,KAAK,CAAC,KAAK,GAAG,EAAE;AAC5CA,M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ACjC,iBAAiB,CAAC,CAAA;MAElDG,KAAK,GAAGA,CAAC3B,MAAc,EAAEC,KAAW,KAAU;AACvD,EAAA,MAAMyD,iBAAiB,GAAG1D,MAAM,GAAG,MAAM,CAAA;EAEzC,OAAOwD,WAAW,CAACE,iBAAiB,EAAE;AAClC,IAAA,GAAGzD,KAAK;AACRI,IAAAA,MAAM,EAAE,KAAA;AACZ,GAAC,CAAC,CAAA;AACN;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../utils/shared/add-library-version-to-perseus-debug.ts","../src/version.ts","../src/index.ts"],"sourcesContent":["/**\n * Adds the given perseus library version information to the __perseus_debug__\n * object and ensures that the object is attached to `globalThis` (`window` in\n * browser environments).\n *\n * This allows each library to provide runtime version information to assist in\n * debugging in production environments.\n */\nexport const addLibraryVersionToPerseusDebug = (\n libraryName: string,\n libraryVersion: string,\n) => {\n // If the library version is the default value, then we don't want to\n // prefix it with a \"v\" to indicate that it is a version number.\n let prefix = \"v\";\n if (libraryVersion === \"__lib_version__\") {\n prefix = \"\";\n }\n const formattedVersion = `${prefix}${libraryVersion}`;\n\n if (typeof globalThis !== \"undefined\") {\n globalThis.__perseus_debug__ = globalThis.__perseus_debug__ ?? {};\n\n const existingVersionEntry = globalThis.__perseus_debug__[libraryName];\n if (existingVersionEntry) {\n // If we already have an entry and it doesn't match the registered\n // version, we morph the entry into an array and log a warning.\n if (existingVersionEntry !== formattedVersion) {\n // Existing entry might be an array already (oops, at least 2\n // versions of the library already loaded!).\n const allVersions = Array.isArray(existingVersionEntry)\n ? existingVersionEntry\n : [existingVersionEntry];\n allVersions.push(formattedVersion);\n\n globalThis.__perseus_debug__[libraryName] = allVersions;\n\n // eslint-disable-next-line no-console\n console.warn(\n `Multiple versions of ${libraryName} loaded on this page: ${allVersions\n .sort()\n .join(\", \")}`,\n );\n }\n } else {\n globalThis.__perseus_debug__[libraryName] = formattedVersion;\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn(`globalThis not found found (${formattedVersion})`);\n }\n};\n","// This file is processed by a Rollup plugin (replace) to inject the production\n// version number during the release build.\n// In dev, you'll never see the version number.\n\n// We use a shared, symlinked directory to bring in this function so that we\n// don't need to have cross-package dependencies just for a few hundred bytes\n// of shared code.\n// ESLint's import/no-relative-packages doesn't understand symlinks! If this\n// lint suppression is removed, it autofixes the import path to an invalid\n// package+path entry.\n// eslint-disable-next-line import/no-relative-packages\nimport {addLibraryVersionToPerseusDebug} from \"./shared-utils/add-library-version-to-perseus-debug\";\n\nconst libName = \"@khanacademy/pure-markdown\";\nexport const libVersion = \"__lib_version__\";\n\naddLibraryVersionToPerseusDebug(libName, libVersion);\n","/**\n * Contains markdown related functions in pure javascript,\n * extracted from perseus-markdown.jsx\n * Note that this file may be used in stand alone nodejs, thus\n * do not import anything from Perseus\n */\nexport {libVersion} from \"./version\";\n\nimport SimpleMarkdown from \"@khanacademy/simple-markdown\";\n\nconst rWidgetRule = /^\\[\\[\\u2603 (([a-z-]+) ([0-9]+))\\]\\]/;\n\n/**\n * This match function matches math in `$`s, such as:\n *\n * $y = x + 1$\n *\n * It functions roughly like the following regex:\n * /\\$([^\\$]*)\\$/\n *\n * Unfortunately, math may have other `$`s inside it, as\n * long as they are inside `{` braces `}`, mostly for\n * `\\text{ $math$ }`.\n *\n * To parse this, we can't use a regex, since we\n * should support arbitrary nesting (even though\n * MathJax actually only supports two levels of nesting\n * here, which we *could* parse with a regex).\n *\n * Non-regex matchers like this are now a first-class\n * concept in simple-markdown. Yay!\n *\n * This can also match block-math, which is math alone in a paragraph.\n */\nconst mathMatcher = (source: any, state: any, isBlock: boolean) => {\n const length = source.length;\n let index = 0;\n\n // When looking for blocks, skip over leading spaces\n if (isBlock) {\n if (state.inline) {\n return null;\n }\n while (index < length && source[index] === \" \") {\n index++;\n }\n }\n\n // Our source must start with a \"$\"\n if (!(index < length && source[index] === \"$\")) {\n return null;\n }\n\n index++;\n const startIndex = index;\n let braceLevel = 0;\n\n // Loop through the source, looking for a closing '$'\n // closing '$'s only count if they are not escaped with\n // a `\\`, and we are not in nested `{}` braces.\n while (index < length) {\n const character = source[index];\n\n if (character === \"\\\\\") {\n // Consume both the `\\` and the escaped char as a single\n // token.\n // This is so that the second `$` in `$\\\\$` closes\n // the math expression, since the first `\\` is escaping\n // the second `\\`, but the second `\\` is not escaping\n // the second `$`.\n // This also handles the case of escaping `$`s or\n // braces `\\{`\n index++;\n } else if (braceLevel <= 0 && character === \"$\") {\n let endIndex = index + 1;\n if (isBlock) {\n // Look for two trailing newlines after the closing `$`\n const match = /^(?: *\\n){2,}/.exec(source.slice(endIndex));\n // @ts-expect-error - TS2322 - Type 'number | null' is not assignable to type 'number'.\n endIndex = match ? endIndex + match[0].length : null;\n }\n\n // Return an array that looks like the results of a\n // regex's .exec function:\n // capture[0] is the whole string\n // capture[1] is the first \"paren\" match, which is the\n // content of the math here, as if we wrote the regex\n // /\\$([^\\$]*)\\$/\n if (endIndex) {\n return [\n source.substring(0, endIndex),\n source.substring(startIndex, index),\n ];\n }\n return null;\n } else if (character === \"{\") {\n braceLevel++;\n } else if (character === \"}\") {\n braceLevel--;\n } else if (character === \"\\n\" && source[index - 1] === \"\\n\") {\n // This is a weird case we supported in the old\n // math implementation--double newlines break\n // math. I'm preserving it for now because content\n // creators might have questions with single '$'s\n // in paragraphs...\n return null;\n }\n\n index++;\n }\n\n // we didn't find a closing `$`\n return null;\n};\nconst mathMatch = (source: any, state: any): any =>\n mathMatcher(source, state, false);\nconst blockMathMatch = (source: any, state: any): any =>\n mathMatcher(source, state, true);\n\nconst TITLED_TABLE_REGEX = new RegExp(\n \"^\\\\|\\\\| +(.*) +\\\\|\\\\| *\\\\n\" +\n \"(\" +\n // The simple-markdown nptable regex, without\n // the leading `^`\n // @ts-expect-error - TS2532 - Object is possibly 'undefined'.\n SimpleMarkdown.defaultRules.nptable.match.regex.source.substring(1) +\n \")\",\n);\n\nconst crowdinJiptMatcher = SimpleMarkdown.blockRegex(/^(crwdns.*)\\n\\s*\\n/);\n\nexport const pureMarkdownRules = {\n ...SimpleMarkdown.defaultRules,\n\n // NOTE: basically ignored by JIPT. wraps everything at the outer layer\n columns: {\n order: -2,\n match: SimpleMarkdown.blockRegex(\n /^([\\s\\S]*\\n\\n)={5,}\\n\\n([\\s\\S]*)/,\n ) as any,\n parse: (capture: any, parse: any, state: any): any => {\n return {\n col1: parse(capture[1], state),\n col2: parse(capture[2], state),\n };\n },\n },\n crowdinId: {\n order: -1,\n match: (source: any, state: any, prevCapture: any): any => {\n // Only match on the just-in-place translation site\n if (state.isJipt) {\n return crowdinJiptMatcher(source, state, prevCapture);\n }\n return null;\n },\n parse: (capture: any, parse: any, state: any): any => ({\n id: capture[1],\n }),\n },\n // This is pretty much horrible, but we have a regex here to capture an\n // entire table + a title. capture[1] is the title. capture[2] of the\n // regex is a copy of the simple-markdown nptable regex. Then we turn\n // our capture[2] into tableCapture[0], and any further captures in\n // our table regex into tableCapture[1..], and we pass tableCapture to\n // our nptable regex\n titledTable: {\n // process immediately before nptables\n order: SimpleMarkdown.defaultRules.nptable.order - 0.5,\n match: SimpleMarkdown.blockRegex(TITLED_TABLE_REGEX) as any,\n parse: (capture: any, parse: any, state: any): any => {\n const title = SimpleMarkdown.parseInline(parse, capture[1], state);\n\n // Remove our [0] and [1] captures, and pass the rest to\n // the nptable parser\n const tableCapture = capture.slice(2);\n const table = SimpleMarkdown.defaultRules.nptable.parse(\n tableCapture,\n parse,\n state,\n );\n return {\n title: title,\n table: table,\n };\n },\n },\n widget: {\n order: SimpleMarkdown.defaultRules.link.order - 0.75,\n match: SimpleMarkdown.inlineRegex(rWidgetRule) as any,\n parse: (capture: any, parse: any, state: any): any => {\n return {\n id: capture[1],\n widgetType: capture[2],\n };\n },\n },\n blockMath: {\n order: (SimpleMarkdown.defaultRules.codeBlock.order + 0.5) as any,\n match: blockMathMatch,\n parse: (capture: any, parse: any, state: any): any => {\n return {\n content: capture[1],\n };\n },\n },\n math: {\n order: SimpleMarkdown.defaultRules.link.order - 0.25,\n match: mathMatch,\n parse: (capture: any, parse: any, state: any): any => {\n return {\n content: capture[1],\n };\n },\n },\n unescapedDollar: {\n order: SimpleMarkdown.defaultRules.link.order - 0.24,\n match: SimpleMarkdown.inlineRegex(/^(?!\\\\)\\$/) as any,\n parse: (capture: any, parse: any, state: any): any => {\n return {};\n },\n },\n fence: {\n ...SimpleMarkdown.defaultRules.fence,\n parse: (capture: any, parse: any, state: any): any => {\n const node = SimpleMarkdown.defaultRules.fence.parse(\n capture,\n parse,\n state,\n );\n\n // support screenreader-only text with ```alt\n if (node.lang === \"alt\") {\n return {\n type: \"codeBlock\",\n lang: \"alt\",\n // default codeBlock parsing doesn't parse the contents.\n // We need to parse the contents for things like table\n // support :).\n // The \\n\\n is because the inside of the codeblock might\n // not end in double newlines for block rules, because\n // ordinarily we don't parse this :).\n content: parse(node.content + \"\\n\\n\", state),\n };\n }\n return node;\n },\n },\n blockQuote: {\n ...SimpleMarkdown.defaultRules.blockQuote,\n // Replace the less restrictive blockquote regex from SimpleMarkdown\n // with a more restrictive one. The only difference should be that\n //\n // > A blockquote\n //\n // > Another blockquote\n //\n // will now match as two different blockQuotes instead of a single\n // blockquote with some paragraph breaks in it.\n //\n // The main motivation for doing this is to provide better support for\n // translators translating blockquotes with multiple paragraphs in\n // them. When translating articles, we split up paragraphs, translate\n // them separately, and then recombine them. We do this so that\n // translators don't have to translate an entire article at a time,\n // they can instead translate paragraph-by-paragraph.That system\n // doesn't understand blockquotes, so it will split up blockquotes into\n // more than one paragraph. A way to solve this would be to make that\n // system understand blockquotes, but then translators would have to\n // translate an entire, multi-paragraph blockquote at a time. Instead,\n // we choose to modify our blockquote matching to split up\n // multi-paragraph blockquotes into multiple blockquotes.\n //\n // There is also precedence for doing this splitting up in other\n // libraries, for instance CommonMark also splits up blockquotes with\n // empty lines into multiple blockquotes:\n // https://spec.commonmark.org/0.28/#example-205\n match: SimpleMarkdown.blockRegex(\n /^ *>[^\\n]+(\\n( *>)?[^\\n]+)*\\n{2,}/,\n ) as any,\n },\n // The lint rule never actually matches anything.\n // We check for lint after parsing, and, if we find any, we\n // transform the tree to add lint nodes. This rule is here\n // just for the react() function\n lint: {\n order: 1000,\n match: (s: any): any => null,\n parse: (capture: any, parse: any, state: any): any => ({}),\n },\n} as const;\n\n// @ts-expect-error - TS2345 - Argument of type '{ readonly columns: { readonly order: -2; readonly match: any; readonly parse: (capture: any, parse: any, state: any) => any; }; readonly crowdinId: { readonly order: -1; readonly match: (source: any, state: any, prevCapture: any) => any; readonly parse: (capture: any, parse: any, state: any) => any; }; ... 34 more ...' is not assignable to parameter of type 'ParserRules'.\nconst builtParser = SimpleMarkdown.parserFor(pureMarkdownRules);\n\nexport const parse = (source: string, state?: any): any => {\n const paragraphedSource = source + \"\\n\\n\";\n\n return builtParser(paragraphedSource, {\n ...state,\n inline: false,\n });\n};\n"],"names":["addLibraryVersionToPerseusDebug","libraryName","libraryVersion","prefix","formattedVersion","globalThis","__perseus_debug__","existingVersionEntry","allVersions","Array","isArray","push","console","warn","sort","join","libName","libVersion","rWidgetRule","mathMatcher","source","state","isBlock","length","index","inline","startIndex","braceLevel","character","endIndex","match","exec","slice","substring","mathMatch","blockMathMatch","TITLED_TABLE_REGEX","RegExp","SimpleMarkdown","defaultRules","nptable","regex","crowdinJiptMatcher","blockRegex","pureMarkdownRules","columns","order","parse","capture","col1","col2","crowdinId","prevCapture","isJipt","id","titledTable","title","parseInline","tableCapture","table","widget","link","inlineRegex","widgetType","blockMath","codeBlock","content","math","unescapedDollar","fence","node","lang","type","blockQuote","lint","s","builtParser","parserFor","paragraphedSource"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,+BAA+B,GAAGA,CAC3CC,WAAmB,EACnBC,cAAsB,KACrB;AACD;AACA;EACA,IAAIC,MAAM,GAAG,GAAG,CAAA;EAChB,IAAID,cAAc,KAAK,iBAAiB,EAAE;AACtCC,IAAAA,MAAM,GAAG,EAAE,CAAA;AACf,GA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YAAY,CAACkC,UAAU;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA3C,IAAAA,KAAK,EAAEQ,kCAAc,CAACK,UAAU,CAC5B,mCACJ,CAAA;GACH;AACD;AACA;AACA;AACA;AACA+B,EAAAA,IAAI,EAAE;AACF5B,IAAAA,KAAK,EAAE,IAAI;IACXhB,KAAK,EAAG6C,CAAM,IAAU,IAAI;IAC5B5B,KAAK,EAAEA,CAACC,OAAY,EAAED,KAAU,EAAE1B,KAAU,MAAW,EAAE,CAAA;AAC7D,GAAA;AACJ,EAAU;;AAEV;AACA,MAAMuD,WAAW,GAAGtC,kCAAc,CAACuC,SAAS,CAACjC,iBAAiB,CAAC,CAAA;MAElDG,KAAK,GAAGA,CAAC3B,MAAc,EAAEC,KAAW,KAAU;AACvD,EAAA,MAAMyD,iBAAiB,GAAG1D,MAAM,GAAG,MAAM,CAAA;EAEzC,OAAOwD,WAAW,CAACE,iBAAiB,EAAE;AAClC,IAAA,GAAGzD,KAAK;AACRI,IAAAA,MAAM,EAAE,KAAA;AACZ,GAAC,CAAC,CAAA;AACN;;;;;;"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Adds the given perseus library version information to the __perseus_debug__
3
+ * object and ensures that the object is attached to `globalThis` (`window` in
4
+ * browser environments).
5
+ *
6
+ * This allows each library to provide runtime version information to assist in
7
+ * debugging in production environments.
8
+ */
9
+ export declare const addLibraryVersionToPerseusDebug: (libraryName: string, libraryVersion: string) => void;
package/package.json CHANGED
@@ -1,35 +1,31 @@
1
1
  {
2
- "name": "@khanacademy/pure-markdown",
3
- "description": "SimpleMarkdown instance with non-react Perseus rules",
4
- "author": "Khan Academy",
5
- "license": "MIT",
6
- "version": "0.3.26",
7
- "publishConfig": {
8
- "access": "public"
9
- },
10
- "repository": {
11
- "type": "git",
12
- "url": "https://github.com/Khan/perseus.git",
13
- "directory": "packages/pure-markdown"
14
- },
15
- "bugs": {
16
- "url": "https://github.com/Khan/perseus/issues"
17
- },
18
- "module": "dist/es/index.js",
19
- "main": "dist/index.js",
20
- "source": "src/index.ts",
21
- "files": [
22
- "dist"
23
- ],
24
- "scripts": {
25
- "prepublishOnly": "../../utils/package-pre-publish-check.sh",
26
- "test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'"
27
- },
28
- "dependencies": {
29
- "@khanacademy/perseus-core": "3.6.0",
30
- "@khanacademy/simple-markdown": "^0.13.19"
31
- },
32
- "devDependencies": {},
33
- "peerDependencies": {},
34
- "keywords": []
2
+ "name": "@khanacademy/pure-markdown",
3
+ "description": "SimpleMarkdown instance with non-react Perseus rules",
4
+ "author": "Khan Academy",
5
+ "license": "MIT",
6
+ "version": "0.4.0",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/Khan/perseus.git",
13
+ "directory": "packages/pure-markdown"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/Khan/perseus/issues"
17
+ },
18
+ "module": "dist/es/index.js",
19
+ "main": "dist/index.js",
20
+ "source": "src/index.ts",
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "dependencies": {
25
+ "@khanacademy/simple-markdown": "0.14.0"
26
+ },
27
+ "devDependencies": {},
28
+ "peerDependencies": {},
29
+ "keywords": [],
30
+ "scripts": {}
35
31
  }