From: Enblend <enb...@li...> - 2010-08-11 17:14:24
|
changeset f2c326ffb36d in /hgrepo/e/en/enblend/enblend details: http://enblend.hg.sourceforge.net/hgweb/enblend/enblend/hgrepo/e/en/enblend/enblend?cmd=changeset;node=f2c326ffb36d description: Validate the XHML documentation files. diffstat: Makefile.am | 4 + README | 6 + VERSION | 2 +- configure.in | 14 ++- doc/Makefile.am | 54 +++++----- doc/color-profiles.texi | 2 - doc/default.css | 2 +- doc/enblend.info | 0 doc/enfuse.info | 0 doc/html2xhtml | 254 ++++++++++++++++++++++++++++++++++++++++++++++++ doc/tidy-post.sed | 25 ---- doc/tidy.cfg | 18 --- doc/versenblend.texi | 4 +- doc/versenfuse.texi | 4 +- 14 files changed, 309 insertions(+), 80 deletions(-) diffs (525 lines): diff -r 5a9da370be6b -r f2c326ffb36d Makefile.am --- a/Makefile.am Tue Aug 10 08:59:16 2010 +0200 +++ b/Makefile.am Wed Aug 11 19:06:14 2010 +0200 @@ -24,3 +24,7 @@ .PHONY: uninstall-xhtml uninstall-xhtml: $(MAKE) --directory=doc $@ + +.PHONY: validate-xhtml +validate-xhtml: + $(MAKE) --directory=doc $@ diff -r 5a9da370be6b -r f2c326ffb36d README --- a/README Tue Aug 10 08:59:16 2010 +0200 +++ b/README Wed Aug 11 19:06:14 2010 +0200 @@ -352,6 +352,10 @@ make pdf make xhtml +The make process automatically ensures the validity of the XHTML +documentation. Additionally, it can be checked with + make validate-xhtml + Note that some additional packages are required to build these formats: makeinfo - GNU documentation generator. @@ -371,6 +375,8 @@ Check out http://www.xfig.org/ for Transfig. tidy - Convert HTML to (almost) XHTML. Tidy is available at http://tidy.sourceforge.net/. + xmllint - Validate XHTML. Get Xmllint e.g. from + http://www.xmlsoft.org/. * Operating System Specific Instructions and Hints diff -r 5a9da370be6b -r f2c326ffb36d VERSION --- a/VERSION Tue Aug 10 08:59:16 2010 +0200 +++ b/VERSION Wed Aug 11 19:06:14 2010 +0200 @@ -1,1 +1,1 @@ -4.1-1e941d40f121 +4.1-5a9da370be6b diff -r 5a9da370be6b -r f2c326ffb36d configure.in --- a/configure.in Tue Aug 10 08:59:16 2010 +0200 +++ b/configure.in Wed Aug 11 19:06:14 2010 +0200 @@ -371,7 +371,7 @@ pngtopnm, false) if test "x$PNGTOPNM" = xfalse; then - AC_MSG_WARN(cannot find pngtopnm; will not be able to build documentation) + AC_MSG_NOTICE(cannot find pngtopnm; will not be able to add transparency to all PNG images) can_build_doc=no missing_for_doc="$missing_for_doc pngtopnm" fi @@ -381,7 +381,7 @@ pnmtopng, false) if test "x$PNMTOPNG" = xfalse; then - AC_MSG_WARN(cannot find pnmtopng; will not be able to build documentation) + AC_MSG_NOTICE(cannot find pnmtopng; will not be able to add transparency to all PNG images) can_build_doc=no missing_for_doc="$missing_for_doc pnmtopng" fi @@ -440,6 +440,16 @@ missing_for_doc="$missing_for_doc tidy" fi +AC_CHECK_PROG(XMLLINT, + xmllint, + xmllint, + false) +if test "x$XMLLINT" = xfalse; then + AC_MSG_WARN(cannot find xmllint; will not be able to build XHTML documentation) + can_build_doc=no + missing_for_doc="$missing_for_doc xmllint" +fi + AM_CONDITIONAL([BUILD_DOC], [test $can_build_doc = yes]) if test $can_build_doc = no; then no_doc_reason=", because of missing$missing_for_doc" diff -r 5a9da370be6b -r f2c326ffb36d doc/Makefile.am --- a/doc/Makefile.am Tue Aug 10 08:59:16 2010 +0200 +++ b/doc/Makefile.am Wed Aug 11 19:06:14 2010 +0200 @@ -44,8 +44,7 @@ TEXI2DVI = texi2dvi $(TEXI2DVIFLAGS) $(EXTRATEXI2DVIFLAGS) -EXTRA_DIST = docstrings \ - tidy.cfg tidy-post.sed +EXTRA_DIST = docstrings # created by make(1), user probably wants to rebuild (often?) MOSTLYCLEANFILES = varsenblend.texi varsenfuse.texi @@ -102,35 +101,24 @@ -rm -rf enblend.xhtml enfuse.xhtml -TIDY_FLAGS = -config $(srcdir)/tidy.cfg -file /dev/null -SED_FLAGS_XHTML = -f $(srcdir)/tidy-post.sed +XMLLINT_FLAGS = --noout --valid + +# The following exported variables are respected by html2xhml(1). +export TIDY SED XMLLINT .PHONY: xhtml -xhtml: $(HTMLS) html-local +xhtml: $(HTMLS:.html=.xhtml) html-local + +.PHONY: validate-xhtml +validate-xhtml: $(HTMLS:.html=.xhtml) for x in $(HTMLS); do \ xhtml=$${x/%.html/.xhtml}; \ - if test -d $$x; then \ - test -d $$xhtml || mkdir $$xhtml; \ - cp *.png $$xhtml; \ - (cd $$x; ls -1 *.html | $(SED) -ne 's#\(.*\)\.html#s|\1\\.html|\1.xhtml|g#p' > fix-refs.sed); \ - for y in $$x/*.html; do \ - if test "$$x/" = "$${y%Table_*}" -o "$$x/" = "$${y%Figure_*}"; then \ - $(SED) -e 's|>| />|' < $$y > $${y//.html/.xhtml}; \ - else \ - $(TIDY) $(TIDY_FLAGS) $$y | \ - $(SED) $(SED_FLAGS_XHTML) \ - -f $$x/fix-refs.sed \ - -e 's|^<head>|<head>\n<meta content="$(VERSION)" name="enblend-version" />|' \ - -e 's|<a\([^>]*\)name="[^"]*"\([^>]*\)|<a\1\2|g' \ - -e 's|\("[^/"]*\)\.html\([#"]\)|\1.xhtml\2|' \ - > $${y//.html/.xhtml}; \ - fi \ - done; \ + if test -d $$xhtml; then \ + for y in $$xhtml/*.xhtml; do \ + $(XMLLINT) $(XMLLINT_FLAGS) $$y; \ + done; \ else \ - $(TIDY) $(TIDY_FLAGS) $$x | \ - $(SED) $(SED_FLAGS_XHTML) \ - -e 's|^<head>|<head>\n<meta content="$(VERSION)" name="enblend-version" />|' \ - -e 's|<a\([^>]*\)name=\([^>]*\)|<a\1id=\2|g' > $$xhtml; \ + $(XMLLINT) $(XMLLINT_FLAGS) $$xhtml; \ fi; \ done @@ -183,7 +171,11 @@ -e 's/^# \?//' < $< > $@ .fig.png: - $(FIG2DEV) -L png -F $< | $(PNGTOPNM) | $(PNMTOPNG) -transparent white > $@ + if test "x$PNGTOPNM" = xfalse -o "x$PNMTOPNG" = xfalse; then \ + $(FIG2DEV) -L png -F $< > $@; \ + else \ + $(FIG2DEV) -L png -F $< | $(PNGTOPNM) | $(PNMTOPNG) -transparent white > $@; \ + fi .fig.eps: $(FIG2DEV) -L eps $< $@ @@ -192,6 +184,14 @@ $(FIG2DEV) -L pdf $< $@ +.html.xhtml: + $(srcdir)/html2xhtml \ + --document-version=$(VERSION) \ + --tidy-flags="$(EXTRATIDYFLAGS)" \ + --xmllint-flags="$(EXTRAXMLLINTFLAGS)" \ + $< + + # Explicit Rules varsenblend.texi: $(srcdir)/../src/enblend.cc \ diff -r 5a9da370be6b -r f2c326ffb36d doc/color-profiles.texi --- a/doc/color-profiles.texi Tue Aug 10 08:59:16 2010 +0200 +++ b/doc/color-profiles.texi Wed Aug 11 19:06:14 2010 +0200 @@ -60,8 +60,6 @@ experience less change when switching the blending spaces. However, colors close the border of any color space can see marked changes. -@sp 2 -@noindent For color geeks: The transformations to @acronym{CIECAM02} color space and back use diff -r 5a9da370be6b -r f2c326ffb36d doc/default.css --- a/doc/default.css Tue Aug 10 08:59:16 2010 +0200 +++ b/doc/default.css Wed Aug 11 19:06:14 2010 +0200 @@ -8,7 +8,7 @@ h1, h2, h3, h4, h5, h6 {margin-left: -4%} dl, h1, h2, h3, h4, h5, h6, ol, p, table, ul {font-family: sans-serif} -code, pre {font-family: monospace; font-size: 110%} +code, pre {font-family: monospace;} var { font-family: sans-serif; font-style: italic diff -r 5a9da370be6b -r f2c326ffb36d doc/enblend.info Binary file doc/enblend.info has changed diff -r 5a9da370be6b -r f2c326ffb36d doc/enfuse.info Binary file doc/enfuse.info has changed diff -r 5a9da370be6b -r f2c326ffb36d doc/html2xhtml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/html2xhtml Wed Aug 11 19:06:14 2010 +0200 @@ -0,0 +1,254 @@ +#! /bin/sh + +# This file is part of Enblend. +# Licence details can be found in the file COPYING. + +# name: html2xhtml +# synopsis: Convert the HTML output of makeinfo(1) to valid XHTML +# author: Dr. Christoph L. Spiel +# bash version: 3.2.39 + + +readonly global__command=`basename $0` + global__document_version=unknown +readonly global__sed=${SED:-sed} +readonly global__tidy=${TIDY:-tidy} + global__tidy_flags="" +readonly global__xmllint=${XMLLINT:-xmllint} + global__xmllint_flags="-valid --noblanks --noent --nsclean --format --encode iso-8859-1" + + +function convert_with_tidy +{ + # We add the system identifier + # "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd" + # with sed(1) after tidy(1). See function postprocess_tidy_output. + + $global__tidy \ + --add-xml-decl yes \ + --doctype '"-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"' \ + --file /dev/null \ + --new-blocklevel-tags "math, mfenced, mfrac, mover, mrow, msqrt, msub, msup, mtable, mtd, mtr, munder, munderover" \ + --new-empty-tags mspace \ + --new-inline-tags "mathinline, mi, mn, mo, mrowinline, msubinline, msupinline, mtext" \ + --sort-attributes alpha \ + --output-encoding latin1 \ + --output-xhtml yes \ + --preserve-entities yes \ + --quiet yes \ + --wrap 0 \ + $global__tidy_flags \ + "$@" +} + + +# We must postprocess tidy(1)'s output, because 1/ it still contains +# elements that make an XML parser puke and 2/ we have intentionally +# introduced pseudo MathML tags to coerce tidy(1) into formatting them +# inline. These tags must be reverted. +function postprocess_tidy_output +{ + $global__sed \ + -e '1,9s|""|"http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd"|' \ + \ + -e "s|^<head>|<head>\n<meta content=\"$global__document_version\" name=\"enblend-version\" />|" \ + \ + -e 's|<html\([^>]*\) lang="[^"]*"\([^>]*\)|<html\1\2|' \ + -e 's|<ol[^>]*>|<ol>|' \ + -e 's|<t\([dh]\)\([^>]*\)width="[^"]*"\([^>]*\)|<t\1\2\3|' \ + -e 's|<ul\([^>]*\)compact="[^"]*"\([^>]*\)|<ul\1\2|' \ + \ + -e 's|<mathinline|<math|g' \ + -e 's|</mathinline|</math|g' \ + -e 's|<mrowinline|<mrow|g' \ + -e 's|</mrowinline|</mrow|g' \ + -e 's|<msubinline|<msub|g' \ + -e 's|</msubinline|</msub|g' \ + -e 's|<msupinline|<msup|g' \ + -e 's|</msupinline|</msup|' +} + + +# Makeinfo(1) generates indirect-reference files for each float. +# Their filenames start with "Table_" or "Figure_*", which is how we +# distinguish them from the html files making up the body. +function is_indirect_reference_file +{ + local filename=$1 + + test -z "${filename%Table_*}" -o -z "${filename%Figure_*}" +} + + +# Convert all html files iside the given directory. +function convert_directory +{ + local html_directory=$1 + local xhtml_directory=${html_directory/%.html/.xhtml} + + test -d $xhtml_directory || mkdir $xhtml_directory + + cp *.png $xhtml_directory + + ( + cd $html_directory + ls -1 *.html | \ + $global__sed -ne 's#\(.*\)\.html#s|\1\\.html|\1.xhtml|g#p' > ,fix-file-refs.sed + ) + + echo -n '' > $html_directory/,fix-indir.sed + for html_file in $html_directory/*.html; do + local html_base=`basename $html_file` + + if is_indirect_reference_file $html_base; then + url=`$global__sed -ne 's#^.*url=\([^"]*\)".*$#\1#p' < $html_file` + target_file=`echo $url | $global__sed -e 's/#.*$//'` + echo "s|$html_base|$target_file|" >> $html_directory/,fix-indir.sed + fi + done + + for html_file in $html_directory/*.html; do + local html_base=`basename $html_file` + + if ! is_indirect_reference_file $html_base; then + local xhtml_file=$xhtml_directory/${html_base/%.html/.xhtml} + + convert_with_tidy $html_file | \ + postprocess_tidy_output | \ + $global__sed \ + -f $html_directory/,fix-indir.sed \ + -f $html_directory/,fix-file-refs.sed \ + -e 's|<a\([^>]*\)name="[^"]*"\([^>]*\)|<a\1\2|g' \ + -e 's|\("[^/"]*\)\.html\([#"]\)|\1.xhtml\2|' | \ + $global__xmllint $global__xmllint_flags --output $xhtml_file - + fi + done +} + + +# Convert a single standalone html file. +function convert_file +{ + local html_file=$1 + local xhtml_file=${html_file/%.html/.xhtml} + + convert_with_tidy $html_file | \ + postprocess_tidy_output | \ + $global__sed -e 's|<a\([^>]*\)name=\([^>]*\)|<a\1id=\2|g' | \ + $global__xmllint $global__xmllint_flags --output $xhtml_file - +} + + +function convert_html_to_xhtml +{ + local html=$1 + + if test -d "$html"; then + convert_directory "$html" + else + convert_file "$html" + fi +} + + +# We prefer to check for all binaries before we get an unpleasant +# surprise in one of the pipes. +function check_binaries +{ + for v in global__sed global__tidy global__xmllint; do + eval x=\$$v + test -z "$x" && { + echo "$global__command: utility \"${v#global__}\" is not defined" 1>&2 + exit 1 + } + $x --version > /dev/null 2>&1 || { + echo "$global__command: cannot execute \"$x\" for \"${v#global__}\"" 1>&2 + exit 1 + } + done +} + + +function parse_options +{ + let n=0 + + while [ -n "$1" ]; do + case "$1" in + --document-version=*) + global__document_version="${1/--document-version=/}" + ;; + -h | --help) + show_help + exit 0 + ;; + --tidy-flags=*) + global__tidy_flags="$global__tidy_flags ${1/--tidy-flags=/}" + ;; + --xmllint-flags=*) + global__xmllint_flags="$global__xmllint_flags ${1/--xmllint-flags=/}" + ;; + + --) + shift + let ++n + break 2 + ;; + + --*) + echo "unknown long option \"$1\"" 1>&2 + exit 1 + ;; + -*) + echo "unknown short option \"$1\"" 1>&2 + exit 1 + ;; + + *) + break 2 + esac + shift + let ++n + done + + return $n +} + + +function show_help +{ + cat <<END_OF_HELP +Usage: $global__command_name [OPTIONS] [HTML...] +Convert HTML files or directories to XHTML. + +Options: + --document-version=VERSION + set meta tag for documentation's version + [default: "$global__document_version"] + --tidy-flags=FLAGS set flags for tidy(1) + --xmllint-flags=FLAGS set flags for xmllint(1) + -h, --help show this help screen + +Influential environment variables: + SED name of sed binary [default: "$global__sed"] + TIDY name of tidy binary [default: "$global__tidy"] + XMLLINT name of xmllint binary [default: "$global__xmllint"] +END_OF_HELP +} + + + +function main +{ + parse_options "$@" + shift $? # shift away all options + + check_binaries + + for x in "$@"; do + convert_html_to_xhtml "$x" + done +} + + +main "$@" diff -r 5a9da370be6b -r f2c326ffb36d doc/tidy-post.sed --- a/doc/tidy-post.sed Tue Aug 10 08:59:16 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -# name: tidy-post.sed -# synopsis: script for postprocessing the output of -# tidy(1) to get a valid XHTML document -# author: Dr. Christoph L. Spiel - - -# The public id is in tidy.cfg. -1,9s|""|"http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd"| - -# Trim attibutes that are not allowed in XHTML. -s|<html\([^>]*\) lang="[^"]*"\([^>]*\)|<html\1\2| -s|<ol[^>]*>|<ol>| -s|<t\([dh]\)\([^>]*\)width="[^"]*"\([^>]*\)|<t\1\2\3| -s|<ul\([^>]*\)compact="[^"]*"\([^>]*\)|<ul\1\2| - -# Undo our dirty work that tricks tidy(1) into correctly -# formatting inline math tags. -s|<mathinline|<math|g -s|</mathinline|</math|g -s|<mrowinline|<mrow|g -s|</mrowinline|</mrow|g -s|<msubinline|<msub|g -s|</msubinline|</msub|g -s|<msupinline|<msup|g -s|</msupinline|</msup|g diff -r 5a9da370be6b -r f2c326ffb36d doc/tidy.cfg --- a/doc/tidy.cfg Tue Aug 10 08:59:16 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -add-xml-decl: yes - -doctype: "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" -# We add the system identifier -# "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd" -# with sed(1) after tidy(1). - -new-blocklevel-tags: math, mfenced, mfrac, mover, mrow, msqrt, msub, msup, mtable, mtd, mtr, munder, munderover -new-empty-tags: mspace -new-inline-tags: mathinline, mi, mn, mo, mrowinline, msubinline, msupinline, mtext -new-pre-tags: - -sort-attributes: alpha -output-encoding: latin1 -output-xhtml: yes -preserve-entities: yes -quiet: yes -wrap: 0 diff -r 5a9da370be6b -r f2c326ffb36d doc/versenblend.texi --- a/doc/versenblend.texi Tue Aug 10 08:59:16 2010 +0200 +++ b/doc/versenblend.texi Wed Aug 11 19:06:14 2010 +0200 @@ -1,4 +1,4 @@ @set UPDATED 31 May 2010 @set UPDATED-MONTH May 2010 -@set EDITION 4.1-1e941d40f121 -@set VERSION 4.1-1e941d40f121 +@set EDITION 4.1-5a9da370be6b +@set VERSION 4.1-5a9da370be6b diff -r 5a9da370be6b -r f2c326ffb36d doc/versenfuse.texi --- a/doc/versenfuse.texi Tue Aug 10 08:59:16 2010 +0200 +++ b/doc/versenfuse.texi Wed Aug 11 19:06:14 2010 +0200 @@ -1,4 +1,4 @@ @set UPDATED 10 August 2010 @set UPDATED-MONTH August 2010 -@set EDITION 4.1-1e941d40f121 -@set VERSION 4.1-1e941d40f121 +@set EDITION 4.1-5a9da370be6b +@set VERSION 4.1-5a9da370be6b |