feat: implement build script and parsers to automate Foundry VTT journal pack generation from Obsidian markdown files
This commit is contained in:
@@ -83,7 +83,7 @@ const PACK_CONFIGS: PackConfig[] = [
|
||||
sources: [
|
||||
// Pure lore narrative.
|
||||
{ path: 'ObsidianNotes/lore/02. Otchłań i Magia.md' },
|
||||
// Rules intro (Wstęp only — mechanics chapters are skipped).
|
||||
// Rules intro (Wstęp only - mechanics chapters are skipped).
|
||||
{ path: 'ObsidianNotes/rules/02. Klątwa Otchłani.md', prefaceTitle: 'Wstęp' },
|
||||
],
|
||||
skip: /^(Rozdział II - Talenty|Rozdział III - Dary|Rozdział IV - Choroby|Rozdział V - Zaklęcia|Rozdział X - Artefakty)/i,
|
||||
@@ -238,7 +238,7 @@ for (const pack of byPack.keys()) {
|
||||
console.log(` ✓ compiled ${pack}`);
|
||||
}
|
||||
|
||||
console.log(`[lore] done — ${byPack.size} packs in packs/`);
|
||||
console.log(`[lore] done - ${byPack.size} packs in packs/`);
|
||||
|
||||
function toFoundryJournal(doc: JournalDoc, sort: number): Record<string, unknown> {
|
||||
const fId = makeFoundryId(doc.id);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* `@UUID[Compendium.<pkg>.<pack>...]` patterns, and reports any reference
|
||||
* to a system pack we know about but a slug that does not exist.
|
||||
*
|
||||
* Currently informational only — the journal parser does not yet emit
|
||||
* Currently informational only - the journal parser does not yet emit
|
||||
* UUID cross-links automatically. This script provides the framework
|
||||
* for Phase 7.3/7.4 integration.
|
||||
*/
|
||||
@@ -45,7 +45,7 @@ function scanFile(file: string) {
|
||||
try {
|
||||
walk(packsSrcDir);
|
||||
} catch {
|
||||
console.log('[lint-uuid] no packs-src/ — run build:packs first.');
|
||||
console.log('[lint-uuid] no packs-src/ - run build:packs first.');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* A. Legacy Google-Docs export (`_books/`):
|
||||
* - No frontmatter.
|
||||
* - TOC is a plain-text block that reuses the same `Rozdział X — Title`
|
||||
* - TOC is a plain-text block that reuses the same `Rozdział X - Title`
|
||||
* headings. The parser deduplicates: the SECOND occurrence of each
|
||||
* heading is the real body.
|
||||
*
|
||||
@@ -33,7 +33,7 @@ export interface JournalDoc {
|
||||
pack: string;
|
||||
/** Source provenance for traceability. */
|
||||
source: { book: string; chapter: string; line: number };
|
||||
/** Pages — each becomes a `JournalEntryPage`. */
|
||||
/** Pages - each becomes a `JournalEntryPage`. */
|
||||
pages: JournalPage[];
|
||||
}
|
||||
|
||||
@@ -66,10 +66,10 @@ export interface JournalParseConfig {
|
||||
|
||||
// Matches both plain-text (`Rozdział IV - Title`) and heading-prefixed
|
||||
// (`## Rozdział IV - Title`) chapter lines. Optional trailing page number.
|
||||
const CHAPTER_RE = /^(?:#{1,6}\s+)?Rozdzia[łl]\s+([IVXLC]+)\s*[:.—\-–]\s*(.+?)(?:\s+\d+)?$/;
|
||||
const CHAPTER_RE = /^(?:#{1,6}\s+)?Rozdzia[łl]\s+([IVXLC]+)\s*[:.\-–]\s*(.+?)(?:\s+\d+)?$/;
|
||||
const SEPARATOR = /^_{3,}$/;
|
||||
const FRONTMATTER_FENCE = /^---\s*$/;
|
||||
// Obsidian TOC bullets: `- [[#Anchor|Label]]` — skip in body content too
|
||||
// Obsidian TOC bullets: `- [[#Anchor|Label]]` - skip in body content too
|
||||
const OBSIDIAN_TOC_BULLET = /^[-*]\s+\[\[#/;
|
||||
|
||||
/** Returns the first non-frontmatter line index (skips `--- ... ---` block). */
|
||||
@@ -94,7 +94,7 @@ export function parseJournalBook(cfg: JournalParseConfig): JournalDoc[] {
|
||||
if (m) occurrences.push({ idx: i, roman: m[1], title: m[2].trim(), raw: lines[i].trim() });
|
||||
}
|
||||
if (occurrences.length === 0) {
|
||||
// No chapters found — if there's a prefaceTitle, still try to emit preface.
|
||||
// No chapters found - if there's a prefaceTitle, still try to emit preface.
|
||||
if (cfg.prefaceTitle) {
|
||||
const pages = bodyToPages(lines);
|
||||
if (pages.length > 0) {
|
||||
@@ -117,7 +117,7 @@ export function parseJournalBook(cfg: JournalParseConfig): JournalDoc[] {
|
||||
}
|
||||
bodyChapters.push(occ);
|
||||
}
|
||||
// If no duplicates were found (no plain-text TOC — typical of native files),
|
||||
// If no duplicates were found (no plain-text TOC - typical of native files),
|
||||
// treat the entire list as body chapters.
|
||||
const chapters = bodyChapters.length > 0 ? bodyChapters : occurrences;
|
||||
|
||||
@@ -158,7 +158,7 @@ export function parseJournalBook(cfg: JournalParseConfig): JournalDoc[] {
|
||||
const slug = slugify(`${ch.roman}-${ch.title}`);
|
||||
docs.push({
|
||||
id: `${cfg.pack}-${slug}`,
|
||||
name: `Rozdział ${ch.roman} — ${ch.title}`,
|
||||
name: `Rozdział ${ch.roman} - ${ch.title}`,
|
||||
pack: cfg.pack,
|
||||
source: { book: cfg.sourceBook, chapter: ch.title, line: startIdx + ch.idx + 1 },
|
||||
pages,
|
||||
|
||||
Reference in New Issue
Block a user