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 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'nixos/doc/manual/default.nix') 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"]; -- cgit 1.4.1