Last active 1717872673

Using the FoundryVTT markdown export plugin, convert those files to dokuwiki things, and give a Table of Contents

Revision d23bf522b2427c2e3dc2aba64e90ccc3bdb24b19

foundry-to-dokuwiki.sh Raw
1#!/bin/bash
2
3# This is the FoundryVTT export plugin used to generate these markdown files:
4# https://foundryvtt.com/packages/export-markdown
5
6set -e
7
8SRC=$1
9DST=$2
10
11# Create dokuwiki files "in place" or rather, alongside markdown
12find "$SRC" -iname "*.md" -type f -exec sh -c 'pandoc -f markdown -t dokuwiki "${0}" -o "${0%.md}.txt"' {} \;
13
14# Copy over the dokuwiki .txt files, flatten along the way:
15# FoundryVTT uses uuids so names shouldn't clash
16find "$SRC" -mindepth 1 -type f -iname "*.txt" -exec cp -t "$DST" -i '{}' +
17
18# Move into destination folder for renaming
19cd $DST
20
21# Do the rename
22rename 'y/A-Z/a-z/' *
23
24# While here, spit out a TOC of top level journal name links
25# TODO: Make the dg:foundry: dokuwiki namespace prefix configurable
26find . -regex '.*journalentry\.[a-z0-9]+\.txt' -exec grep -m 1 -H '.' {} \; | sed -E 's/\.\/(journalentry\.[a-z0-9]+)\.txt:====== (.*) ======/ \* [[dg:foundry:\1|\2]]/'
27
28# Go back
29cd -