Messages in this thread Patch in this message | | | From | Jani Nikula <> | Subject | [RFC 08/10] scripts: add a crude converter from DocBook tmpl to asciidoc | Date | Tue, 26 Jan 2016 14:08:53 +0200 |
| |
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@intel.com> --- 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
| |