@khanacademy/pure-markdown 2.0.2 → 2.0.3
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/es/index.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/dist/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { addLibraryVersionToPerseusDebug } from '@khanacademy/perseus-utils';
|
|
2
2
|
import SimpleMarkdown from '@khanacademy/simple-markdown';
|
|
3
3
|
|
|
4
|
-
const libName="@khanacademy/pure-markdown";const libVersion="2.0.
|
|
4
|
+
const libName="@khanacademy/pure-markdown";const libVersion="2.0.3";addLibraryVersionToPerseusDebug(libName,libVersion);
|
|
5
5
|
|
|
6
6
|
const rWidgetRule=/^\[\[\u2603 (([a-z-]+) ([0-9]+))\]\]/;const mathMatcher=(source,state,isBlock)=>{const length=source.length;let index=0;if(isBlock){if(state.inline){return null}while(index<length&&source[index]===" "){index++;}}if(!(index<length&&source[index]==="$")){return null}index++;const startIndex=index;let braceLevel=0;while(index<length){const character=source[index];if(character==="\\"){index++;}else if(braceLevel<=0&&character==="$"){let endIndex=index+1;if(isBlock){const match=/^(?: *\n){2,}/.exec(source.slice(endIndex));endIndex=match?endIndex+match[0].length:null;}if(endIndex){return [source.substring(0,endIndex),source.substring(startIndex,index)]}return null}else if(character==="{"){braceLevel++;}else if(character==="}"){braceLevel--;}else if(character==="\n"&&source[index-1]==="\n"){return null}index++;}return null};const mathMatch=(source,state)=>mathMatcher(source,state,false);const blockMathMatch=(source,state)=>mathMatcher(source,state,true);const TITLED_TABLE_REGEX=new RegExp("^\\|\\| +(.*) +\\|\\| *\\n"+"("+SimpleMarkdown.defaultRules.nptable.match.regex.source.substring(1)+")");const crowdinJiptMatcher=SimpleMarkdown.blockRegex(/^(crwdns.*)\n\s*\n/);const pureMarkdownRules={...SimpleMarkdown.defaultRules,columns:{order:-2,match:SimpleMarkdown.blockRegex(/^([\s\S]*\n\n)={5,}\n\n([\s\S]*)/),parse:(capture,parse,state)=>{return {col1:parse(capture[1],state),col2:parse(capture[2],state)}}},crowdinId:{order:-1,match:(source,state,prevCapture)=>{if(state.isJipt){return crowdinJiptMatcher(source,state,prevCapture)}return null},parse:(capture,parse,state)=>({id:capture[1]})},titledTable:{order:SimpleMarkdown.defaultRules.nptable.order-.5,match:SimpleMarkdown.blockRegex(TITLED_TABLE_REGEX),parse:(capture,parse,state)=>{const title=SimpleMarkdown.parseInline(parse,capture[1],state);const tableCapture=capture.slice(2);const table=SimpleMarkdown.defaultRules.nptable.parse(tableCapture,parse,state);return {title:title,table:table}}},widget:{order:SimpleMarkdown.defaultRules.link.order-.75,match:SimpleMarkdown.inlineRegex(rWidgetRule),parse:(capture,parse,state)=>{return {id:capture[1],widgetType:capture[2]}}},blockMath:{order:SimpleMarkdown.defaultRules.codeBlock.order+.5,match:blockMathMatch,parse:(capture,parse,state)=>{return {content:capture[1]}}},math:{order:SimpleMarkdown.defaultRules.link.order-.25,match:mathMatch,parse:(capture,parse,state)=>{return {content:capture[1]}}},unescapedDollar:{order:SimpleMarkdown.defaultRules.link.order-.24,match:SimpleMarkdown.inlineRegex(/^(?!\\)\$/),parse:(capture,parse,state)=>{return {}}},fence:{...SimpleMarkdown.defaultRules.fence,parse:(capture,parse,state)=>{const node=SimpleMarkdown.defaultRules.fence.parse(capture,parse,state);if(node.lang==="alt"){return {type:"codeBlock",lang:"alt",content:parse(node.content+"\n\n",state)}}return node}},blockQuote:{...SimpleMarkdown.defaultRules.blockQuote,match:SimpleMarkdown.blockRegex(/^ *>[^\n]+(\n( *>)?[^\n]+)*\n{2,}/)},lint:{order:1e3,match:s=>null,parse:(capture,parse,state)=>({})}};const builtParser=SimpleMarkdown.parserFor(pureMarkdownRules);const parse=(source,state)=>{const paragraphedSource=source+"\n\n";return builtParser(paragraphedSource,{...state,inline:false})};
|
|
7
7
|
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
9
|
|
|
10
10
|
var SimpleMarkdown__default = /*#__PURE__*/_interopDefaultCompat(SimpleMarkdown);
|
|
11
11
|
|
|
12
|
-
const libName="@khanacademy/pure-markdown";const libVersion="2.0.
|
|
12
|
+
const libName="@khanacademy/pure-markdown";const libVersion="2.0.3";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
|
|
13
13
|
|
|
14
14
|
const rWidgetRule=/^\[\[\u2603 (([a-z-]+) ([0-9]+))\]\]/;const mathMatcher=(source,state,isBlock)=>{const length=source.length;let index=0;if(isBlock){if(state.inline){return null}while(index<length&&source[index]===" "){index++;}}if(!(index<length&&source[index]==="$")){return null}index++;const startIndex=index;let braceLevel=0;while(index<length){const character=source[index];if(character==="\\"){index++;}else if(braceLevel<=0&&character==="$"){let endIndex=index+1;if(isBlock){const match=/^(?: *\n){2,}/.exec(source.slice(endIndex));endIndex=match?endIndex+match[0].length:null;}if(endIndex){return [source.substring(0,endIndex),source.substring(startIndex,index)]}return null}else if(character==="{"){braceLevel++;}else if(character==="}"){braceLevel--;}else if(character==="\n"&&source[index-1]==="\n"){return null}index++;}return null};const mathMatch=(source,state)=>mathMatcher(source,state,false);const blockMathMatch=(source,state)=>mathMatcher(source,state,true);const TITLED_TABLE_REGEX=new RegExp("^\\|\\| +(.*) +\\|\\| *\\n"+"("+SimpleMarkdown__default.default.defaultRules.nptable.match.regex.source.substring(1)+")");const crowdinJiptMatcher=SimpleMarkdown__default.default.blockRegex(/^(crwdns.*)\n\s*\n/);const pureMarkdownRules={...SimpleMarkdown__default.default.defaultRules,columns:{order:-2,match:SimpleMarkdown__default.default.blockRegex(/^([\s\S]*\n\n)={5,}\n\n([\s\S]*)/),parse:(capture,parse,state)=>{return {col1:parse(capture[1],state),col2:parse(capture[2],state)}}},crowdinId:{order:-1,match:(source,state,prevCapture)=>{if(state.isJipt){return crowdinJiptMatcher(source,state,prevCapture)}return null},parse:(capture,parse,state)=>({id:capture[1]})},titledTable:{order:SimpleMarkdown__default.default.defaultRules.nptable.order-.5,match:SimpleMarkdown__default.default.blockRegex(TITLED_TABLE_REGEX),parse:(capture,parse,state)=>{const title=SimpleMarkdown__default.default.parseInline(parse,capture[1],state);const tableCapture=capture.slice(2);const table=SimpleMarkdown__default.default.defaultRules.nptable.parse(tableCapture,parse,state);return {title:title,table:table}}},widget:{order:SimpleMarkdown__default.default.defaultRules.link.order-.75,match:SimpleMarkdown__default.default.inlineRegex(rWidgetRule),parse:(capture,parse,state)=>{return {id:capture[1],widgetType:capture[2]}}},blockMath:{order:SimpleMarkdown__default.default.defaultRules.codeBlock.order+.5,match:blockMathMatch,parse:(capture,parse,state)=>{return {content:capture[1]}}},math:{order:SimpleMarkdown__default.default.defaultRules.link.order-.25,match:mathMatch,parse:(capture,parse,state)=>{return {content:capture[1]}}},unescapedDollar:{order:SimpleMarkdown__default.default.defaultRules.link.order-.24,match:SimpleMarkdown__default.default.inlineRegex(/^(?!\\)\$/),parse:(capture,parse,state)=>{return {}}},fence:{...SimpleMarkdown__default.default.defaultRules.fence,parse:(capture,parse,state)=>{const node=SimpleMarkdown__default.default.defaultRules.fence.parse(capture,parse,state);if(node.lang==="alt"){return {type:"codeBlock",lang:"alt",content:parse(node.content+"\n\n",state)}}return node}},blockQuote:{...SimpleMarkdown__default.default.defaultRules.blockQuote,match:SimpleMarkdown__default.default.blockRegex(/^ *>[^\n]+(\n( *>)?[^\n]+)*\n{2,}/)},lint:{order:1e3,match:s=>null,parse:(capture,parse,state)=>({})}};const builtParser=SimpleMarkdown__default.default.parserFor(pureMarkdownRules);const parse=(source,state)=>{const paragraphedSource=source+"\n\n";return builtParser(paragraphedSource,{...state,inline:false})};
|
|
15
15
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "SimpleMarkdown instance with non-react Perseus rules",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "2.0.
|
|
6
|
+
"version": "2.0.3",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@khanacademy/perseus-utils": "2.0.
|
|
26
|
-
"@khanacademy/simple-markdown": "2.0.
|
|
25
|
+
"@khanacademy/perseus-utils": "2.0.2",
|
|
26
|
+
"@khanacademy/simple-markdown": "2.0.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"perseus-build-settings": "0.6.1"
|