@farvardin/lezer-parser-markdown 1.6.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/CHANGELOG.md +279 -0
- package/LICENSE +21 -0
- package/README.md +719 -0
- package/bin/build-readme.cjs +39 -0
- package/build.js +16 -0
- package/dist/index.cjs +2357 -0
- package/dist/index.d.cts +600 -0
- package/dist/index.d.ts +600 -0
- package/dist/index.js +2340 -0
- package/package.json +37 -0
- package/publish.sh +1 -0
- package/src/README.md +83 -0
- package/src/extension.ts +301 -0
- package/src/index.ts +5 -0
- package/src/markdown.ts +1966 -0
- package/src/nest.ts +46 -0
- package/test/compare-tree.ts +14 -0
- package/test/spec.ts +79 -0
- package/test/test-extension.ts +277 -0
- package/test/test-incremental.ts +265 -0
- package/test/test-markdown.ts +3574 -0
- package/test/test-nesting.ts +86 -0
- package/test/tsconfig.json +12 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Build github-proof readmes that contain the package's API
|
|
2
|
+
// docs as HTML.
|
|
3
|
+
|
|
4
|
+
const {gather} = require("getdocs-ts")
|
|
5
|
+
const {build} = require("builddocs")
|
|
6
|
+
const {join} = require("path"), fs = require("fs")
|
|
7
|
+
|
|
8
|
+
let root = join(__dirname, "..")
|
|
9
|
+
|
|
10
|
+
function buildReadme() {
|
|
11
|
+
let template = fs.readFileSync(join(root, "src", "README.md"), "utf8")
|
|
12
|
+
|
|
13
|
+
let placeholders = template.match(/\n@\w+(?=\n|$)/g), dummy = placeholders.join("\n\n<hr>\n\n")
|
|
14
|
+
let html = build({
|
|
15
|
+
mainText: dummy,
|
|
16
|
+
anchorPrefix: "",
|
|
17
|
+
allowUnresolvedTypes: false,
|
|
18
|
+
imports: [type => {
|
|
19
|
+
if (/\bcommon\b/.test(type.typeSource))
|
|
20
|
+
return `https://lezer.codemirror.net/docs/ref/#common.${type.type}`
|
|
21
|
+
if (/\blr\b/.test(type.typeSource))
|
|
22
|
+
return `https://lezer.codemirror.net/docs/ref/#lr.${type.type}`
|
|
23
|
+
if (/\bhighlight\b/.test(type.typeSource))
|
|
24
|
+
return `https://lezer.codemirror.net/docs/ref/#highlight.${type.type}`
|
|
25
|
+
if (type.type == "NodeSet") console.log(type.typeSource)
|
|
26
|
+
}]
|
|
27
|
+
}, gather({filename: join(root, "src", "index.ts"), basedir: join(root, "src"), }))
|
|
28
|
+
|
|
29
|
+
html = html.replace(/<\/?span.*?>/g, "")
|
|
30
|
+
.replace(/id="(.*?)"/g, (_, id) => `id="user-content-${id.toLowerCase()}"`)
|
|
31
|
+
.replace(/href="#(.*?)"/g, (_, id) => `href="#user-content-${id.toLowerCase()}"`)
|
|
32
|
+
|
|
33
|
+
let pieces = html.split("\n<hr>\n")
|
|
34
|
+
|
|
35
|
+
let i = 0
|
|
36
|
+
return template.replace(/\n@\w+(?=\n|$)/g, _ => pieces[i++])
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
fs.writeFileSync(join(root, "README.md"), buildReadme())
|
package/build.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {build, watch} from "@marijn/buildtool"
|
|
2
|
+
import {fileURLToPath} from "url"
|
|
3
|
+
import {dirname, join} from "path"
|
|
4
|
+
|
|
5
|
+
let tsOptions = {
|
|
6
|
+
lib: ["es5", "es6"],
|
|
7
|
+
target: "es6"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
let main = join(dirname(fileURLToPath(import.meta.url)), "src", "index.ts")
|
|
11
|
+
|
|
12
|
+
if (process.argv.includes("--watch")) {
|
|
13
|
+
watch([main], [], {tsOptions})
|
|
14
|
+
} else {
|
|
15
|
+
build(main, {tsOptions})
|
|
16
|
+
}
|