@canopycanopycanopy/b-ber-parser-footnotes 3.0.8-nav-memo.2 → 3.0.8-next.61

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.
Files changed (3) hide show
  1. package/README.md +20 -4
  2. package/dist/index.js +11 -6
  3. package/package.json +7 -9
package/README.md CHANGED
@@ -1,9 +1,25 @@
1
- # `@canopycanopycanopy/b-ber-parser-footnotes`
1
+ # b-ber-parser-footnotes
2
2
 
3
- The `b-ber-parser-footnotes` package is used internally parse footnotes in Markdown.
3
+ A markdown-it plugin that parses both inline (`^[…]`) and reference-style (`[^label]` / `[^label]: …`) footnotes from Markdown source and renders them as EPUB-compatible HTML. It emits footnote reference links with `epub:type="noteref"` and footnote list items with `epub:type="footnote"`, and injects hidden back-links (↵) into the footnote body. After processing a document the plugin strips the footnote block from the main token stream and passes it to a callback so the build pipeline can write footnotes to a separate `notes.xhtml` file. A `Counter` helper tracks numbering across pages, supporting both per-document and globally-grouped footnote lists (controlled by `bberState.config.group_footnotes`).
4
4
 
5
- ## Install
5
+ ## Usage
6
6
 
7
+ This plugin is consumed by the b-ber build pipeline's `render` and `footnotes` build steps:
8
+
9
+ ```js
10
+ import footnotePlugin from '@canopycanopycanopy/b-ber-parser-footnotes'
11
+
12
+ md.use(footnotePlugin, footnoteTokens => {
13
+ // footnoteTokens is the extracted footnote block for this document
14
+ })
7
15
  ```
8
- $ npm i -g @canopycanopycanopy/b-ber-parser-footnotes
16
+
17
+ The callback receives the collected footnote tokens; the pipeline writes them to `notes.xhtml`.
18
+
19
+ ## Dev
20
+
21
+ ```
22
+ npm test
9
23
  ```
24
+
25
+ The test suite currently contains only a `test.todo` placeholder — no assertions are implemented yet.
package/dist/index.js CHANGED
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
2
 
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
3
4
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
5
+ _Object$defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = footnotePlugin;
4
9
  var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
5
10
  var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
6
11
  var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
7
12
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
8
- var _lodash = _interopRequireDefault(require("lodash.isundefined"));
13
+ var _isUndefined = _interopRequireDefault(require("lodash/isUndefined"));
9
14
  var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
10
15
  var _counter = _interopRequireDefault(require("./counter"));
11
16
  /* eslint-disable camelcase */
@@ -36,7 +41,7 @@ function renderFootnoteRef(tokens, idx, options, env, slf) {
36
41
  const ref = counter.getRef();
37
42
  return `<a epub:type="noteref" class="footnote-ref" href="notes.xhtml#fn${ref}" id="fnref${ref}">${caption}</a>`;
38
43
  }
39
- function renderFootnoteBlockOpen( /* tokens, idx, options */
44
+ function renderFootnoteBlockOpen(/* tokens, idx, options */
40
45
  ) {
41
46
  const start = counter.listCounter(_State.default.config.group_footnotes, _State.default.footnotes.length);
42
47
  return `<ol class="footnotes" start="${start}">`;
@@ -83,13 +88,13 @@ function renderFootnoteOpen(tokens, idx, _options, env, _self) {
83
88
  function renderFootnoteClose() {
84
89
  return '</li>';
85
90
  }
86
- function renderFootnoteAnchor( /*tokens, idx, options,env, slf */
91
+ function renderFootnoteAnchor(/*tokens, idx, options,env, slf */
87
92
  ) {
88
93
  /* ↩ with escape code to prevent display as Apple Emoji on iOS */
89
94
  // return ' <a href="#fnref' + id + '">\u21a9\uFE0E</a>';
90
95
  return '';
91
96
  }
92
- module.exports = function footnotePlugin(md, callback) {
97
+ function footnotePlugin(md, callback) {
93
98
  const {
94
99
  parseLinkLabel
95
100
  } = md.helpers;
@@ -248,7 +253,7 @@ module.exports = function footnotePlugin(md, callback) {
248
253
  if (pos >= max) return false;
249
254
  pos++;
250
255
  const label = (0, _slice.default)(_context3 = state.src).call(_context3, start + 2, pos - 1);
251
- if ((0, _lodash.default)(state.env.footnotes.refs[`:${label}`])) return false;
256
+ if ((0, _isUndefined.default)(state.env.footnotes.refs[`:${label}`])) return false;
252
257
  if (!silent) {
253
258
  if (!state.env.footnotes.list) state.env.footnotes.list = [];
254
259
  if (state.env.footnotes.refs[`:${label}`] < 0) {
@@ -398,4 +403,4 @@ module.exports = function footnotePlugin(md, callback) {
398
403
  md.inline.ruler.after('image', 'footnote_inline', footnoteInline);
399
404
  md.inline.ruler.after('footnote_inline', 'footnote_ref', footnoteRef);
400
405
  md.core.ruler.after('inline', 'footnote_tail', footnoteTail);
401
- };
406
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canopycanopycanopy/b-ber-parser-footnotes",
3
- "version": "3.0.8-nav-memo.2+63b04c68",
3
+ "version": "3.0.8-next.61+2bbec564",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -25,13 +25,11 @@
25
25
  "rimraf": "^2.7.1"
26
26
  },
27
27
  "dependencies": {
28
- "@canopycanopycanopy/b-ber-lib": "3.0.8-nav-memo.2+63b04c68",
29
- "@canopycanopycanopy/b-ber-logger": "3.0.8-nav-memo.2+63b04c68",
30
- "@canopycanopycanopy/b-ber-shapes-directives": "3.0.8-nav-memo.2+63b04c68",
31
- "@canopycanopycanopy/b-ber-templates": "3.0.8-nav-memo.2+63b04c68",
32
- "lodash": "^4.17.21",
33
- "lodash.isundefined": "^3.0.1",
34
- "tar": "^6.1.11"
28
+ "@canopycanopycanopy/b-ber-lib": "3.0.8-next.61+2bbec564",
29
+ "@canopycanopycanopy/b-ber-logger": "3.0.8-next.61+2bbec564",
30
+ "@canopycanopycanopy/b-ber-shapes-directives": "3.0.8-next.61+2bbec564",
31
+ "@canopycanopycanopy/b-ber-templates": "3.0.8-next.61+2bbec564",
32
+ "lodash": "^4.17.21"
35
33
  },
36
34
  "files": [
37
35
  "dist"
@@ -50,5 +48,5 @@
50
48
  "url": "https://maxwellsimmer.com"
51
49
  }
52
50
  ],
53
- "gitHead": "63b04c68746dd40114a3718c6bef65710649a688"
51
+ "gitHead": "2bbec5643278f53becb0d2ba1f55edfe379d5587"
54
52
  }