Dernière activité 1717872673

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

foundry-to-dokuwiki.sh Brut
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
8# TODO: Change PREFIX to be optional, get some argparse type things going
9PREFIX=$1
10SRC=$2
11DST=$3
12
13# Create dokuwiki files "in place" or rather, alongside markdown
14find "$SRC" -iname "*.md" -type f -exec sh -c 'pandoc -f markdown -t dokuwiki "${0}" -o "${0%.md}.txt"' {} \;
15
16# Copy over the dokuwiki .txt files, flatten along the way:
17# FoundryVTT uses uuids so names shouldn't clash
18find "$SRC" -mindepth 1 -type f -iname "*.txt" -exec cp -t "$DST" -i '{}' +
19
20# Move into destination folder for renaming
21cd $DST
22
23# Do the rename
24rename 'y/A-Z/a-z/' *
25
26# While here, spit out a TOC of top level journal name links
27find . -regex '.*journalentry\.[a-z0-9]+\.txt' -exec grep -m 1 -H '.' {} \; | sed -E "s/\.\/(journalentry\.[a-z0-9]+)\.txt:====== (.*) ======/ \* [[$PREFIX\1|\2]]/"
28
29# Go back
30cd -