From c863de29a77c201bf93626bc29d185d3bb185338 Mon Sep 17 00:00:00 2001 From: Ryan Mulligan Date: Tue, 7 Sep 2021 06:29:21 -0700 Subject: [PATCH] nixos/doc/md-to-db.sh: handle Docbook inclues in CommonMark You can do includes like this: ```{=docbook} ``` --- .../from_md/development/writing-documentation.chapter.xml | 2 +- nixos/doc/manual/md-to-db.sh | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/nixos/doc/manual/from_md/development/writing-documentation.chapter.xml b/nixos/doc/manual/from_md/development/writing-documentation.chapter.xml index a42067f4e995..079c80060576 100644 --- a/nixos/doc/manual/from_md/development/writing-documentation.chapter.xml +++ b/nixos/doc/manual/from_md/development/writing-documentation.chapter.xml @@ -1,4 +1,4 @@ - + Writing NixOS Documentation As NixOS grows, so too does the need for a catalogue and explanation diff --git a/nixos/doc/manual/md-to-db.sh b/nixos/doc/manual/md-to-db.sh index 7949b42e8d81..c7a328b2295d 100755 --- a/nixos/doc/manual/md-to-db.sh +++ b/nixos/doc/manual/md-to-db.sh @@ -24,15 +24,19 @@ mapfile -t MD_FILES < <(find . -type f -regex '.*\.md$') for mf in ${MD_FILES[*]}; do if [ "${mf: -11}" == ".section.md" ]; then mkdir -p $(dirname "$OUT/$mf") + OUTFILE="$OUT/${mf%".section.md"}.section.xml" pandoc "$mf" "${pandoc_flags[@]}" \ - -o "$OUT/${mf%".section.md"}.section.xml" + -o "$OUTFILE" + grep -q -m 1 "xi:include" "$OUTFILE" && sed -i 's|xmlns:xlink="http://www.w3.org/1999/xlink"| xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude"|' "$OUTFILE" fi if [ "${mf: -11}" == ".chapter.md" ]; then mkdir -p $(dirname "$OUT/$mf") + OUTFILE="$OUT/${mf%".chapter.md"}.chapter.xml" pandoc "$mf" "${pandoc_flags[@]}" \ --top-level-division=chapter \ - -o "$OUT/${mf%".chapter.md"}.chapter.xml" + -o "$OUTFILE" + grep -q -m 1 "xi:include" "$OUTFILE" && sed -i 's|xmlns:xlink="http://www.w3.org/1999/xlink"| xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude"|' "$OUTFILE" fi done