@peaceroad/markdown-it-figure-with-p-caption 0.14.1 → 0.14.2

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 +2 -2
  2. package/index.js +9 -9
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -89,8 +89,8 @@ Every option below is forwarded verbatim to `p7d-markdown-it-p-captions`, which
89
89
 
90
90
  ### Automatic numbering
91
91
 
92
- - `setLabelNumbers`: enable numbering per media type. Pass an array such as `['img']`, `['table']`, or `['img', 'table']`.
93
- - `autoLabelNumber`: shorthand for turning numbering on for both images and tables without passing the array yourself. Provide `setLabelNumbers` explicitly (e.g., `['img']`) when you need finer control—the explicit array always wins.
92
+ - `autoLabelNumberSets`: enable numbering per media type. Pass an array such as `['img']`, `['table']`, or `['img', 'table']`.
93
+ - `autoLabelNumber`: shorthand for turning numbering on for both images and tables without passing the array yourself. Provide `autoLabelNumberSets` explicitly (e.g., `['img']`) when you need finer control—the explicit array always wins.
94
94
  - Counters start at `1` near the top of the document and increment sequentially per media type. Figures and tables keep independent counters even when mixed together.
95
95
  - The counter only advances when a real caption exists (paragraph, auto-detected alt/title, or fallback text). Figures emitted solely because of `oneImageWithoutCaption` stay unnumbered.
96
96
  - Manual numbers inside the caption text (e.g., `Figure 5.`) always win. The plugin updates its internal counter so the next automatic number becomes `6`. This applies to captions sourced from paragraphs, auto detection, and fallback captions.
package/index.js CHANGED
@@ -26,7 +26,7 @@ const fallbackLabelDefaults = {
26
26
  table: { en: 'Table', ja: '表' },
27
27
  }
28
28
 
29
- const normalizeSetLabelNumbers = (value) => {
29
+ const normalizeAutoLabelNumberSets = (value) => {
30
30
  const normalized = { img: false, table: false }
31
31
  if (!value) return normalized
32
32
  if (Array.isArray(value)) {
@@ -53,7 +53,7 @@ const buildLabelClassLookup = (opt) => {
53
53
  }
54
54
 
55
55
  const shouldApplyLabelNumbering = (captionType, opt) => {
56
- const setting = opt.setLabelNumbers
56
+ const setting = opt.autoLabelNumberSets
57
57
  if (!setting) return false
58
58
  return !!setting[captionType]
59
59
  }
@@ -933,8 +933,8 @@ const mditFigureWithPCaption = (md, option) => {
933
933
  autoTitleCaption: false, // same as above but reads from the title attribute when alt isn't usable
934
934
 
935
935
  // --- numbering controls ---
936
- autoLabelNumber: false, // shorthand for enabling numbering for both img/table unless setLabelNumbers is provided explicitly
937
- setLabelNumbers: [], // preferred; supports ['img'], ['table'], or both
936
+ autoLabelNumber: false, // shorthand for enabling numbering for both img/table unless autoLabelNumberSets is provided explicitly
937
+ autoLabelNumberSets: [], // preferred; supports ['img'], ['table'], or both
938
938
 
939
939
  // --- caption text formatting (delegated to p7d-markdown-it-p-captions) ---
940
940
  hasNumClass: false,
@@ -948,13 +948,13 @@ const mditFigureWithPCaption = (md, option) => {
948
948
  removeMarkNameInCaptionClass: false,
949
949
  wrapCaptionBody: false,
950
950
  }
951
- const hasExplicitSetLabelNumbers = option && Object.prototype.hasOwnProperty.call(option, 'setLabelNumbers')
951
+ const hasExplicitAutoLabelNumberSets = option && Object.prototype.hasOwnProperty.call(option, 'autoLabelNumberSets')
952
952
  if (option) Object.assign(opt, option)
953
953
  // Normalize option shorthands now so downstream logic works with a consistent { img, table } shape.
954
- opt.setLabelNumbers = normalizeSetLabelNumbers(opt.setLabelNumbers)
955
- if (opt.autoLabelNumber && !hasExplicitSetLabelNumbers) {
956
- opt.setLabelNumbers.img = true
957
- opt.setLabelNumbers.table = true
954
+ opt.autoLabelNumberSets = normalizeAutoLabelNumberSets(opt.autoLabelNumberSets)
955
+ if (opt.autoLabelNumber && !hasExplicitAutoLabelNumberSets) {
956
+ opt.autoLabelNumberSets.img = true
957
+ opt.autoLabelNumberSets.table = true
958
958
  }
959
959
  // Precompute `.f-*-label` permutations so numbering lookup doesn't rebuild arrays per caption.
960
960
  opt.labelClassLookup = buildLabelClassLookup(opt)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peaceroad/markdown-it-figure-with-p-caption",
3
- "version": "0.14.1",
3
+ "version": "0.14.2",
4
4
  "description": "A markdown-it plugin. For a paragraph with only one image, a table or code block or blockquote, and by writing a caption paragraph immediately before or after, they are converted into the figure element with the figcaption element.",
5
5
  "main": "index.js",
6
6
  "type": "module",