@thi.ng/hiccup-markdown 2.1.49 → 3.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/CHANGELOG.md +106 -1
- package/README.md +261 -169
- package/api.d.ts +348 -17
- package/emoji.d.ts +11 -0
- package/emoji.js +1914 -0
- package/package.json +8 -7
- package/parse.d.ts +73 -5
- package/parse.js +521 -211
- package/parser.d.ts +65 -0
- package/parser.js +379 -0
- package/serialize.d.ts +2 -1
- package/serialize.js +43 -32
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/hiccup-markdown",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Markdown parser & serializer from/to Hiccup format",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -38,12 +38,13 @@
|
|
|
38
38
|
"@thi.ng/arrays": "^2.5.5",
|
|
39
39
|
"@thi.ng/checks": "^3.3.9",
|
|
40
40
|
"@thi.ng/defmulti": "^2.1.30",
|
|
41
|
+
"@thi.ng/emoji": "^0.1.0",
|
|
41
42
|
"@thi.ng/errors": "^2.2.11",
|
|
42
|
-
"@thi.ng/
|
|
43
|
-
"@thi.ng/
|
|
44
|
-
"@thi.ng/
|
|
45
|
-
"@thi.ng/
|
|
46
|
-
"@thi.ng/
|
|
43
|
+
"@thi.ng/hiccup": "^4.2.33",
|
|
44
|
+
"@thi.ng/logger": "^1.4.9",
|
|
45
|
+
"@thi.ng/parse": "^2.2.27",
|
|
46
|
+
"@thi.ng/strings": "^3.4.0",
|
|
47
|
+
"@thi.ng/text-canvas": "^2.4.30"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
50
|
"@microsoft/api-extractor": "^7.34.2",
|
|
@@ -95,5 +96,5 @@
|
|
|
95
96
|
"status": "alpha",
|
|
96
97
|
"year": 2018
|
|
97
98
|
},
|
|
98
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "060a3a69281094df70be0e4f326a0ac3bbc3dd1d\n"
|
|
99
100
|
}
|
package/parse.d.ts
CHANGED
|
@@ -1,8 +1,76 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Fn3, IObjectOf, Primitive } from "@thi.ng/api";
|
|
2
|
+
import type { ILogger } from "@thi.ng/logger";
|
|
3
|
+
import type { ParseScope, ParseState } from "@thi.ng/parse";
|
|
4
|
+
import type { ParseOpts, ParseResult, TagTransforms, TransformCtx } from "./api.js";
|
|
5
|
+
export declare const GRAMMAR: import("@thi.ng/parse").Language | undefined;
|
|
6
|
+
export declare const DEFAULT_TAG_TRANSFORMS: TagTransforms;
|
|
7
|
+
export declare class ParseError extends Error {
|
|
8
|
+
state?: ParseState<string> | undefined;
|
|
9
|
+
constructor(state?: ParseState<string> | undefined);
|
|
10
|
+
}
|
|
2
11
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
12
|
+
* Parses given Markdown source string into a tree structure defined by given
|
|
13
|
+
* {@link TagTransforms}.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* The tag transforms are optional and the default implementations can be
|
|
17
|
+
* overwritten on tag-by-tag basis. The default transforms yield a simple hiccup
|
|
18
|
+
* tree (aka each tag will be an array in the form: `["tagname", {...},
|
|
19
|
+
* ...body]`).
|
|
20
|
+
*
|
|
21
|
+
* See [thi.ng/hiccup](https://thi.ng/hiccup) and related packages for further
|
|
22
|
+
* details.
|
|
23
|
+
*
|
|
24
|
+
* @param src
|
|
25
|
+
* @param opts
|
|
6
26
|
*/
|
|
7
|
-
export declare const parse: (
|
|
27
|
+
export declare const parse: (src: string, { tags, opts, linkRefs, logger, }?: Partial<{
|
|
28
|
+
tags: Partial<TagTransforms>;
|
|
29
|
+
opts: Partial<ParseOpts>;
|
|
30
|
+
linkRefs: IObjectOf<[string, (string | undefined)?]>;
|
|
31
|
+
logger: ILogger;
|
|
32
|
+
}>) => ParseResult;
|
|
33
|
+
/**
|
|
34
|
+
* 1st stage of the parsing (with out result transformations). This calls the
|
|
35
|
+
* `main` rule of the provided parse {@link GRAMMAR} and returns a parse
|
|
36
|
+
* context, incl. the raw abstract syntax tree of the parsed document. If
|
|
37
|
+
* parsing failed entirely (due to invalid input), throws a {@link ParseError}.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* Note: Even if the function returns a result, parsing might only have
|
|
41
|
+
* partially successful (can be checked via the [`.done`
|
|
42
|
+
* flag](https://docs.thi.ng/umbrella/parse/classes/ParseContext.html#done)).
|
|
43
|
+
*
|
|
44
|
+
* This function is only for advanced use. Mostly you'll probably want to use
|
|
45
|
+
* the main {@link parse} function instead.
|
|
46
|
+
*
|
|
47
|
+
* @param src
|
|
48
|
+
* @param retain
|
|
49
|
+
*/
|
|
50
|
+
export declare const parseRaw: (src: string, retain?: boolean) => import("@thi.ng/parse").ParseContext<string>;
|
|
51
|
+
export declare const defTransformContext: (tags?: Partial<TagTransforms>, opts?: Partial<ParseOpts>, linkRefs?: IObjectOf<[string, (string | undefined)?]>, logger?: ILogger) => TransformCtx;
|
|
52
|
+
/**
|
|
53
|
+
* Polymorphic & recursive parse scope/node transformation function. Takes a
|
|
54
|
+
* single scope, context and accumulator array, then calls itself recursively
|
|
55
|
+
* for any child scopes and passes relevant data to its user defined
|
|
56
|
+
* {@link TagTransforms} handler and adds result to the accumulator array.
|
|
57
|
+
*
|
|
58
|
+
*/
|
|
59
|
+
export declare const transformScope: Fn3<ParseScope<string>, TransformCtx, any[], void>;
|
|
60
|
+
/**
|
|
61
|
+
* Takes an attributes object and optional metadata. If `meta` is not nullish,
|
|
62
|
+
* assigns it as `__meta` key in given object. Returns object.
|
|
63
|
+
*
|
|
64
|
+
* @param target
|
|
65
|
+
* @param meta
|
|
66
|
+
*/
|
|
67
|
+
export declare const withMeta: (target: any, meta?: any) => any;
|
|
68
|
+
/**
|
|
69
|
+
* Takes a hiccup tree and extracts only the primitive body values (strings,
|
|
70
|
+
* numbers, booleans) and returns them as array.
|
|
71
|
+
*
|
|
72
|
+
* @param body
|
|
73
|
+
* @param acc
|
|
74
|
+
*/
|
|
75
|
+
export declare const extractBody: (body: any[], acc?: Primitive[]) => Primitive[];
|
|
8
76
|
//# sourceMappingURL=parse.d.ts.map
|