@pretextbook/remark-pretext 0.0.9 → 0.0.11
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/README.md +42 -0
- package/dist/index.cjs +6 -6
- package/dist/index.js +397 -362
- package/dist/lib/context.d.ts +10 -0
- package/dist/lib/frontmatter.d.ts +3 -0
- package/dist/lib/mdast-to-ptxast.d.ts +5 -0
- package/dist/lib/remark-pretext.d.ts +8 -0
- package/package.json +2 -2
package/dist/lib/context.d.ts
CHANGED
|
@@ -25,6 +25,16 @@ export interface VisitContext {
|
|
|
25
25
|
topLevelAttributesApplied?: {
|
|
26
26
|
done: boolean;
|
|
27
27
|
};
|
|
28
|
+
/** The title of the document's top-level division (or document root), e.g.
|
|
29
|
+
* from frontmatter `title`. When set for a non-root document, depth-1
|
|
30
|
+
* headings no longer supply the top-level title — they start the first
|
|
31
|
+
* subdivision instead (see `headingDepthOffset`). */
|
|
32
|
+
topLevelTitle?: string;
|
|
33
|
+
/** Added to a heading's raw depth when resolving its division type. Set to
|
|
34
|
+
* `1` when `topLevelTitle` supplies the top-level division's title itself,
|
|
35
|
+
* so a depth-1 heading (`#`) resolves one level deeper (the first
|
|
36
|
+
* subdivision) instead of the top-level division. */
|
|
37
|
+
headingDepthOffset?: number;
|
|
28
38
|
}
|
|
29
39
|
export interface ConversionMessage {
|
|
30
40
|
type: 'warning' | 'error';
|
|
@@ -8,6 +8,9 @@ export interface FrontmatterResult {
|
|
|
8
8
|
documentRoot?: RootDivisionType;
|
|
9
9
|
/** Attributes (`xml:id`, `label`, `component`) for the top-level division. */
|
|
10
10
|
attributes?: Record<string, string>;
|
|
11
|
+
/** The title of the document's top-level division (or document root),
|
|
12
|
+
* when a `title:` field is present. */
|
|
13
|
+
title?: string;
|
|
11
14
|
/** The markdown source with the frontmatter block removed. */
|
|
12
15
|
body: string;
|
|
13
16
|
}
|
|
@@ -18,6 +18,11 @@ export interface MdastToPtxastOptions {
|
|
|
18
18
|
/** Attributes (`xml:id`, `label`, `component`) applied to the first
|
|
19
19
|
* root-level division built from the document, e.g. from frontmatter. */
|
|
20
20
|
topLevelAttributes?: Record<string, string>;
|
|
21
|
+
/** Title of the document's top-level division (or document root), e.g.
|
|
22
|
+
* from frontmatter `title`. When set for a non-root document, a depth-1
|
|
23
|
+
* heading (`#`) no longer supplies that title — it starts the first
|
|
24
|
+
* subdivision instead. */
|
|
25
|
+
topLevelTitle?: string;
|
|
21
26
|
}
|
|
22
27
|
/** Transform an mdast Root node into an xast Root node (backwards compatible). */
|
|
23
28
|
export declare function mdastToPtxast(tree: MdastRoot, source?: string, options?: MdastToPtxastOptions): Root;
|
|
@@ -23,6 +23,14 @@ export interface RemarkPretextOptions {
|
|
|
23
23
|
* fields declared in the markdown's frontmatter.
|
|
24
24
|
*/
|
|
25
25
|
topLevelAttributes?: Record<string, string>;
|
|
26
|
+
/**
|
|
27
|
+
* Title of the document's top-level division (or, when `documentRoot` is
|
|
28
|
+
* set, the root's own title). Overrides any `title:` field declared in the
|
|
29
|
+
* markdown's frontmatter. When set for a non-root document, a depth-1
|
|
30
|
+
* heading (`#`) no longer supplies that title — it starts the first
|
|
31
|
+
* subdivision instead.
|
|
32
|
+
*/
|
|
33
|
+
topLevelTitle?: string;
|
|
26
34
|
}
|
|
27
35
|
declare const remarkPretext: Plugin<[RemarkPretextOptions?], MdastRoot, Root>;
|
|
28
36
|
export default remarkPretext;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pretextbook/remark-pretext",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "remark plugin to transform markdown-style PreTeXt directives into ptxast",
|
|
5
5
|
"author": "Oscar Levin",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"test": "vitest run"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@pretextbook/ptxast": "^0.0.
|
|
42
|
+
"@pretextbook/ptxast": "^0.0.8",
|
|
43
43
|
"@types/mdast": "^4.0.0",
|
|
44
44
|
"mdast-util-directive": "^3.0.0",
|
|
45
45
|
"remark-directive": "^4.0.0",
|