obsidian-publisher mermaid diagram
flowchart TD
A["Run: bash ./build"] --> B["build.sh"]
B --> C["source .env (loads pkm_in_path, build_path)"]
C --> D1["rm -rf $build_path/markdown_flies/*md (typo, cleans nothing)"]
C --> D2["rm -rf $build_path/docs/*"]
C --> D3["rm -rf $build_path/pkm.sqlite"]
D1 --> E
D2 --> E
D3 --> E
E["Execute node raw_to_sqlite.js -i $pkm_in_path -o $build_path -dbf $build_path/pkm.sqlite -oi 5"]
subgraph raw_to_sqlite.js
F["Parse CLI args (exit 1 if -i or -o missing)"]
F --> G["Create dirs: $build_path + markdown_files/assets"]
G --> H["Open SQLite, create 6 tables: markdown_nodes, markdown_edges, markdown_key_values, markdown_syntax_trees, html_rendered_from_markdown, urls_extracted_from_nodes"]
H --> I["Glob **/*.md across vault"]
I --> J["Select check_rbac (default = shared_verification_function; -ev = all_files; -g with -np = groups_not_shared; -g = groups)"]
J --> K["For each .md file"]
K --> L["Extract YAML frontmatter"]
L --> M["Has uuid?"]
M -- "No" --> N["Generate uuid, set share=false, write back to vault file"]
N --> O["check_rbac passes?"]
M -- "Yes" --> O
O -- "No" --> K
O -- "Yes" --> P["INSERT raw note into markdown_nodes"]
P --> Q["Select all nodes from DB"]
Q --> R["Glob vault assets/**"]
R --> S["For each node: link pass"]
S --> T["embeddedLinksFind on raw_markdown"]
T --> U["For each embed [!](../!)"]
U --> V["Lookup target by title in markdown_nodes"]
V -- "Found note" --> V1["Extract embedded section or heading, label = EMBEDDED"]
V1 --> W["INSERT markdown_edges"]
V -- "No note" --> V2["Asset file matches?"]
V2 -- "Yes" --> V3["Copy asset into markdown_files/assets, label = ASSET"]
V3 --> W
V2 -- "No" --> V4["Label = BROKEN, to_node_id = null"]
V4 --> W
W --> U
W --> X["embeddedLinksReplace raw_markdown"]
X --> Y["internalLinksFind on new markdown"]
Y --> Z["For each wikilink"]
Z --> Z1["Lookup target by title, INSERT markdown_edges label = INTERNAL"]
Z1 --> Z2["internalLinksReplace -> link rewritten as uuid.md path"]
Z2 --> Z
Z2 --> AA["UPDATE rendered_markdown in markdown_nodes"]
AA --> AB["Backlink pass"]
AB --> AC["Distinct INTERNAL to_node_id in edges"]
AC --> AD["Append '#### Backlinks' section to rendered_markdown"]
AD --> AE["For each node: emit files"]
AE --> AF["Write markdown_files/{uuid}.md, add title to YAML if missing"]
AE --> AG["title == index_title?"]
AG -- "Yes" --> AH["Also write markdown_files/index.md"]
AH --> AI["Build page hierarchy from full_file_path"]
AG -- "No" --> AI
AI --> AJ["Write mkdocs.json + mkdocs.yaml (mkdocs-bak.yml template with site_title/site_url substituted, merged with YAML file tree)"]
end
Links