@heroiclands/package-build 22.21.0 → 22.22.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.
Files changed (110) hide show
  1. package/CHANGELOG.md +191 -0
  2. package/assets/styles/content-base.css +162 -0
  3. package/bin/content-commands.mjs +26 -3
  4. package/bin/package-build.mjs +15 -2
  5. package/ci/content-format-reference.mjs +68 -1
  6. package/config.mjs +26 -0
  7. package/content-config.mjs +73 -4
  8. package/docs/api.md +36 -18
  9. package/docs/authoring/dates-and-calendars.md +4 -2
  10. package/docs/authoring/frontmatter.md +2 -2
  11. package/docs/authoring/links-and-markup.md +237 -28
  12. package/docs/configuration.md +27 -1
  13. package/docs/content-format.md +3 -1
  14. package/docs/guides/reference-pages.md +15 -0
  15. package/docs/reference/format-details.md +224 -46
  16. package/docs/reference/note-types.md +21 -4
  17. package/engine/actor-compiler.mjs +23 -0
  18. package/engine/anchored-sections.mjs +35 -4
  19. package/engine/anchors.mjs +10 -20
  20. package/engine/base-compiler.mjs +86 -21
  21. package/engine/base-styles.mjs +149 -0
  22. package/engine/bundles.mjs +0 -1
  23. package/engine/compendiums.mjs +8 -1
  24. package/engine/content-blocks.mjs +410 -0
  25. package/engine/content-captions.mjs +57 -8
  26. package/engine/content-footnotes.mjs +189 -0
  27. package/engine/content-format-check.mjs +15 -12
  28. package/engine/content-index.mjs +2 -2
  29. package/engine/content-links.mjs +14 -6
  30. package/engine/content-tables.mjs +45 -4
  31. package/engine/content-tasklists.mjs +189 -0
  32. package/engine/docs-checks.mjs +4 -4
  33. package/engine/extension-attributes.mjs +48 -2
  34. package/engine/frontmatter-lint.mjs +47 -64
  35. package/engine/frontmatter.mjs +3 -3
  36. package/engine/heading-attributes.mjs +308 -0
  37. package/engine/helpers.mjs +14 -13
  38. package/engine/homepage.mjs +8 -8
  39. package/engine/index.mjs +3 -0
  40. package/engine/infobox-render.mjs +15 -3
  41. package/engine/infobox.mjs +83 -8
  42. package/engine/journals.mjs +36 -17
  43. package/engine/macros.mjs +1 -1
  44. package/engine/markdown-expressions.mjs +178 -53
  45. package/engine/note-dates.mjs +49 -0
  46. package/engine/note-frontmatter.mjs +7 -16
  47. package/engine/note-vocabulary.mjs +172 -37
  48. package/engine/page-lists.mjs +358 -0
  49. package/engine/pdf-build.mjs +76 -42
  50. package/engine/pdf-render.mjs +422 -49
  51. package/engine/rank-ladder.mjs +198 -0
  52. package/engine/reckoning-markers.mjs +1 -1
  53. package/engine/retired-fields.mjs +8 -13
  54. package/engine/scenes.mjs +10 -3
  55. package/engine/site-build.mjs +41 -12
  56. package/engine/site-config.mjs +10 -1
  57. package/engine/site-index.mjs +18 -2
  58. package/engine/site-preview.mjs +18 -7
  59. package/engine/social-ties.mjs +52 -14
  60. package/engine/sql-tables.mjs +66 -9
  61. package/engine/standings.mjs +89 -6
  62. package/engine/system-block.mjs +12 -14
  63. package/engine/web-wikilinks.mjs +48 -1
  64. package/hm3/actors.mjs +6 -3
  65. package/manifest.mjs +13 -0
  66. package/package.json +1 -1
  67. package/sohl/actors.mjs +22 -99
  68. package/sohl/item-fields.mjs +4 -5
  69. package/sohl/items.mjs +1 -1
  70. package/sohl/note-schemas.mjs +11 -21
  71. package/types/config.d.mts +9 -0
  72. package/types/engine/actor-compiler.d.mts +11 -0
  73. package/types/engine/anchored-sections.d.mts +24 -0
  74. package/types/engine/base-compiler.d.mts +19 -0
  75. package/types/engine/base-styles.d.mts +93 -0
  76. package/types/engine/content-blocks.d.mts +87 -0
  77. package/types/engine/content-captions.d.mts +14 -1
  78. package/types/engine/content-footnotes.d.mts +73 -0
  79. package/types/engine/content-format-check.d.mts +8 -6
  80. package/types/engine/content-tables.d.mts +12 -4
  81. package/types/engine/content-tasklists.d.mts +72 -0
  82. package/types/engine/extension-attributes.d.mts +22 -1
  83. package/types/engine/frontmatter.d.mts +1 -1
  84. package/types/engine/heading-attributes.d.mts +174 -0
  85. package/types/engine/helpers.d.mts +7 -4
  86. package/types/engine/homepage.d.mts +7 -7
  87. package/types/engine/index.d.mts +1 -0
  88. package/types/engine/infobox-render.d.mts +6 -1
  89. package/types/engine/journals.d.mts +14 -7
  90. package/types/engine/markdown-expressions.d.mts +23 -0
  91. package/types/engine/note-frontmatter.d.mts +1 -4
  92. package/types/engine/note-vocabulary.d.mts +82 -6
  93. package/types/engine/page-lists.d.mts +126 -0
  94. package/types/engine/pdf-render.d.mts +72 -2
  95. package/types/engine/rank-ladder.d.mts +32 -0
  96. package/types/engine/retired-fields.d.mts +4 -6
  97. package/types/engine/site-build.d.mts +13 -1
  98. package/types/engine/site-config.d.mts +9 -0
  99. package/types/engine/site-index.d.mts +13 -1
  100. package/types/engine/site-preview.d.mts +1 -1
  101. package/types/engine/sql-tables.d.mts +31 -7
  102. package/types/engine/standings.d.mts +21 -3
  103. package/types/engine/system-block.d.mts +11 -12
  104. package/types/engine/web-wikilinks.d.mts +3 -1
  105. package/types/hm3/actors.d.mts +3 -3
  106. package/types/sohl/actors.d.mts +6 -7
  107. package/engine/content-admonitions.mjs +0 -114
  108. package/engine/content-secrets.mjs +0 -112
  109. package/types/engine/content-admonitions.d.mts +0 -24
  110. package/types/engine/content-secrets.d.mts +0 -17
