pantsdown 2.0.8 → 2.1.1

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "pantsdown",
3
3
  "author": "wallpants",
4
4
  "type": "module",
5
- "version": "2.0.8",
5
+ "version": "2.1.1",
6
6
  "license": "MIT",
7
7
  "description": "Markdown to 'GitHub HTML' parser",
8
8
  "repository": {
@@ -44,7 +44,9 @@
44
44
  "scripts": {
45
45
  "commit": "cz",
46
46
  "format": "prettier **/*.{md,ts,css,yml} -w",
47
- "lint": "tsc && eslint . --ext ts --report-unused-disable-directives --max-warnings 0",
47
+ "typecheck": "tsc",
48
+ "lint": "eslint . --ext ts --report-unused-disable-directives --max-warnings 0",
49
+ "check": "bun run typecheck && bun run lint",
48
50
  "docs:build": "bun run docs/build.ts"
49
51
  },
50
52
  "dependencies": {
@@ -52,18 +54,18 @@
52
54
  "highlight.js": "^11.9.0"
53
55
  },
54
56
  "devDependencies": {
55
- "@commitlint/config-conventional": "^18.6.2",
56
- "@commitlint/cz-commitlint": "^18.6.1",
57
- "@happy-dom/global-registrator": "^13.6.0",
58
- "@typescript-eslint/eslint-plugin": "^7.1.0",
59
- "@typescript-eslint/parser": "^7.0.2",
60
- "bun-types": "latest",
57
+ "@commitlint/config-conventional": "^19.1.0",
58
+ "@commitlint/cz-commitlint": "^19.2.0",
59
+ "@happy-dom/global-registrator": "^14.0.0",
60
+ "@types/bun": "^1.0.12",
61
+ "@typescript-eslint/eslint-plugin": "^7.5.0",
62
+ "@typescript-eslint/parser": "^7.5.0",
61
63
  "commitizen": "^4.3.0",
62
- "commitlint": "^18.6.1",
64
+ "commitlint": "^19.2.1",
63
65
  "eslint": "^8.57.0",
64
66
  "prettier": "^3.2.5",
65
67
  "prettier-plugin-organize-imports": "^3.2.4",
66
- "semantic-release": "^23.0.2",
67
- "typescript": "5.3.3"
68
+ "semantic-release": "^23.0.6",
69
+ "typescript": "5.4.2"
68
70
  }
69
71
  }
@@ -155,6 +155,18 @@
155
155
  color: var(--color-attention-fg);
156
156
  }
157
157
 
158
+ .pantsdown .markdown-alert-tip {
159
+ border-color: var(--color-success-fg);
160
+ }
161
+ .pantsdown .markdown-alert-tip span {
162
+ color: var(--color-success-fg);
163
+ }
164
+ .pantsdown .markdown-alert-caution {
165
+ border-color: var(--color-danger-fg);
166
+ }
167
+ .pantsdown .markdown-alert-caution span {
168
+ color: var(--color-danger-fg);
169
+ }
158
170
  .pantsdown .copy-button {
159
171
  position: absolute;
160
172
  left: calc(100% - 36px);
package/src/lexer.ts CHANGED
@@ -36,10 +36,10 @@ export class Lexer {
36
36
 
37
37
  this.blockTokens(src, this.tokens);
38
38
 
39
- let next;
40
- while ((next = this.inlineQueue.shift())) {
39
+ for (const next of this.inlineQueue) {
41
40
  this.inlineTokens(next.src, next.tokens);
42
41
  }
42
+ this.inlineQueue = [];
43
43
 
44
44
  const footnotesToken: Tokens["Footnotes"] = {
45
45
  type: "footnotes",
@@ -71,7 +71,7 @@ export class Lexer {
71
71
  * Lexing
72
72
  */
73
73
  blockTokens(src: string, tokens: Token[]): Token[] {
74
- src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs: string) => {
74
+ src = src.replace(/^( *)(\t+)/gm, (_, leading: string, tabs: string) => {
75
75
  return leading + " ".repeat(tabs.length);
76
76
  });
77
77
 
@@ -228,7 +228,7 @@ export class Lexer {
228
228
  }
229
229
 
230
230
  if (src) {
231
- const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
231
+ const errMsg = "Infinite loop on byte: " + String(src.charCodeAt(0));
232
232
  throw new Error(errMsg);
233
233
  }
234
234
  }
@@ -401,7 +401,7 @@ export class Lexer {
401
401
  }
402
402
 
403
403
  if (src) {
404
- const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
404
+ const errMsg = "Infinite loop on byte: " + String(src.charCodeAt(0));
405
405
  throw new Error(errMsg);
406
406
  }
407
407
  }
@@ -25,8 +25,8 @@ const tag =
25
25
  "|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption" +
26
26
  "|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe" +
27
27
  "|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option" +
28
- "|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr" +
29
- "|track|ul";
28
+ "|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title" +
29
+ "|tr|track|ul";
30
30
 
31
31
  const title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
32
32
 
@@ -49,7 +49,7 @@ const block_list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/)
49
49
  .replace("def", "\\n+(?=" + block_def.source + ")")
50
50
  .getRegex();
51
51
 
52
- export const comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
52
+ export const comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
53
53
 
54
54
  const block_html = edit(
55
55
  "^ {0,3}(?:" + // optional indentation
@@ -72,8 +72,16 @@ const block_html = edit(
72
72
  )
73
73
  .getRegex();
74
74
 
75
- const block_lheading = edit(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/)
75
+ // const block_lheading = edit(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/)
76
+ const block_lheading = edit(
77
+ /^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
78
+ )
76
79
  .replace(/bull/g, block_bullet) // lists can interrupt
80
+ .replace(/blockCode/g, / {4}/) // indented code blocks can interrupt
81
+ .replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt
82
+ .replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt
83
+ .replace(/heading/g, / {0,3}#{1,6}/) // ATX heading can interrupt
84
+ .replace(/html/g, / {0,3}<[^\n>]+>\n/) // block html can interrupt
77
85
  .getRegex();
78
86
 
79
87
  const block_hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
@@ -22,7 +22,7 @@ type InlineRuleNames =
22
22
  | "backpedal";
23
23
 
24
24
  // list of unicode punctuation marks, plus any missing characters from CommonMark spec
25
- const punctuation = "\\p{P}$+<=>`^|~";
25
+ const punctuation = "\\p{P}\\p{S}";
26
26
  const title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
27
27
  const href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
28
28
  const scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
package/src/types.ts CHANGED
@@ -29,7 +29,7 @@ export interface Tokens extends Record<string, BaseToken> {
29
29
  text: string;
30
30
  icon: string;
31
31
  tokens: Token[];
32
- variant: "Note" | "Important" | "Warning";
32
+ variant: "Note" | "Important" | "Warning" | "Tip" | "Caution";
33
33
  };
34
34
  Heading: {
35
35
  type: "heading";
package/src/utils.ts CHANGED
@@ -297,4 +297,14 @@ export const ALERTS = [
297
297
  regex: makeAlertRegex("Warning"),
298
298
  icon: '<svg class="octicon octicon-alert" style="margin-right: 0.5rem;" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg>',
299
299
  },
300
+ {
301
+ variant: "Tip",
302
+ regex: makeAlertRegex("Tip"),
303
+ icon: '<svg class="octicon octicon-alert" style="margin-right: 0.5rem;" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"/></svg>',
304
+ },
305
+ {
306
+ variant: "Caution",
307
+ regex: makeAlertRegex("Caution"),
308
+ icon: '<svg class="octicon octicon-alert" style="margin-right: 0.5rem;" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 0 1-.22.53l-4.25 4.25A.749.749 0 0 1 11 16H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"/></svg>',
309
+ },
300
310
  ];
package/tsconfig.json CHANGED
@@ -5,7 +5,6 @@
5
5
  "target": "ESNext",
6
6
  "moduleResolution": "Bundler",
7
7
  "moduleDetection": "force",
8
- "types": ["bun-types"],
9
8
  "allowImportingTsExtensions": true,
10
9
  "noEmit": true,
11
10
  "composite": true,