@dustfeather/deckrun 2.0.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 +21 -0
- package/README.md +1073 -0
- package/THIRD-PARTY-NOTICES.md +38 -0
- package/dist/editor-content.js +485 -0
- package/dist/editor.js +3916 -0
- package/dist/fragments.js +71 -0
- package/dist/generate.js +3488 -0
- package/dist/highlights.js +833 -0
- package/dist/index.js +1020 -0
- package/dist/lint.js +330 -0
- package/dist/parser.js +221 -0
- package/dist/pdf.js +200 -0
- package/dist/presentation-options.js +289 -0
- package/dist/preview.js +400 -0
- package/dist/rich-content.js +195 -0
- package/dist/safe-fetch.js +173 -0
- package/dist/sanitize.js +102 -0
- package/dist/themes.js +1041 -0
- package/dist/titles.js +30 -0
- package/package.json +64 -0
package/dist/titles.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How much of a document is searched for its `<title>`, and how long a
|
|
3
|
+
* heading or title may be before it is ignored.
|
|
4
|
+
*
|
|
5
|
+
* The document is attacker-supplied — it arrives from `deckrun <url>`,
|
|
6
|
+
* `/__fetch-doc` or a `POST /__present-doc` body — so every scan here is
|
|
7
|
+
* bounded. An unbounded `[^>]*` or `[\s\S]*?` re-scans the remaining input
|
|
8
|
+
* from every candidate start position, which turns a megabyte of `<title`
|
|
9
|
+
* into quadratic work on the server's only thread.
|
|
10
|
+
*/
|
|
11
|
+
const HEAD_SCAN_LIMIT = 64 * 1024;
|
|
12
|
+
const ATTR_LIMIT = 200;
|
|
13
|
+
const TEXT_LIMIT = 2000;
|
|
14
|
+
const HEADING_RE = new RegExp(`<h[1-6][^>]{0,${ATTR_LIMIT}}>([\\s\\S]{0,${TEXT_LIMIT}}?)</h[1-6]>`, "i");
|
|
15
|
+
const TITLE_RE = new RegExp(`<title[^>]{0,${ATTR_LIMIT}}>([\\s\\S]{0,${TEXT_LIMIT}}?)</title>`, "i");
|
|
16
|
+
function stripTags(value) {
|
|
17
|
+
return value.replace(/<[^>]{0,1000}>/g, "").trim();
|
|
18
|
+
}
|
|
19
|
+
/** First heading of the deck, with inline markup stripped. */
|
|
20
|
+
export function deckTitle(slides, fallback) {
|
|
21
|
+
const heading = slides[0]?.html.slice(0, HEAD_SCAN_LIMIT).match(HEADING_RE);
|
|
22
|
+
const text = heading ? stripTags(heading[1]) : "";
|
|
23
|
+
return text || fallback;
|
|
24
|
+
}
|
|
25
|
+
/** An HTML doc's own `<title>`, with inline markup stripped. */
|
|
26
|
+
export function docTitle(html, fallback) {
|
|
27
|
+
const match = html.slice(0, HEAD_SCAN_LIMIT).match(TITLE_RE);
|
|
28
|
+
const text = match ? stripTags(match[1]) : "";
|
|
29
|
+
return text || fallback;
|
|
30
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dustfeather/deckrun",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "A local-first presentation tool for writing, editing, presenting, and exporting Markdown slides or self-contained HTML docs.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"presentation",
|
|
7
|
+
"slides",
|
|
8
|
+
"markdown",
|
|
9
|
+
"deck",
|
|
10
|
+
"mermaid",
|
|
11
|
+
"katex",
|
|
12
|
+
"pdf-export",
|
|
13
|
+
"local-first",
|
|
14
|
+
"cli"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://github.com/dustfeather/deckrun#readme",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/dustfeather/deckrun/issues"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/dustfeather/deckrun.git"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"author": "Catalin Teodorescu",
|
|
26
|
+
"type": "module",
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=26"
|
|
29
|
+
},
|
|
30
|
+
"bin": {
|
|
31
|
+
"deckrun": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist/",
|
|
35
|
+
"THIRD-PARTY-NOTICES.md"
|
|
36
|
+
],
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"prepare": "git config core.hooksPath .githooks 2>/dev/null || true",
|
|
42
|
+
"build": "tsc && chmod +x dist/index.js",
|
|
43
|
+
"dev": "tsx src/index.ts",
|
|
44
|
+
"typecheck": "tsc --noEmit",
|
|
45
|
+
"test": "npm run build && node --test"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"commander": "^15.0.0",
|
|
49
|
+
"katex": "^0.18.7",
|
|
50
|
+
"marked": "^18.0.13",
|
|
51
|
+
"mermaid": "^11.17.2",
|
|
52
|
+
"open": "^11.0.4",
|
|
53
|
+
"sanitize-html": "^2.17.7"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^26.6.1",
|
|
57
|
+
"@types/sanitize-html": "^2.16.0",
|
|
58
|
+
"tsx": "^4.23.13",
|
|
59
|
+
"typescript": "^7.0.2"
|
|
60
|
+
},
|
|
61
|
+
"allowScripts": {
|
|
62
|
+
"esbuild@0.28.2": true
|
|
63
|
+
}
|
|
64
|
+
}
|