@@ -7,22 +7,13 @@
7
7
 
8
8
  import YAML from "yaml";
9
9
 
10
- /** The complete ordered top-level vocabulary for addressed content notes. */
11
- export const NOTE_TOP_LEVEL_KEYS = Object.freeze([
12
- "shortcode",
13
- "name",
14
- "type",
15
- "subType",
16
- "description",
17
- "tags",
18
- "data",
19
- "hm3",
20
- "sohl",
21
- "dnd5e",
22
- ]);
23
-
24
- /** Membership test for the top-level vocabulary. */
25
- export const NOTE_TOP_LEVEL_KEY_SET = new Set(NOTE_TOP_LEVEL_KEYS);
10
+ // The top-level vocabulary itself is declared beside the other two closed
11
+ // regions, so the lint, the formatter and the reference read one list.
12
+ export {
13
+ NOTE_TOP_LEVEL_FIELDS,
14
+ NOTE_TOP_LEVEL_KEYS,
15
+ NOTE_TOP_LEVEL_KEY_SET,
16
+ } from "./note-vocabulary.mjs";
26
17
 
27
18
  /** The name properties every note accepts, in display order. */
28
19
  export const NOTE_NAME_KEYS = Object.freeze(["full", "aliases"]);
@@ -12,30 +12,32 @@
12
12
  */
13
13
 
14
14
  /**
15
- * The **closed** half of a note's frontmatter: the `data:` container, and the
16
- * `subType` each note type declares.
17
- *
18
- * A note's frontmatter has three regions, and only one of them is open. The
19
- * **top level** describes the note as a published artefact, every key of it is
20
- * copied into the generated web page, and an unrecognised key there is a Hugo
21
- * or theme parameter this build has no standing to refuse. The **system
22
- * blocks** describe the subject as one system's documents. Between them sits
23
- * `data:` — the type-specific facts about the subject itself, system-agnostic,
24
- * and closed.
25
- *
26
- * Closed is the whole point. Those facts previously sat at the top level, where
27
- * the pass-through rule applied to them too, so a misspelled `wieght` became a
28
- * theme parameter rather than a finding — indistinguishable, from the outside,
29
- * from a weapon that simply weighs nothing. Under `data:` the same misspelling
30
- * is an error naming the note and the key it was probably meant to be.
31
- *
32
- * **`subType` rides along, and stays at the top level.** It is not a `data:`
33
- * key: a note's `(type, subType)` is what each system's map reads to derive a
34
- * document type, so it describes the note rather than the subject. But it is
35
- * the other per-type vocabulary the format closes, it is enumerated in the same
36
- * `### type:` section of the specification that enumerates the `data:` keys,
37
- * and keeping the two together means one entry per type rather than two
38
- * registries free to disagree about which types exist.
15
+ * The **closed vocabularies** of a note's frontmatter: the top-level keys, the
16
+ * `data:` container, and the `subType` each note type declares.
17
+ *
18
+ * A note's frontmatter has three regions and every one of them is closed. The
19
+ * **top level** describes the note as a published artefact and is a fixed list
20
+ * — {@link NOTE_TOP_LEVEL_FIELDS} — so a key it does not name is a finding at
21
+ * its own line rather than a value copied into the generated page. The
22
+ * **system blocks** describe the subject as one system's documents, and are
23
+ * checked against the published schema. Between them sits `data:` — the
24
+ * type-specific facts about the subject itself, system-agnostic.
25
+ *
26
+ * Closed is the whole point, and the failure it answers is a misspelling. A
27
+ * region that passes an unrecognised key through cannot tell `wieght` from a
28
+ * weapon that weighs nothing: the note says one thing, the build does another,
29
+ * and nothing says so. Under a closed vocabulary the same misspelling is an
30
+ * error naming the note and the key it was probably meant to be.
31
+ *
32
+ * **`subType` is a top-level key with a per-type vocabulary**, which is why it
33
+ * is declared twice over: once in {@link NOTE_TOP_LEVEL_FIELDS} as a key the
34
+ * region accepts, and once per type below as the closed set of values that type
35
+ * takes. It is not a `data:` key — a note's `(type, subType)` is what each
36
+ * system's map reads to derive a document type, so it describes the note rather
37
+ * than the subject — but its values are enumerated in the same `### type:`
38
+ * section of the specification that enumerates the `data:` keys, and keeping
39
+ * the two together means one entry per type rather than two registries free to
40
+ * disagree about which types exist.
39
41
  *
40
42
  * **This is note-format knowledge, so it lives in `engine/`.** `data:` holds
41
43
  * what is true of the *thing* — a weapon's weight, an affliction's
@@ -79,6 +81,9 @@
79
81
  // is how a disagreement between the three arises.
80
82
  import { ART_SLOTS } from "./art-slots.mjs";
81
83
  import { ADDRESS_SEGMENT_PATTERN, isAddressSegment } from "./address-charset.mjs";
84
+ // The system registry, so the top-level block keys below are the systems this
85
+ // toolchain recognises rather than a second list of them.
86
+ import { SYSTEM_IDS } from "./systems.mjs";
82
87
  // The retirement window for a renamed type, read rather than restated: a
83
88
  // vocabulary that answered only to the current spelling would report every key
84
89
  // of an unswept note as unknown.
@@ -100,6 +105,7 @@ import { checkSocialTies } from "./social-ties.mjs";
100
105
  import { checkStandings } from "./standings.mjs";
101
106
  import { STANDING_BODY_TYPES } from "./standing-terms.mjs";
102
107
  import { checkDatedOffices } from "./office-holders.mjs";
108
+ import { checkRankLadder } from "./rank-ladder.mjs";
103
109
  import { checkCalendarChoice } from "./calendar-choice.mjs";
104
110
  import { checkCultureChoice } from "./culture-choice.mjs";
105
111
  import { SOCIAL_TIES, SOCIAL_TIE_TARGET_TYPES } from "./social-tie-terms.mjs";
@@ -218,6 +224,16 @@ const TEXT = Object.freeze({ shape: "string", kind: "string" });
218
224
  /** A list. */
219
225
  const LIST = Object.freeze({ shape: "list", kind: "list" });
220
226
 
227
+ /**
228
+ * One value, or several.
229
+ *
230
+ * The two are the same fact at different lengths rather than two different
231
+ * facts, so a single value means a list of one and a consumer reads one shape.
232
+ * That is what separates this from `list-or-map`, whose halves say different
233
+ * things.
234
+ */
235
+ const TEXT_OR_LIST = Object.freeze({ shape: "string or list", kind: "string-or-list" });
236
+
221
237
  /** A single Address. */
222
238
  const LINK = Object.freeze({ shape: "an Address", kind: "address" });
223
239
 
@@ -303,6 +319,101 @@ const TOKEN_ICON = Object.freeze({
303
319
  describe: "What a token on the canvas wears — an `icon` address; unset, it follows `icon`.",
304
320
  });
305
321
 
322
+ /**
323
+ * One top-level frontmatter key.
324
+ *
325
+ * Narrower than a {@link DataFieldSpec}: the top level is a fixed list rather
326
+ * than a per-type vocabulary, nothing there is keyed by pack or resolved as an
327
+ * Address, and the value's shape is checked by whatever owns the region the key
328
+ * opens — `name`, `tags` and each system block each have their own check.
329
+ *
330
+ * @typedef {object} TopLevelFieldSpec
331
+ * @property {string} name - The key, as a note writes it.
332
+ * @property {boolean} [system] - The key opens a game system's block, so it is
333
+ * one of {@link module:engine/systems.SYSTEM_IDS} rather than a fixed key.
334
+ * @property {string} describe - One line, for the author-facing reference.
335
+ */
336
+
337
+ /**
338
+ * **The top-level vocabulary**, in the order a formatted note writes it.
339
+ *
340
+ * The region describes the note as a published artefact: what it is called,
341
+ * what kind of thing it is about, how it is classified, and which of the other
342
+ * two regions it opens. Everything else a note states is a fact about the
343
+ * subject, which belongs under `data:`, or a fact about one system's document,
344
+ * which belongs inside that system's block.
345
+ *
346
+ * **Closed, like the other two regions.** A key this list does not name is a
347
+ * finding at its own line, because a region that passed one through would turn
348
+ * a misspelling into a value nothing reads — `title` beside `name`, or `pack`
349
+ * where `data.pack` was meant.
350
+ *
351
+ * **The system blocks are derived from the system registry**, so recognising a
352
+ * further system is a change to {@link module:engine/systems.SYSTEM_IDS} and to
353
+ * nothing else. They sort by name after the fixed keys: a block is the largest
354
+ * thing a note writes, every one of them belongs at the end, and a rule a
355
+ * reader can restate in one sentence is worth more than a hand-kept order.
356
+ *
357
+ * Five readers derive from this one list — the frontmatter lint's accepted set,
358
+ * the message it prints, the formatter's key order, the content-format check,
359
+ * and the author-facing reference — so none of them can fall behind the others.
360
+ *
361
+ * @type {readonly TopLevelFieldSpec[]}
362
+ */
363
+ export const NOTE_TOP_LEVEL_FIELDS = Object.freeze([
364
+ Object.freeze({
365
+ name: "shortcode",
366
+ describe: "The note's own address segment, unique within its type.",
367
+ }),
368
+ Object.freeze({
369
+ name: "name",
370
+ describe: "The display names — a required `full`, and any `aliases`.",
371
+ }),
372
+ Object.freeze({
373
+ name: "type",
374
+ describe: "What the note is about, which decides its vocabulary and its document.",
375
+ }),
376
+ Object.freeze({
377
+ name: "subType",
378
+ describe: "The type's own genre, where it declares one.",
379
+ }),
380
+ Object.freeze({
381
+ name: "description",
382
+ describe: "The short page summary.",
383
+ }),
384
+ Object.freeze({
385
+ name: "tags",
386
+ describe: "Draft state, GM routing, and the descriptive labels a page list reads.",
387
+ }),
388
+ Object.freeze({
389
+ name: "data",
390
+ describe: "The facts about the subject itself, shared by every system.",
391
+ }),
392
+ ...[...SYSTEM_IDS].sort().map((system) =>
393
+ Object.freeze({
394
+ name: system,
395
+ system: true,
396
+ describe:
397
+ `What the \`${system}\` system makes of the subject — its ` +
398
+ `document's mechanics, routing and art.`,
399
+ }),
400
+ ),
401
+ ]);
402
+
403
+ /**
404
+ * The top-level keys, in formatted order.
405
+ *
406
+ * @type {readonly string[]}
407
+ */
408
+ export const NOTE_TOP_LEVEL_KEYS = Object.freeze(NOTE_TOP_LEVEL_FIELDS.map((field) => field.name));
409
+
410
+ /**
411
+ * Membership test for the top-level vocabulary.
412
+ *
413
+ * @type {ReadonlySet<string>}
414
+ */
415
+ export const NOTE_TOP_LEVEL_KEY_SET = Object.freeze(new Set(NOTE_TOP_LEVEL_KEYS));
416
+
306
417
  /**
307
418
  * The `data:` keys **every** note type accepts, whatever it is.
308
419
  *
@@ -448,7 +559,7 @@ function checkPlacePurpose(note) {
448
559
  },
449
560
  ];
450
561
  if (hasTag(note.fm, value)) return [];
451
- const tags = note.fm?.tags ?? note.fm?.tag;
562
+ const tags = note.fm?.tags;
452
563
  return [
453
564
  {
454
565
  ...at(),
@@ -482,15 +593,17 @@ export const GM_TAG = "gm";
482
593
  /**
483
594
  * The tags that **classify** a note, grouped by what they classify.
484
595
  *
485
- * `tags:` lives at the open top level and most tags belong there: a theme, a
486
- * region, a working state is the author's own and this build has no opinion
487
- * about it. A classifying tag is different, because something queries it — a
596
+ * `tags:` holds an open vocabulary of *values*, and most tags belong there: a
597
+ * theme, a region, a working state is the author's own and this build has no
598
+ * opinion about it. A classifying tag is different, because something queries
599
+ * it — a
488
600
  * settlement tagged `village` appears in the list of villages and an untagged
489
601
  * one does not, so `vilage` does not merely look wrong, it removes the note from
490
602
  * an index while the index still renders a table that looks complete.
491
603
  *
492
604
  * **This list is not a closed set.** An unrecognised tag is legal, because the
493
- * region is open; what is reported is a **near miss** — a tag close enough to a
605
+ * values are the author's; what is reported is a **near miss** — a tag close
606
+ * enough to a
494
607
  * declared one to be a typo of it.
495
608
  *
496
609
  * **Each group names the types it applies to**, and that scope is what makes the
@@ -662,14 +775,12 @@ export function exclusiveTagGroups(type, groups = DECLARED_TAGS) {
662
775
  * The spelling of the tag *itself* still is — a near miss is a near miss, and
663
776
  * the frontmatter lint is what reports it; nothing here guesses.
664
777
  *
665
- * Reads `tags` and the singular `tag` spelling.
666
- *
667
778
  * @param {object|null|undefined} fm - Parsed frontmatter.
668
779
  * @param {string} tag - The tag to look for, in its declared spelling.
669
780
  * @returns {boolean} Whether the note carries it.
670
781
  */
671
782
  export function hasTag(fm, tag) {
672
- const raw = fm?.tags ?? fm?.tag;
783
+ const raw = fm?.tags;
673
784
  if (raw == null) return false;
674
785
  const wanted = String(tag).toLowerCase();
675
786
  for (const entry of Array.isArray(raw) ? raw : [raw]) {
@@ -781,8 +892,8 @@ export const NOTE_VOCABULARY = Object.freeze({
781
892
  ...STANDINGS,
782
893
  describe:
783
894
  "Bodies the being belongs to, keyed by Address, each entry holding the " +
784
- "standing it holds there — `rank`, a level on that body's own ladder, " +
785
- "and `office`, a post that body names.",
895
+ "standing it holds there — `rank`, required, a level on that body's own " +
896
+ "ladder, and `office`, optional, a post that body names.",
786
897
  },
787
898
  {
788
899
  name: "socialTies",
@@ -794,7 +905,14 @@ export const NOTE_VOCABULARY = Object.freeze({
794
905
  check: checkSocialTies,
795
906
  describe: `Defining ties directed from this being to others: ${SOCIAL_TIES.map(({ term, meaning }) => `\`${term}\` (${meaning})`).join("; ")}`,
796
907
  },
797
- { name: "gender", ...TEXT, describe: "`male`, `female` or `other`." },
908
+ {
909
+ name: "gender",
910
+ ...TEXT,
911
+ describe:
912
+ "One of `male`, `female`, `nonbinary`, `none` or `other`. " +
913
+ "`none` says the being has no gender; an absent field says its " +
914
+ "gender is unrecorded.",
915
+ },
798
916
  {
799
917
  name: "species",
800
918
  ...LINK,
@@ -862,12 +980,19 @@ export const NOTE_VOCABULARY = Object.freeze({
862
980
  {
863
981
  name: "frame",
864
982
  ...TEXT,
865
- describe: "Relative frame — `scant`, `light`, `medium`, `large` or `massive`.",
983
+ describe:
984
+ "Relative frame — one of `scant`, `light`, `medium`, `heavy` or `massive`.",
866
985
  },
867
986
  { name: "appearance.eye_color", ...TEXT, describe: "Eye colour." },
868
987
  { name: "appearance.hair_color", ...TEXT, describe: "Hair colour." },
869
988
  { name: "appearance.skin_color", ...TEXT, describe: "Skin colour." },
870
- { name: "appearance.complexion", ...TEXT, describe: "Complexion." },
989
+ {
990
+ name: "appearance.complexion",
991
+ ...TEXT_OR_LIST,
992
+ describe:
993
+ "The skin's condition — one value, or several, because a face " +
994
+ "carries more than one at once. A single value means a list of one.",
995
+ },
871
996
  {
872
997
  name: "appearance.extra_features",
873
998
  ...LIST,
@@ -931,6 +1056,16 @@ export const NOTE_VOCABULARY = Object.freeze({
931
1056
  {
932
1057
  name: "governance.ranks",
933
1058
  ...LIST,
1059
+ // A rung is `{level, title, description}` with an optional
1060
+ // `lore`. The shape check sees a list and stops there, so the
1061
+ // rungs inside it are checked here — a ladder is what a being's
1062
+ // `rank` indexes into, and an incomplete rung resolves to a
1063
+ // standing with no name.
1064
+ check: checkRankLadder,
1065
+ // Each rung takes a row of its own, labelled and anchored by
1066
+ // its title, ordered by level — the ladder's parallel to
1067
+ // `governance.offices`' `roster`.
1068
+ ranks: true,
934
1069
  describe: "The ladder of ranks the body confers — level, title, description.",
935
1070
  },
936
1071
  {