Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos: Split paras by \n\n in option descriptions #45930

Merged
merged 1 commit into from Sep 2, 2018

Conversation

aszlig
Copy link
Member

@aszlig aszlig commented Sep 2, 2018

What annoyed me for a long time was the fact, that in order to break into a new paragraph, you need to insert </para><para> in the description attribute of an option.

Now we will automatically create <para/> 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 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 <nixos:option-description/> 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:

<screen><![CDATA[

  one line

  another one

]]></screen>

This would create one <para/> element for one line and another for another line, which we obviously don't want because <screen/> 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 <para/> and leave all elements as-is. If there are more than one <para/> elements at the top-level, we simply don't process it at all, because the description then already contains </para><para>.

Cc: @edolstra, @domenkozar

What annoyed me for a long time was the fact, that in order to break
into a new paragraph, you need to insert </para><para> in the
description attribute of an option.

Now we will automatically create <para/> 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 <nixos:option-description/> 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:

  <screen><![CDATA[

    one line

    another one

  ]]></screen>

This would create one <para/> element for "one line" and another for
"another line", which we obviously don't want because <screen/> 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 <para/> and leave all elements as-is. If there are
more than one <para/> elements at the top-level, we simply don't process
it at all, because the description then already contains </para><para>.

https://www.mhonarc.org/archive/html/xsl-list/2012-09/msg00319.html

Signed-off-by: aszlig <aszlig@nix.build>
Cc: @edolstra, @domenkozar
@grahamc
Copy link
Member

grahamc commented Sep 2, 2018

Looking ...

@grahamc
Copy link
Member

grahamc commented Sep 2, 2018

│ │ │ │ -relevant file to be invoked.
│ │ │ │ -
│ │ │ │ -See the description of the 'F' flag in the kernel docs
│ │ │ │ +relevant file to be invoked.</p><p>See the description of the 'F' flag in the kernel docs
│ │ │ │  for more details.

Nice:

│ │ │ │ -            </a></code></td></tr></table></dd><dt><span class="term"><a id="opt-boot.loader.grub.backgroundColor"></a><a class="term" href="options.html#opt-boot.loader.grub.backgroundColor"><code class="option">boot.loader.grub.backgroundColor</code></a></span></dt><dd><p>Background color to be used for GRUB to fill the areas the image isn't filling.
│ │ │ │ -
│ │ │ │ -</p><div class="note"><h3 class="title">Note</h3><p>
│ │ │ │ +            </a></code></td></tr></table></dd><dt><span class="term"><a id="opt-boot.loader.grub.backgroundColor"></a><a class="term" href="options.html#opt-boot.loader.grub.backgroundColor"><code class="option">boot.loader.grub.backgroundColor</code></a></span></dt><dd><p>Background color to be used for GRUB to fill the areas the image isn't filling.</p><div class="note"><h3 class="title">Note</h3><p>

I spot-checked the results with diffocsope, and everything looked good.

Nicely done!

@grahamc grahamc merged commit 14b0456 into NixOS:master Sep 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants