@canopycanopycanopy/b-ber-grammar-footnotes 3.1.0 → 4.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/README.md +15 -4
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -58
- package/package.json +13 -14
package/README.md
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
#
|
|
1
|
+
# b-ber-grammar-footnotes
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Handles footnote collection and rendering as a MarkdownIt core rule (not a container directive). After MarkdownIt processes a source file, this package's plugin function receives the full token stream, prepends a `<section class="footnotes break-after">` wrapper with an `<h1>` heading (using the spine entry's title for the current file), appends the closing `</section>`, renders the augmented token stream to HTML, and stores the result in global state under `state.footnotes`. Footnote pages are generated later by `b-ber-parser-footnotes` from that collected state.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Usage
|
|
6
6
|
|
|
7
|
+
Registered as a MarkdownIt core rule by the rendering engine:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import footnotes from '@canopycanopycanopy/b-ber-grammar-footnotes'
|
|
11
|
+
// default export is a factory: (self) => plugin(tokens)
|
|
7
12
|
```
|
|
8
|
-
|
|
13
|
+
|
|
14
|
+
## Dev
|
|
15
|
+
|
|
9
16
|
```
|
|
17
|
+
npm test
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Tests are in `__tests__/index.test.js`.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";iBAEwB,wBAAA,CAAyB,IAAA,SACxB,MAAM;AAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,59 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
5
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = markdownItFootnotePlugin;
|
|
9
|
-
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
10
|
-
var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
|
|
1
|
+
let _canopycanopycanopy_b_ber_lib = require("@canopycanopycanopy/b-ber-lib");
|
|
2
|
+
//#region src/index.ts
|
|
11
3
|
function markdownItFootnotePlugin(self) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const notes = self.markdownIt.renderer.render(tokens, 0, {
|
|
51
|
-
reference: `${fileName}.xhtml`
|
|
52
|
-
});
|
|
53
|
-
_State.default.add('footnotes', {
|
|
54
|
-
fileName,
|
|
55
|
-
title,
|
|
56
|
-
notes
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
}
|
|
4
|
+
return function plugin(tokens) {
|
|
5
|
+
const { fileName } = self;
|
|
6
|
+
const title = _canopycanopycanopy_b_ber_lib.State.find("spine.flattened", { fileName })?.title || fileName;
|
|
7
|
+
tokens.unshift({
|
|
8
|
+
type: "block",
|
|
9
|
+
tag: "section",
|
|
10
|
+
attrs: [["class", "footnotes break-after"]],
|
|
11
|
+
nesting: 1,
|
|
12
|
+
block: true
|
|
13
|
+
}, {
|
|
14
|
+
type: "block",
|
|
15
|
+
tag: "h1",
|
|
16
|
+
nesting: 1,
|
|
17
|
+
block: true
|
|
18
|
+
}, {
|
|
19
|
+
type: "text",
|
|
20
|
+
block: false,
|
|
21
|
+
content: title
|
|
22
|
+
}, {
|
|
23
|
+
type: "block",
|
|
24
|
+
tag: "h1",
|
|
25
|
+
nesting: -1
|
|
26
|
+
});
|
|
27
|
+
tokens.push({
|
|
28
|
+
type: "block",
|
|
29
|
+
tag: "section",
|
|
30
|
+
nesting: -1
|
|
31
|
+
});
|
|
32
|
+
const notes = self.markdownIt.renderer.render(tokens, 0, { reference: `${fileName}.xhtml` });
|
|
33
|
+
_canopycanopycanopy_b_ber_lib.State.add("footnotes", {
|
|
34
|
+
fileName,
|
|
35
|
+
title,
|
|
36
|
+
notes
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
module.exports = markdownItFootnotePlugin;
|
package/package.json
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canopycanopycanopy/b-ber-grammar-footnotes",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"build": "npm run prepare",
|
|
11
|
-
"watch": "BABEL_ENV=production babel --config-file ../../babel.config.js -d dist/ src/ --watch src",
|
|
7
|
+
"build": "tsdown",
|
|
8
|
+
"watch": "tsdown --watch",
|
|
9
|
+
"typecheck": "tsc --noEmit",
|
|
12
10
|
"test": "jest"
|
|
13
11
|
},
|
|
14
12
|
"author": "Triple Canopy <b-ber@canopycanopycanopy.com> (https://triplecanopy.github.io/)",
|
|
@@ -17,15 +15,15 @@
|
|
|
17
15
|
"access": "public"
|
|
18
16
|
},
|
|
19
17
|
"devDependencies": {
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
18
|
+
"@swc/core": "^1.15.40",
|
|
19
|
+
"@swc/jest": "^0.2.39",
|
|
20
|
+
"jest": "^29.7.0",
|
|
21
|
+
"rimraf": "^2.7.1",
|
|
22
|
+
"tsdown": "^0.22.1",
|
|
23
|
+
"typescript": "^6.0.3"
|
|
26
24
|
},
|
|
27
25
|
"dependencies": {
|
|
28
|
-
"@canopycanopycanopy/b-ber-lib": "
|
|
26
|
+
"@canopycanopycanopy/b-ber-lib": "4.0.0",
|
|
29
27
|
"lodash": "^4.17.21",
|
|
30
28
|
"lodash.find": "latest",
|
|
31
29
|
"tar": "^6.1.11"
|
|
@@ -47,5 +45,6 @@
|
|
|
47
45
|
"url": "https://maxwellsimmer.com"
|
|
48
46
|
}
|
|
49
47
|
],
|
|
50
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "435b9c7e6b97d3fbdeb21f2308283597040ebfc8",
|
|
49
|
+
"types": "dist/index.d.ts"
|
|
51
50
|
}
|