diff --git a/static/css/markdown.css b/static/css/markdown.css
new file mode 100644
index 0000000..8b4c97e
--- /dev/null
+++ b/static/css/markdown.css
@@ -0,0 +1,71 @@
+.el-node-markdown {
+ h1 {
+ border-bottom: 1px solid #ccc;
+ margin-top: 32px;
+ margin-bottom: 8px;
+
+ display: inline-block;
+ font-size: 1.25em;
+
+ border-radius: 8px;
+ color: #fff;
+ background-color: var(--color1);
+ padding: 4px 12px;
+
+ &:first-child {
+ margin-top: 32px;
+ }
+ }
+
+ h2 {
+ font-size: 1.25em;
+ margin-bottom: 0px;
+ color: var(--color1);
+ }
+
+ h3:before {
+ font-size: 1.0em;
+ content: "> ";
+ color: var(--color1);
+ }
+
+ img {
+ max-width: var(--thumbnail-width);
+ max-height: var(--thumbnail-height);
+ }
+
+ table {
+ border: 1px solid #ccc;
+ border-collapse: collapse;
+
+ th {
+ text-align: left;
+ padding: 8px;
+ }
+
+ th,
+ td {
+ border: 1px solid #ccc;
+ padding: 8px;
+ }
+ }
+
+ code {
+ background-color: #f8f8f8;
+ border: 1px solid #ccc;
+ padding: 2px 4px;
+ border-radius: 4px;
+ }
+
+ pre {
+ background-color: #f8f8f8;
+ border: 1px solid #ccc;
+ padding: 8px;
+ border-radius: 4px;
+
+ code {
+ border: unset;
+ padding: unset;
+ }
+ }
+}
diff --git a/static/css/notes2.css b/static/css/notes2.css
index e6d0ef6..477b05a 100644
--- a/static/css/notes2.css
+++ b/static/css/notes2.css
@@ -2,6 +2,8 @@
:root {
--content-width: 900px;
+ --thumbnail-width: 300px;
+ --thumbnail-height: 100px;
}
html {
@@ -13,17 +15,13 @@ html {
display: grid;
grid-template-areas:
- "tree crumbs"
- "tree name"
- "tree sync"
- "tree content"
- /*
- "tree checklist"
- "tree files"
- */
- "tree blank"
+ "tree hum crumbs crumbs ding"
+ "tree hum name name ding"
+ "tree hum sync functions ding"
+ "tree hum content content ding"
+ "tree hum blank blank ding"
;
- grid-template-columns: min-content 1fr;
+ grid-template-columns: min-content minmax(16px, 1fr) minmax(min-content, 820px) 80px minmax(16px, 1fr);
grid-template-rows:
min-content min-content 48px 1fr;
@@ -34,10 +32,6 @@ html {
"sync"
"name"
"content"
- /*
- "checklist"
- "files"
- */
"blank"
;
grid-template-columns: 1fr;
@@ -61,13 +55,20 @@ html {
padding: 16px 0px 16px 16px;
color: #ddd;
z-index: 100;
- /* Over crumbs shadow */
border-left: 2px solid #333;
- &:focus {
- border-left: 2px solid #FE5F55;
+ n2-tree {
+ border: 2px solid #333;
}
+ &:focus-within {
+ n2-tree {
+ border: 2px solid #fe5f55;
+ }
+
+ }
+
+
#logo {
display: grid;
position: relative;
@@ -151,7 +152,7 @@ html {
align-items: start;
justify-items: center;
height: min-content;
- margin: 16px 16px;
+ margin: 0 16px 16px 16px;
n2-crumbs {
background: #e4e4e4;
@@ -223,8 +224,7 @@ n2-syncprogress {
}
progress {
- width: calc(100% - 32px);
- max-width: var(--content-width);
+ width: 100%;
height: 24px;
border-radius: 8px;
}
@@ -272,6 +272,7 @@ n2-nodeui {
margin-bottom: 32px;
.el-name {
+ grid-area: name;
color: #333;
font-weight: bold;
text-align: center;
@@ -280,27 +281,27 @@ n2-nodeui {
margin-bottom: 0px;
}
+ .el-functions {
+ grid-area: functions;
+ }
+
.el-node-content {
+ grid-area: content;
justify-self: center;
word-wrap: break-word;
font-family: monospace;
color: #333;
- /*
width: 100%;
max-width: var(--content-width);
field-sizing: content;
- */
-
- width: calc(100% - 32px);
- max-width: var(--content-width);
- field-sizing: content;
resize: none;
- border: none;
outline: none;
- padding: 16px 0;
+ padding: 32px 0;
+ border-left: none;
+ border-right: none;
border-top: 1px solid #e0e0e0;
border-bottom: 1px solid #e0e0e0;
margin-bottom: 32px;
@@ -310,6 +311,25 @@ n2-nodeui {
padding-top: 16px;
}
}
+
+ .el-node-markdown {
+ grid-area: content;
+ display: none;
+
+ border-top: 1px solid #e0e0e0;
+ border-bottom: 1px solid #e0e0e0;
+ margin-bottom: 32px;
+ }
+
+ &.show-markdown {
+ .el-node-content {
+ display: none;
+ }
+
+ .el-node-markdown {
+ display: block;
+ }
+ }
}
#blank {
diff --git a/static/images/icon_markdown.svg b/static/images/icon_markdown.svg
new file mode 100644
index 0000000..f8d0aae
--- /dev/null
+++ b/static/images/icon_markdown.svg
@@ -0,0 +1,57 @@
+
+
+
+
diff --git a/static/images/icon_markdown_hollow.svg b/static/images/icon_markdown_hollow.svg
new file mode 100644
index 0000000..d938c6f
--- /dev/null
+++ b/static/images/icon_markdown_hollow.svg
@@ -0,0 +1,50 @@
+
+
diff --git a/static/images/icon_save.svg b/static/images/icon_save.svg
new file mode 100644
index 0000000..0846a73
--- /dev/null
+++ b/static/images/icon_save.svg
@@ -0,0 +1,49 @@
+
+
+
+
diff --git a/static/images/icon_save_disabled.svg b/static/images/icon_save_disabled.svg
new file mode 100644
index 0000000..907cee6
--- /dev/null
+++ b/static/images/icon_save_disabled.svg
@@ -0,0 +1,49 @@
+
+
+
+
diff --git a/static/js/app.mjs b/static/js/app.mjs
index 45cd85b..7fa4dda 100644
--- a/static/js/app.mjs
+++ b/static/js/app.mjs
@@ -55,10 +55,12 @@ export class App {
switch (event.key.toUpperCase()) {
case 'T':
- if (document.activeElement.id === 'tree-nodes')
- this.nodeUI.takeFocus()
- else
+ if (document.activeElement.id === 'tree-nodes') {
+ console.log('take focus')
this.nodeUI.takeFocus()
+ } else {
+ this.tree.focus()
+ }
break
case 'F':
@@ -72,12 +74,12 @@ export class App {
case 'E':
this.showPage('keys')
break
+ */
case 'M':
- this.toggleMarkdown()
+ globalThis._mbus.dispatch('MARKDOWN_TOGGLE')
break
- */
case 'N':
this.createNode()
break
diff --git a/static/js/lib/node_modules/.package-lock.json b/static/js/lib/node_modules/.package-lock.json
index 441fdf4..3d3d164 100644
--- a/static/js/lib/node_modules/.package-lock.json
+++ b/static/js/lib/node_modules/.package-lock.json
@@ -4,14 +4,24 @@
"requires": true,
"packages": {
"node_modules/marked": {
- "version": "11.1.1",
- "resolved": "https://registry.npmjs.org/marked/-/marked-11.1.1.tgz",
- "integrity": "sha512-EgxRjgK9axsQuUa/oKMx5DEY8oXpKJfk61rT5iY3aRlgU6QJtUcxU5OAymdhCvWvhYcd9FKmO5eQoX8m9VGJXg==",
+ "version": "18.0.3",
+ "resolved": "https://registry.npmjs.org/marked/-/marked-18.0.3.tgz",
+ "integrity": "sha512-7VT90JOkDeaRWpfjOReRGPEKn0ecdARBkDGL+tT1wZY0efPPqkUxLUSmzy/C7TIylQYJC9STISEsCHrqb/7VIA==",
+ "license": "MIT",
"bin": {
"marked": "bin/marked.js"
},
"engines": {
- "node": ">= 18"
+ "node": ">= 20"
+ }
+ },
+ "node_modules/marked-token-position": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/marked-token-position/-/marked-token-position-2.0.2.tgz",
+ "integrity": "sha512-IMyr4mR3A5uFReXn7cxLDgDLjefG110ANy0oMGs5+gB7NsdIbv9YoVoJuGxuMSFHWOeIFkAzjdSoFNVKcMPfZw==",
+ "license": "MIT",
+ "peerDependencies": {
+ "marked": ">=16.2.0 <19"
}
},
"node_modules/preact": {
diff --git a/static/js/lib/node_modules/marked-token-position/LICENSE b/static/js/lib/node_modules/marked-token-position/LICENSE
new file mode 100644
index 0000000..5d36390
--- /dev/null
+++ b/static/js/lib/node_modules/marked-token-position/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2025 @UziTech
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/static/js/lib/node_modules/marked-token-position/README.md b/static/js/lib/node_modules/marked-token-position/README.md
new file mode 100644
index 0000000..a10f43c
--- /dev/null
+++ b/static/js/lib/node_modules/marked-token-position/README.md
@@ -0,0 +1,160 @@
+# marked-token-position
+
+Add `position` field for each token.
+
+```ts
+interface Position {
+ /**
+ * Positions for each line of the token. LinePositions will not include the newline character for the line.
+ */
+ lines: LinePosition[]
+ /**
+ * Position at the beginning of token
+ */
+ start: PositionFields;
+ /**
+ * Position at the end of token
+ */
+ end: PositionFields;
+}
+
+interface LinePosition {
+ /**
+ * Position at the beginning of line
+ */
+ start: PositionFields;
+ /**
+ * Position at the end of line. Will not include the newline character.
+ */
+ end: PositionFields;
+}
+
+interface PositionFields {
+ /**
+ * Number of characters from the beginning of the markdown string
+ */
+ offset: number;
+ /**
+ * Line number of the token. Starts at line 0.
+ */
+ line: number;
+ /**
+ * Column number of the token. Starts at column 0.
+ */
+ column: number;
+}
+```
+
+# Usage
+
+## Extension
+
+```js
+import {Marked} from "marked";
+import markedTokenPosition from "marked-token-position";
+
+// or UMD script
+//
+//
+// const Marked = marked.Marked;
+
+const marked = new Marked();
+
+function anotherExtension {
+ return {
+ walkTokens(token) {
+ // token has `position` field
+ }
+ hooks: {
+ processAllTokens(tokens) {
+ // tokens have `position` field
+ }
+ }
+ };
+}
+
+marked.use(anotherExtension(), markedTokenPosition());
+
+marked.parse("# example markdown");
+```
+
+The `position` field will be added to the tokens so any other extension can
+use the `position` field in a `walkTokens` function or `processAllTokens` hook.
+
+> [!CAUTION]
+> The `processAllTokens` hook is used by this extension so any other extension
+> using `processAllTokens` that requires the `position` field must be added
+> before this extension because marked calls the `processAllTokens` hooks in
+> reverse order.
+
+The tokens will look like:
+
+```json
+[
+ {
+ "type": "heading",
+ "raw": "# example markdown",
+ "depth": 1,
+ "text": "example markdown",
+ "tokens": [
+ {
+ "type": "text",
+ "raw": "example markdown",
+ "text": "example markdown",
+ "escaped": false,
+ "position": {
+ "start": {
+ "offset": 2,
+ "line": 0,
+ "column": 2
+ },
+ "end": {
+ "offset": 18,
+ "line": 0,
+ "column": 18
+ }
+ }
+ }
+ ],
+ "position": {
+ "start": {
+ "offset": 0,
+ "line": 0,
+ "column": 0
+ },
+ "end": {
+ "offset": 18,
+ "line": 0,
+ "column": 18
+ }
+ }
+ }
+]
+```
+
+## addTokenPositions
+
+Calling `marked.lexer()` will not add the `position` field with the extension
+since the extension is only called on `marked.parse()` and `marked.parseInline()`.
+
+An `addTokenPositions` function is exported to add the `position` field to the
+tokens returned by `marked.lexer()`.
+
+```js
+import {Marked} from "marked";
+import {addTokenPositions} from "marked-token-position";
+
+// or UMD script
+//
+//
+// const Marked = marked.Marked;
+// const addTokenPositions = markedTokenPosition.addTokenPositions;
+
+
+const marked = new Marked();
+const tokens = marked.lexer("# example markdown");
+
+addTokenPositions(tokens);
+
+// tokens now have a `position` field
+```
diff --git a/static/js/lib/node_modules/marked-token-position/lib/index.d.ts b/static/js/lib/node_modules/marked-token-position/lib/index.d.ts
new file mode 100644
index 0000000..f61cd65
--- /dev/null
+++ b/static/js/lib/node_modules/marked-token-position/lib/index.d.ts
@@ -0,0 +1,59 @@
+// Generated by dts-bundle-generator v9.5.1
+
+import { MarkedExtension, Token, Tokens } from 'marked';
+
+export interface TokenWithPosition extends Tokens.Generic {
+ position: Position;
+}
+export interface Position {
+ /**
+ * Positions for each line of the token. LinePositions will not include the newline character for the line.
+ */
+ lines: LinePosition[];
+ /**
+ * Position at the beginning of token
+ */
+ start: PositionFields;
+ /**
+ * Position at the end of token
+ */
+ end: PositionFields;
+}
+export interface LinePosition {
+ /**
+ * Position at the beginning of line
+ */
+ start: PositionFields;
+ /**
+ * Position at the end of line. Will not include the newline character.
+ */
+ end: PositionFields;
+}
+export interface PositionFields {
+ /**
+ * Number of characters from the beginning of the markdown string
+ */
+ offset: number;
+ /**
+ * Line number of the token. Starts at line 0.
+ */
+ line: number;
+ /**
+ * Column number of the token. Starts at column 0.
+ */
+ column: number;
+}
+/**
+ * Add position field to tokens
+ */
+export declare function addTokenPositions(tokens: Token[]): TokenWithPosition[];
+/**
+ * Marked extension to add position field to tokens
+ */
+declare function _default(options?: {}): MarkedExtension;
+
+export {
+ _default as default,
+};
+
+export {};
diff --git a/static/js/lib/node_modules/marked-token-position/lib/index.esm.js b/static/js/lib/node_modules/marked-token-position/lib/index.esm.js
new file mode 100644
index 0000000..41a85f7
--- /dev/null
+++ b/static/js/lib/node_modules/marked-token-position/lib/index.esm.js
@@ -0,0 +1,6 @@
+function g(u){let i=u.map(r=>r.raw).join("");return h(u,0,0,0,i).tokens}function b(u={}){return{hooks:{processAllTokens(i){return g(i)}}}}function h(u,i,r,f,l){for(let s of u){let n=s,a=T(i,r,f,l,n.raw);if(n.position=a,n.tokens&&h(n.tokens,i,r,f,l),n.childTokens){let c=i,t=r,e=f,d=l;for(let k of n.childTokens){let o=h(n[k],c,t,e,d);c=o.offset,t=o.line,e=o.column,d=o.markdown}}if(n.type==="list"&&h(n.items,i,r,f,l),n.type==="table"){let c=i,t=r,e=f,d=l;for(let k of n.header){let o=h(k.tokens,c,t,e,d);c=o.offset,t=o.line,e=o.column,d=o.markdown}for(let k of n.rows)for(let o of k){let P=h(o.tokens,c,t,e,d);c=P.offset,t=P.line,e=P.column,d=P.markdown}}let m=a.end.offset-i;i=a.end.offset,r=a.end.line,f=a.end.column,l=l.slice(m)}return{tokens:u,offset:i,line:r,column:f,markdown:l}}function T(u,i,r,f,l){let s=[],n=l.split(`
+`),a=f.split(`
+`);n:for(let t=0;t<=a.length-n.length;t++){s=[];for(let e=0;e0?`
+`:""),x={offset:u+P.length+o,line:i+t+e,column:(t+e===0?r:0)+o},p={offset:x.offset+k.length,line:x.line,column:x.column+k.length};s.push({start:x,end:p})}break}if(s.length===0)throw new Error(`Cannot find ${JSON.stringify(l)} in ${JSON.stringify(f)}`);let m=s[0].start,c=s.at(-1).end;return s.length>1&&s.at(-1).start.offset===c.offset&&(s=s.slice(0,-1)),{lines:s,start:m,end:c}}export{g as addTokenPositions,b as default};
+//# sourceMappingURL=index.esm.js.map
diff --git a/static/js/lib/node_modules/marked-token-position/lib/index.esm.js.map b/static/js/lib/node_modules/marked-token-position/lib/index.esm.js.map
new file mode 100644
index 0000000..4eb0539
--- /dev/null
+++ b/static/js/lib/node_modules/marked-token-position/lib/index.esm.js.map
@@ -0,0 +1,7 @@
+{
+ "version": 3,
+ "sources": ["../src/index.ts"],
+ "sourcesContent": ["/* node:coverage ignore next */\nimport type { MarkedExtension, Token, Tokens } from 'marked';\n\nexport interface TokenWithPosition extends Tokens.Generic {\n position: Position;\n}\ninterface Position {\n /**\n * Positions for each line of the token. LinePositions will not include the newline character for the line.\n */\n lines: LinePosition[]\n /**\n * Position at the beginning of token\n */\n start: PositionFields;\n /**\n * Position at the end of token\n */\n end: PositionFields;\n}\n\ninterface LinePosition {\n /**\n * Position at the beginning of line\n */\n start: PositionFields;\n /**\n * Position at the end of line. Will not include the newline character.\n */\n end: PositionFields;\n}\n\ninterface PositionFields {\n /**\n * Number of characters from the beginning of the markdown string\n */\n offset: number;\n /**\n * Line number of the token. Starts at line 0.\n */\n line: number;\n /**\n * Column number of the token. Starts at column 0.\n */\n column: number;\n}\n\n/**\n * Add position field to tokens\n */\nexport function addTokenPositions(tokens: Token[]) {\n const markdown = tokens.map(token => token.raw).join('');\n return addPosition(tokens, 0, 0, 0, markdown).tokens;\n}\n\n/**\n * Marked extension to add position field to tokens\n */\nexport default function(options = {}): MarkedExtension {\n return {\n hooks: {\n processAllTokens(tokens) {\n return addTokenPositions(tokens);\n },\n },\n };\n}\n\nfunction addPosition(tokens: Token[], offset: number, line: number, column: number, markdown: string) {\n for (const token of tokens) {\n const genericToken = token as Tokens.Generic;\n const position = getPosition(offset, line, column, markdown, genericToken.raw);\n genericToken.position = position;\n\n if (genericToken.tokens) {\n addPosition(genericToken.tokens, offset, line, column, markdown);\n }\n\n if (genericToken.childTokens) {\n let nextOffset = offset;\n let nextLine = line;\n let nextColumn = column;\n let nextMarkdown = markdown;\n for (const childToken of genericToken.childTokens) {\n const nextPosition = addPosition(genericToken[childToken], nextOffset, nextLine, nextColumn, nextMarkdown);\n nextOffset = nextPosition.offset;\n nextLine = nextPosition.line;\n nextColumn = nextPosition.column;\n nextMarkdown = nextPosition.markdown;\n }\n }\n\n if (genericToken.type === 'list') {\n addPosition(genericToken.items, offset, line, column, markdown);\n }\n\n if (genericToken.type === 'table') {\n let nextOffset = offset;\n let nextLine = line;\n let nextColumn = column;\n let nextMarkdown = markdown;\n for (const headerCell of genericToken.header) {\n const nextPosition = addPosition(headerCell.tokens, nextOffset, nextLine, nextColumn, nextMarkdown);\n nextOffset = nextPosition.offset;\n nextLine = nextPosition.line;\n nextColumn = nextPosition.column;\n nextMarkdown = nextPosition.markdown;\n }\n for (const row of genericToken.rows) {\n for (const rowCell of row) {\n const nextPosition = addPosition(rowCell.tokens, nextOffset, nextLine, nextColumn, nextMarkdown);\n nextOffset = nextPosition.offset;\n nextLine = nextPosition.line;\n nextColumn = nextPosition.column;\n nextMarkdown = nextPosition.markdown;\n }\n }\n }\n\n const deltaOffset = position.end.offset - offset;\n offset = position.end.offset;\n line = position.end.line;\n column = position.end.column;\n markdown = markdown.slice(deltaOffset);\n }\n\n return {\n tokens: tokens as TokenWithPosition[],\n offset,\n line,\n column,\n markdown,\n };\n}\n\nfunction getPosition(offset: number, line: number, column: number, markdown: string, raw: string): Position {\n let lines: LinePosition[] = [];\n const rawLines = raw.split('\\n');\n const markdownLines = markdown.split('\\n');\n\n // eslint-disable-next-line no-labels\n md: for (let i = 0; i <= markdownLines.length - rawLines.length; i++) {\n lines = [];\n for (let j = 0; j < rawLines.length; j++) {\n const markdownLine = markdownLines[i + j];\n const rawLine = rawLines[j];\n const lineStartOffset = markdownLine.indexOf(rawLine);\n\n if (lineStartOffset === -1) {\n // eslint-disable-next-line no-labels\n continue md;\n }\n\n const beforeMarkdownLines = markdownLines.slice(0, i + j).join('\\n') + (i + j > 0 ? '\\n' : '');\n const start = {\n offset: offset + beforeMarkdownLines.length + lineStartOffset,\n line: line + i + j,\n column: (i + j === 0 ? column : 0) + lineStartOffset,\n };\n const end = {\n offset: start.offset + rawLine.length,\n line: start.line,\n column: start.column + rawLine.length,\n };\n\n lines.push({\n start,\n end,\n });\n }\n break;\n }\n\n /* node:coverage ignore next 4 */\n if (lines.length === 0) {\n // This shouldn't ever happen but if it does it would be nice to have a good error message\n throw new Error(`Cannot find ${JSON.stringify(raw)} in ${JSON.stringify(markdown)}`);\n }\n\n const start = lines[0].start;\n const end = lines.at(-1)!.end;\n\n if (lines.length > 1 && lines.at(-1)!.start.offset === end.offset) {\n lines = lines.slice(0, -1);\n }\n\n return {\n lines,\n start,\n end,\n };\n}\n"],
+ "mappings": "AAkDO,SAASA,EAAkBC,EAAiB,CACjD,IAAMC,EAAWD,EAAO,IAAIE,GAASA,EAAM,GAAG,EAAE,KAAK,EAAE,EACvD,OAAOC,EAAYH,EAAQ,EAAG,EAAG,EAAGC,CAAQ,EAAE,MAChD,CAKe,SAARG,EAAiBC,EAAU,CAAC,EAAoB,CACrD,MAAO,CACL,MAAO,CACL,iBAAiBL,EAAQ,CACvB,OAAOD,EAAkBC,CAAM,CACjC,CACF,CACF,CACF,CAEA,SAASG,EAAYH,EAAiBM,EAAgBC,EAAcC,EAAgBP,EAAkB,CACpG,QAAWC,KAASF,EAAQ,CAC1B,IAAMS,EAAeP,EACfQ,EAAWC,EAAYL,EAAQC,EAAMC,EAAQP,EAAUQ,EAAa,GAAG,EAO7E,GANAA,EAAa,SAAWC,EAEpBD,EAAa,QACfN,EAAYM,EAAa,OAA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B,CAAC,EACvBC,EAAWF,EAAI,MAAM;AAAA,CAAI,EACzBG,EAAgBxB,EAAS,MAAM;AAAA,CAAI,EAGzCyB,EAAI,QAASC,EAAI,EAAGA,GAAKF,EAAc,OAASD,EAAS,OAAQG,IAAK,CACpEJ,EAAQ,CAAC,EACT,QAASK,EAAI,EAAGA,EAAIJ,EAAS,OAAQI,IAAK,CACxC,IAAMC,EAAeJ,EAAcE,EAAIC,CAAC,EAClCE,EAAUN,EAASI,CAAC,EACpBG,EAAkBF,EAAa,QAAQC,CAAO,EAEpD,GAAIC,IAAoB,GAEtB,SAASL,EAGX,IAAMM,EAAsBP,EAAc,MAAM,EAAGE,EAAIC,CAAC,EAAE,KAAK;AAAA,CAAI,GAAKD,EAAIC,EAAI,EAAI;AAAA,EAAO,IACrFK,EAAQ,CACZ,OAAQ3B,EAAS0B,EAAoB,OAASD,EAC9C,KAAMxB,EAAOoB,EAAIC,EACjB,QAASD,EAAIC,IAAM,EAAIpB,EAAS,GAAKuB,CACvC,EACMG,EAAM,CACV,OAAQD,EAAM,OAASH,EAAQ,OAC/B,KAAMG,EAAM,KACZ,OAAQA,EAAM,OAASH,EAAQ,MACjC,EAEAP,EAAM,KAAK,CACT,MAAAU,EACA,IAAAC,CACF,CAAC,CACH,CACA,KACF,CAGA,GAAIX,EAAM,SAAW,EAEnB,MAAM,IAAI,MAAM,eAAe,KAAK,UAAUD,CAAG,CAAC,OAAO,KAAK,UAAUrB,CAAQ,CAAC,EAAE,EAGrF,IAAMgC,EAAQV,EAAM,CAAC,EAAE,MACjBW,EAAMX,EAAM,GAAG,EAAE,EAAG,IAE1B,OAAIA,EAAM,OAAS,GAAKA,EAAM,GAAG,EAAE,EAAG,MAAM,SAAWW,EAAI,SACzDX,EAAQA,EAAM,MAAM,EAAG,EAAE,GAGpB,CACL,MAAAA,EACA,MAAAU,EACA,IAAAC,CACF,CACF",
+ "names": ["addTokenPositions", "tokens", "markdown", "token", "addPosition", "index_default", "options", "offset", "line", "column", "genericToken", "position", "getPosition", "nextOffset", "nextLine", "nextColumn", "nextMarkdown", "childToken", "nextPosition", "headerCell", "row", "rowCell", "deltaOffset", "raw", "lines", "rawLines", "markdownLines", "md", "i", "j", "markdownLine", "rawLine", "lineStartOffset", "beforeMarkdownLines", "start", "end"]
+}
diff --git a/static/js/lib/node_modules/marked-token-position/lib/index.umd.js b/static/js/lib/node_modules/marked-token-position/lib/index.umd.js
new file mode 100644
index 0000000..253cb7d
--- /dev/null
+++ b/static/js/lib/node_modules/marked-token-position/lib/index.umd.js
@@ -0,0 +1,9 @@
+(function(g,f){if(typeof exports=="object"&&typeof module<"u"){module.exports=f()}else if("function"==typeof define && define.amd){define("markedTokenPosition",f)}else {g["markedTokenPosition"]=f()}}(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : this,function(){var exports={};var __exports=exports;var module={exports};
+var m=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var F=(e,n)=>()=>(e&&(n=e(e=0)),n);var M=(e,n)=>{for(var o in n)m(e,o,{get:n[o],enumerable:!0})},j=(e,n,o,f)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of y(n))!C.call(e,t)&&t!==o&&m(e,t,{get:()=>n[t],enumerable:!(f=O(n,t))||f.enumerable});return e};var b=e=>j(m({},"__esModule",{value:!0}),e);var T={};M(T,{addTokenPositions:()=>L,default:()=>E});function L(e){let n=e.map(o=>o.raw).join("");return x(e,0,0,0,n).tokens}function E(e={}){return{hooks:{processAllTokens(n){return L(n)}}}}function x(e,n,o,f,t){for(let c of e){let i=c,a=S(n,o,f,t,i.raw);if(i.position=a,i.tokens&&x(i.tokens,n,o,f,t),i.childTokens){let d=n,r=o,s=f,u=t;for(let k of i.childTokens){let l=x(i[k],d,r,s,u);d=l.offset,r=l.line,s=l.column,u=l.markdown}}if(i.type==="list"&&x(i.items,n,o,f,t),i.type==="table"){let d=n,r=o,s=f,u=t;for(let k of i.header){let l=x(k.tokens,d,r,s,u);d=l.offset,r=l.line,s=l.column,u=l.markdown}for(let k of i.rows)for(let l of k){let P=x(l.tokens,d,r,s,u);d=P.offset,r=P.line,s=P.column,u=P.markdown}}let p=a.end.offset-n;n=a.end.offset,o=a.end.line,f=a.end.column,t=t.slice(p)}return{tokens:e,offset:n,line:o,column:f,markdown:t}}function S(e,n,o,f,t){let c=[],i=t.split(`
+`),a=f.split(`
+`);n:for(let r=0;r<=a.length-i.length;r++){c=[];for(let s=0;s0?`
+`:""),h={offset:e+P.length+l,line:n+r+s,column:(r+s===0?o:0)+l},w={offset:h.offset+k.length,line:h.line,column:h.column+k.length};c.push({start:h,end:w})}break}if(c.length===0)throw new Error(`Cannot find ${JSON.stringify(t)} in ${JSON.stringify(f)}`);let p=c[0].start,d=c.at(-1).end;return c.length>1&&c.at(-1).start.offset===d.offset&&(c=c.slice(0,-1)),{lines:c,start:p,end:d}}var g=F(()=>{"use strict"});module.exports=(g(),b(T)).default;module.exports.addTokenPositions=(g(),b(T)).addTokenPositions;
+
+if(__exports != exports)module.exports = exports;return module.exports}));
+//# sourceMappingURL=index.umd.js.map
diff --git a/static/js/lib/node_modules/marked-token-position/lib/index.umd.js.map b/static/js/lib/node_modules/marked-token-position/lib/index.umd.js.map
new file mode 100644
index 0000000..7894776
--- /dev/null
+++ b/static/js/lib/node_modules/marked-token-position/lib/index.umd.js.map
@@ -0,0 +1,7 @@
+{
+ "version": 3,
+ "sources": ["../src/index.ts", ""],
+ "sourcesContent": ["/* node:coverage ignore next */\nimport type { MarkedExtension, Token, Tokens } from 'marked';\n\nexport interface TokenWithPosition extends Tokens.Generic {\n position: Position;\n}\ninterface Position {\n /**\n * Positions for each line of the token. LinePositions will not include the newline character for the line.\n */\n lines: LinePosition[]\n /**\n * Position at the beginning of token\n */\n start: PositionFields;\n /**\n * Position at the end of token\n */\n end: PositionFields;\n}\n\ninterface LinePosition {\n /**\n * Position at the beginning of line\n */\n start: PositionFields;\n /**\n * Position at the end of line. Will not include the newline character.\n */\n end: PositionFields;\n}\n\ninterface PositionFields {\n /**\n * Number of characters from the beginning of the markdown string\n */\n offset: number;\n /**\n * Line number of the token. Starts at line 0.\n */\n line: number;\n /**\n * Column number of the token. Starts at column 0.\n */\n column: number;\n}\n\n/**\n * Add position field to tokens\n */\nexport function addTokenPositions(tokens: Token[]) {\n const markdown = tokens.map(token => token.raw).join('');\n return addPosition(tokens, 0, 0, 0, markdown).tokens;\n}\n\n/**\n * Marked extension to add position field to tokens\n */\nexport default function(options = {}): MarkedExtension {\n return {\n hooks: {\n processAllTokens(tokens) {\n return addTokenPositions(tokens);\n },\n },\n };\n}\n\nfunction addPosition(tokens: Token[], offset: number, line: number, column: number, markdown: string) {\n for (const token of tokens) {\n const genericToken = token as Tokens.Generic;\n const position = getPosition(offset, line, column, markdown, genericToken.raw);\n genericToken.position = position;\n\n if (genericToken.tokens) {\n addPosition(genericToken.tokens, offset, line, column, markdown);\n }\n\n if (genericToken.childTokens) {\n let nextOffset = offset;\n let nextLine = line;\n let nextColumn = column;\n let nextMarkdown = markdown;\n for (const childToken of genericToken.childTokens) {\n const nextPosition = addPosition(genericToken[childToken], nextOffset, nextLine, nextColumn, nextMarkdown);\n nextOffset = nextPosition.offset;\n nextLine = nextPosition.line;\n nextColumn = nextPosition.column;\n nextMarkdown = nextPosition.markdown;\n }\n }\n\n if (genericToken.type === 'list') {\n addPosition(genericToken.items, offset, line, column, markdown);\n }\n\n if (genericToken.type === 'table') {\n let nextOffset = offset;\n let nextLine = line;\n let nextColumn = column;\n let nextMarkdown = markdown;\n for (const headerCell of genericToken.header) {\n const nextPosition = addPosition(headerCell.tokens, nextOffset, nextLine, nextColumn, nextMarkdown);\n nextOffset = nextPosition.offset;\n nextLine = nextPosition.line;\n nextColumn = nextPosition.column;\n nextMarkdown = nextPosition.markdown;\n }\n for (const row of genericToken.rows) {\n for (const rowCell of row) {\n const nextPosition = addPosition(rowCell.tokens, nextOffset, nextLine, nextColumn, nextMarkdown);\n nextOffset = nextPosition.offset;\n nextLine = nextPosition.line;\n nextColumn = nextPosition.column;\n nextMarkdown = nextPosition.markdown;\n }\n }\n }\n\n const deltaOffset = position.end.offset - offset;\n offset = position.end.offset;\n line = position.end.line;\n column = position.end.column;\n markdown = markdown.slice(deltaOffset);\n }\n\n return {\n tokens: tokens as TokenWithPosition[],\n offset,\n line,\n column,\n markdown,\n };\n}\n\nfunction getPosition(offset: number, line: number, column: number, markdown: string, raw: string): Position {\n let lines: LinePosition[] = [];\n const rawLines = raw.split('\\n');\n const markdownLines = markdown.split('\\n');\n\n // eslint-disable-next-line no-labels\n md: for (let i = 0; i <= markdownLines.length - rawLines.length; i++) {\n lines = [];\n for (let j = 0; j < rawLines.length; j++) {\n const markdownLine = markdownLines[i + j];\n const rawLine = rawLines[j];\n const lineStartOffset = markdownLine.indexOf(rawLine);\n\n if (lineStartOffset === -1) {\n // eslint-disable-next-line no-labels\n continue md;\n }\n\n const beforeMarkdownLines = markdownLines.slice(0, i + j).join('\\n') + (i + j > 0 ? '\\n' : '');\n const start = {\n offset: offset + beforeMarkdownLines.length + lineStartOffset,\n line: line + i + j,\n column: (i + j === 0 ? column : 0) + lineStartOffset,\n };\n const end = {\n offset: start.offset + rawLine.length,\n line: start.line,\n column: start.column + rawLine.length,\n };\n\n lines.push({\n start,\n end,\n });\n }\n break;\n }\n\n /* node:coverage ignore next 4 */\n if (lines.length === 0) {\n // This shouldn't ever happen but if it does it would be nice to have a good error message\n throw new Error(`Cannot find ${JSON.stringify(raw)} in ${JSON.stringify(markdown)}`);\n }\n\n const start = lines[0].start;\n const end = lines.at(-1)!.end;\n\n if (lines.length > 1 && lines.at(-1)!.start.offset === end.offset) {\n lines = lines.slice(0, -1);\n }\n\n return {\n lines,\n start,\n end,\n };\n}\n", "\nmodule.exports = require(\"./src/index.ts\").default;\nmodule.exports.addTokenPositions = require(\"./src/index.ts\").addTokenPositions;\n"],
+ "mappings": ";+bAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA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/B,KAAMG,EAAM,KACZ,OAAQA,EAAM,OAASH,EAAQ,MACjC,EAEAP,EAAM,KAAK,CACT,MAAAU,EACA,IAAAC,CACF,CAAC,CACH,CACA,KACF,CAGA,GAAIX,EAAM,SAAW,EAEnB,MAAM,IAAI,MAAM,eAAe,KAAK,UAAUD,CAAG,CAAC,OAAO,KAAK,UAAUpB,CAAQ,CAAC,EAAE,EAGrF,IAAM+B,EAAQV,EAAM,CAAC,EAAE,MACjBW,EAAMX,EAAM,GAAG,EAAE,EAAG,IAE1B,OAAIA,EAAM,OAAS,GAAKA,EAAM,GAAG,EAAE,EAAG,MAAM,SAAWW,EAAI,SACzDX,EAAQA,EAAM,MAAM,EAAG,EAAE,GAGpB,CACL,MAAAA,EACA,MAAAU,EACA,IAAAC,CACF,CACF,CA/LA,IAAAC,EAAAC,EAAA,oBCCA,OAAO,QAAU,WAA0B,QAC3C,OAAO,QAAQ,kBAAoB,WAA0B",
+ "names": ["src_exports", "__export", "addTokenPositions", "src_default", "tokens", "markdown", "token", "addPosition", "options", "offset", "line", "column", "genericToken", "position", "getPosition", "nextOffset", "nextLine", "nextColumn", "nextMarkdown", "childToken", "nextPosition", "headerCell", "row", "rowCell", "deltaOffset", "raw", "lines", "rawLines", "markdownLines", "md", "i", "j", "markdownLine", "rawLine", "lineStartOffset", "beforeMarkdownLines", "start", "end", "init_src", "__esmMin"]
+}
diff --git a/static/js/lib/node_modules/marked-token-position/package.json b/static/js/lib/node_modules/marked-token-position/package.json
new file mode 100644
index 0000000..4f359e9
--- /dev/null
+++ b/static/js/lib/node_modules/marked-token-position/package.json
@@ -0,0 +1,66 @@
+{
+ "name": "marked-token-position",
+ "version": "2.0.2",
+ "description": "marked extension template",
+ "main": "./lib/index.esm.js",
+ "module": "./lib/index.esm.js",
+ "browser": "./lib/index.umd.js",
+ "type": "module",
+ "keywords": [
+ "marked",
+ "extension"
+ ],
+ "files": [
+ "lib/",
+ "src/"
+ ],
+ "exports": {
+ ".": {
+ "typescript": "./src/index.ts",
+ "types": "./lib/index.d.ts",
+ "default": "./lib/index.esm.js"
+ }
+ },
+ "scripts": {
+ "build": "npm run build:esbuild && npm run build:types",
+ "build:esbuild": "node esbuild.config.js",
+ "build:types": "tsc && dts-bundle-generator --export-referenced-types --project tsconfig.json -o lib/index.d.ts src/index.ts",
+ "format": "eslint --fix",
+ "lint": "eslint",
+ "test": "npm run build:esbuild && node --experimental-transform-types ./spec/test.config.js",
+ "test:cover": "npm run build:esbuild && node --experimental-transform-types --experimental-test-coverage ./spec/test.config.js -- --cover",
+ "test:only": "npm run build:esbuild && node --experimental-transform-types ./spec/test.config.js -- --only",
+ "test:types": "npm run build:types && tsc --project tsconfig-test-types.json && attw -P --entrypoints . --profile esm-only",
+ "test:update": "npm run build:esbuild && node --experimental-transform-types --test-update-snapshots ./spec/test.config.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/UziTech/marked-token-position.git"
+ },
+ "author": "Tony Brix (https://Tony.Brix.ninja)",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/UziTech/marked-token-position/issues"
+ },
+ "homepage": "https://github.com/UziTech/marked-token-position#readme",
+ "peerDependencies": {
+ "marked": ">=16.2.0 <19"
+ },
+ "devDependencies": {
+ "@arethetypeswrong/cli": "^0.18.2",
+ "@markedjs/eslint-config": "^1.0.14",
+ "@semantic-release/changelog": "^6.0.3",
+ "@semantic-release/commit-analyzer": "^13.0.1",
+ "@semantic-release/git": "^10.0.1",
+ "@semantic-release/github": "^12.0.6",
+ "@semantic-release/npm": "^13.1.5",
+ "@semantic-release/release-notes-generator": "^14.1.0",
+ "dts-bundle-generator": "^9.5.1",
+ "esbuild": "^0.28.0",
+ "esbuild-plugin-umd-wrapper": "^3.0.0",
+ "eslint": "^10.2.0",
+ "marked": "^18.0.0",
+ "semantic-release": "^25.0.3",
+ "typescript": "^6.0.2"
+ }
+}
diff --git a/static/js/lib/node_modules/marked-token-position/src/index.ts b/static/js/lib/node_modules/marked-token-position/src/index.ts
new file mode 100644
index 0000000..d624389
--- /dev/null
+++ b/static/js/lib/node_modules/marked-token-position/src/index.ts
@@ -0,0 +1,192 @@
+/* node:coverage ignore next */
+import type { MarkedExtension, Token, Tokens } from 'marked';
+
+export interface TokenWithPosition extends Tokens.Generic {
+ position: Position;
+}
+interface Position {
+ /**
+ * Positions for each line of the token. LinePositions will not include the newline character for the line.
+ */
+ lines: LinePosition[]
+ /**
+ * Position at the beginning of token
+ */
+ start: PositionFields;
+ /**
+ * Position at the end of token
+ */
+ end: PositionFields;
+}
+
+interface LinePosition {
+ /**
+ * Position at the beginning of line
+ */
+ start: PositionFields;
+ /**
+ * Position at the end of line. Will not include the newline character.
+ */
+ end: PositionFields;
+}
+
+interface PositionFields {
+ /**
+ * Number of characters from the beginning of the markdown string
+ */
+ offset: number;
+ /**
+ * Line number of the token. Starts at line 0.
+ */
+ line: number;
+ /**
+ * Column number of the token. Starts at column 0.
+ */
+ column: number;
+}
+
+/**
+ * Add position field to tokens
+ */
+export function addTokenPositions(tokens: Token[]) {
+ const markdown = tokens.map(token => token.raw).join('');
+ return addPosition(tokens, 0, 0, 0, markdown).tokens;
+}
+
+/**
+ * Marked extension to add position field to tokens
+ */
+export default function(options = {}): MarkedExtension {
+ return {
+ hooks: {
+ processAllTokens(tokens) {
+ return addTokenPositions(tokens);
+ },
+ },
+ };
+}
+
+function addPosition(tokens: Token[], offset: number, line: number, column: number, markdown: string) {
+ for (const token of tokens) {
+ const genericToken = token as Tokens.Generic;
+ const position = getPosition(offset, line, column, markdown, genericToken.raw);
+ genericToken.position = position;
+
+ if (genericToken.tokens) {
+ addPosition(genericToken.tokens, offset, line, column, markdown);
+ }
+
+ if (genericToken.childTokens) {
+ let nextOffset = offset;
+ let nextLine = line;
+ let nextColumn = column;
+ let nextMarkdown = markdown;
+ for (const childToken of genericToken.childTokens) {
+ const nextPosition = addPosition(genericToken[childToken], nextOffset, nextLine, nextColumn, nextMarkdown);
+ nextOffset = nextPosition.offset;
+ nextLine = nextPosition.line;
+ nextColumn = nextPosition.column;
+ nextMarkdown = nextPosition.markdown;
+ }
+ }
+
+ if (genericToken.type === 'list') {
+ addPosition(genericToken.items, offset, line, column, markdown);
+ }
+
+ if (genericToken.type === 'table') {
+ let nextOffset = offset;
+ let nextLine = line;
+ let nextColumn = column;
+ let nextMarkdown = markdown;
+ for (const headerCell of genericToken.header) {
+ const nextPosition = addPosition(headerCell.tokens, nextOffset, nextLine, nextColumn, nextMarkdown);
+ nextOffset = nextPosition.offset;
+ nextLine = nextPosition.line;
+ nextColumn = nextPosition.column;
+ nextMarkdown = nextPosition.markdown;
+ }
+ for (const row of genericToken.rows) {
+ for (const rowCell of row) {
+ const nextPosition = addPosition(rowCell.tokens, nextOffset, nextLine, nextColumn, nextMarkdown);
+ nextOffset = nextPosition.offset;
+ nextLine = nextPosition.line;
+ nextColumn = nextPosition.column;
+ nextMarkdown = nextPosition.markdown;
+ }
+ }
+ }
+
+ const deltaOffset = position.end.offset - offset;
+ offset = position.end.offset;
+ line = position.end.line;
+ column = position.end.column;
+ markdown = markdown.slice(deltaOffset);
+ }
+
+ return {
+ tokens: tokens as TokenWithPosition[],
+ offset,
+ line,
+ column,
+ markdown,
+ };
+}
+
+function getPosition(offset: number, line: number, column: number, markdown: string, raw: string): Position {
+ let lines: LinePosition[] = [];
+ const rawLines = raw.split('\n');
+ const markdownLines = markdown.split('\n');
+
+ // eslint-disable-next-line no-labels
+ md: for (let i = 0; i <= markdownLines.length - rawLines.length; i++) {
+ lines = [];
+ for (let j = 0; j < rawLines.length; j++) {
+ const markdownLine = markdownLines[i + j];
+ const rawLine = rawLines[j];
+ const lineStartOffset = markdownLine.indexOf(rawLine);
+
+ if (lineStartOffset === -1) {
+ // eslint-disable-next-line no-labels
+ continue md;
+ }
+
+ const beforeMarkdownLines = markdownLines.slice(0, i + j).join('\n') + (i + j > 0 ? '\n' : '');
+ const start = {
+ offset: offset + beforeMarkdownLines.length + lineStartOffset,
+ line: line + i + j,
+ column: (i + j === 0 ? column : 0) + lineStartOffset,
+ };
+ const end = {
+ offset: start.offset + rawLine.length,
+ line: start.line,
+ column: start.column + rawLine.length,
+ };
+
+ lines.push({
+ start,
+ end,
+ });
+ }
+ break;
+ }
+
+ /* node:coverage ignore next 4 */
+ if (lines.length === 0) {
+ // This shouldn't ever happen but if it does it would be nice to have a good error message
+ throw new Error(`Cannot find ${JSON.stringify(raw)} in ${JSON.stringify(markdown)}`);
+ }
+
+ const start = lines[0].start;
+ const end = lines.at(-1)!.end;
+
+ if (lines.length > 1 && lines.at(-1)!.start.offset === end.offset) {
+ lines = lines.slice(0, -1);
+ }
+
+ return {
+ lines,
+ start,
+ end,
+ };
+}
diff --git a/static/js/lib/node_modules/marked/LICENSE.md b/static/js/lib/node_modules/marked/LICENSE
similarity index 100%
rename from static/js/lib/node_modules/marked/LICENSE.md
rename to static/js/lib/node_modules/marked/LICENSE
diff --git a/static/js/lib/node_modules/marked/README.md b/static/js/lib/node_modules/marked/README.md
index d4ab251..60f0b28 100644
--- a/static/js/lib/node_modules/marked/README.md
+++ b/static/js/lib/node_modules/marked/README.md
@@ -5,7 +5,6 @@
# Marked
[](https://www.npmjs.com/package/marked)
-[](https://cdn.jsdelivr.net/npm/marked/marked.min.js)
[](https://packagephobia.now.sh/result?p=marked)
[](https://www.npmjs.com/package/marked)
[](https://github.com/markedjs/marked/actions)
@@ -18,7 +17,7 @@
## Demo
-Checkout the [demo page](https://marked.js.org/demo/) to see marked in action ⛹️
+Check out the [demo page](https://marked.js.org/demo/) to see Marked in action ⛹️
## Docs
@@ -33,7 +32,7 @@ Also read about:
**Node.js:** Only [current and LTS](https://nodejs.org/en/about/releases/) Node.js versions are supported. End of life Node.js versions may become incompatible with Marked at any point in time.
-**Browser:** Not IE11 :)
+**Browser:** [Baseline Widely Available](https://developer.mozilla.org/en-US/docs/Glossary/Baseline/Compatibility)
## Installation
@@ -84,7 +83,7 @@ $ marked --help
-
+
-