From f865d0feabfafbb30a9e0659e19a30cb0dc24481 Mon Sep 17 00:00:00 2001 From: aszlig Date: Sun, 2 Sep 2018 05:05:34 +0200 Subject: nixos: Split paras by \n\n in option descriptions What annoyed me for a long time was the fact, that in order to break into a new paragraph, you need to insert in the description attribute of an option. Now we will automatically create elements for every block that is separated by two consecutive newlines. I first tried to do this within options-to-docbook.xsl, but it turns out[1] that this isn't directly possible with XSLT 1.0, so I added another XSLT file that postprocesses the option descriptions that are now enclosed in by options-to-docbook.xsl. The splitting itself is a bit more involved, because we can't simply split on every \n\n because we'd also split text nodes of elements, for example: This would create one element for "one line" and another for "another line", which we obviously don't want because is used to display verbatim contents of what a user is seeing on the screen. So what we do instead is splitting *only* the top-level text nodes within the outermost and leave all elements as-is. If there are more than one elements at the top-level, we simply don't process it at all, because the description then already contains . https://www.mhonarc.org/archive/html/xsl-list/2012-09/msg00319.html Signed-off-by: aszlig Cc: @edolstra, @domenkozar --- nixos/doc/manual/default.nix | 4 +- nixos/doc/manual/options-to-docbook.xsl | 11 +- .../doc/manual/postprocess-option-descriptions.xsl | 115 +++++++++++++++++++++ 3 files changed, 125 insertions(+), 5 deletions(-) create mode 100644 nixos/doc/manual/postprocess-option-descriptions.xsl diff --git a/nixos/doc/manual/default.nix b/nixos/doc/manual/default.nix index be28c2c17af..aaa6e0da545 100644 --- a/nixos/doc/manual/default.nix +++ b/nixos/doc/manual/default.nix @@ -90,7 +90,9 @@ let fi ${buildPackages.libxslt.bin}/bin/xsltproc \ --stringparam revision '${revision}' \ - -o $out ${./options-to-docbook.xsl} $optionsXML + -o intermediate.xml ${./options-to-docbook.xsl} $optionsXML + ${buildPackages.libxslt.bin}/bin/xsltproc \ + -o "$out" ${./postprocess-option-descriptions.xsl} intermediate.xml ''; sources = lib.sourceFilesBySuffices ./. [".xml"]; diff --git a/nixos/doc/manual/options-to-docbook.xsl b/nixos/doc/manual/options-to-docbook.xsl index 2038b0dff63..72ac89d4ff6 100644 --- a/nixos/doc/manual/options-to-docbook.xsl +++ b/nixos/doc/manual/options-to-docbook.xsl @@ -4,6 +4,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:str="http://exslt.org/strings" xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:nixos="tag:nixos.org" xmlns="http://docbook.org/ns/docbook" extension-element-prefixes="str" > @@ -30,10 +31,12 @@ - - - + + + + + diff --git a/nixos/doc/manual/postprocess-option-descriptions.xsl b/nixos/doc/manual/postprocess-option-descriptions.xsl new file mode 100644 index 00000000000..1201c7612c2 --- /dev/null +++ b/nixos/doc/manual/postprocess-option-descriptions.xsl @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit 1.4.1