[RFC 08/10] scripts: add a crude converter from DocBook tmpl to asciidoc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use some pre- and post-processing to handle the "![EIFPCD]" docproc
directives in the DocBook, and let pandoc do the rest. Manual editing
will be required, but this will give a big jump start.

The asciidoc result would be nicer without the pandoc --no-wrap option,
but unfortunately pandoc also wraps the docproc directives within
<pre></pre> tags, breaking their post-processing. There's probably a way
around this, but I couldn't be bothered for this proof of concept.

The post-processing converts the directives to the new format of having
comma separated filename suffixes describe the content to be included.

Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx>
---
 scripts/tmpl2asciidoc | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100755 scripts/tmpl2asciidoc

diff --git a/scripts/tmpl2asciidoc b/scripts/tmpl2asciidoc
new file mode 100755
index 000000000000..092400cc702c
--- /dev/null
+++ b/scripts/tmpl2asciidoc
@@ -0,0 +1,39 @@
+#!/bin/bash
+# a crude converter from DocBook tmpl in STDIN to AsciiDoc in STDOUT
+
+sed 's/^\(!.*\)/<pre>\1<\/pre>/' |\
+	pandoc --atx-headers --no-wrap -f docbook -t asciidoc |\
+	while read line; do
+		case "$line" in
+			!E*)
+				file=${line#!?}
+				echo "include::$file,export[]"
+				;;
+			!I*)
+				file=${line#!?}
+				echo "include::$file,internal[]"
+				;;
+			!F*)
+				file=${line#!?}
+				file=${file%% *}
+				functions=${line#* }
+				for f in $functions; do
+					echo "include::$file,function,$f[]"
+				done
+				;;
+			!P*)
+				file=${line#!?}
+				file=${file%% *}
+				doc=${line#* }
+				doc=${doc//[^A-Za-z0-9]/_}
+				echo "include::$file,doc,$doc[]"
+				;;
+			!C*|!D*)
+				echo "$0: WARNING: unsupported: $line" >&2
+				echo "// $line"
+				;;
+			*)
+				echo -E "$line"
+				;;
+		esac
+	done
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux