Merged ghost sections without title while preserving role=restriction*

When exporting the DocBook template to Markdown or PDF (there might be more cases in formats not tested), Pandoc still includes a section into the exported format even when it doesn't have a title.

In the Markdown files, this means added lines `##` in-between ```Any use by a business that is privately owned and managed, and that seeks to generate profit from the labor of employees paid by salary or other wages, is not permitted under this license.``` and ```You may exercise the rights granted in the license grant for any purposes only if:```.

When the license doesn't strip out elements with `role=restriction-attribution` (for the no-attribution licenses), there's another empty section title between ```You do not use the Work to either Discriminate or spread Hate Speech on the basis of sex, sexual orientation, gender identity, race, age, disability, color, national origin, religion, caste, or lower economic status.``` and ```If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made by any Licensor to remove credit from a Collection or Adaptation, keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing:```

This is an issue when exporting the Markdown license files to PDFs, because these ghost sections will be visible in the outline viewer of a PDF reader. Might also be a potential issue if users want to generate a table of contents or index along with their PDF — it might put these ghost section in, too.

To fix this, DocBook doesn't have a special "ghost section" type (closest is a `<bridgehead>`, but that completely screws over formatting), so the contents of the ghost sections were merged into its parent with the `role` of the ghost section in mind.

Output was sanity-tested with these commands:
```sh
$ xml ed -d "/article/info" template.xml | xml ed -d "*/*/*[@role='restriction']" | pandoc -f docbook -t markdown -s -o test-modified.md
$ xml ed -d "/article/info" template-original.xml | xml ed -d "*/*/*[@role='restriction']" | pandoc -f docbook -t markdown -s -o test-original.md
$ diff test-original.md test-modified.md
215,216d214
< ## 
<``` `template-original.xml` is the file from this branch's last commit, c706fa6efc5ecd7217342fa5f7e23fdc613fb07b.
This commit is contained in:
Endo 2022-09-28 17:27:49 +02:00 committed by Endo
parent 43901c4dd1
commit bfa8363f8c

View file

@ -60,29 +60,25 @@
<para role="restriction">If the Work meets the definition of Software, You may exercise the rights granted in the license grant only if You provide a copy of the corresponding Source Code from which the Work was derived in digital form, or You provide a URI for the corresponding Source Code of the Work, to any recipients upon request.</para>
<para role="restriction">If the Work is used as or for a Network Service, You may exercise the rights granted in the license grant only if You provide a copy of the corresponding Source Code from which the Work was derived in digital form, or You provide a URI for the corresponding Source Code to the Work, to any recipients of the data served or modified by the Web Service.</para>
<para role="restriction-cooperative">Any use by a business that is privately owned and managed, and that seeks to generate profit from the labor of employees paid by salary or other wages, is not permitted under this license.</para>
<section role="restriction">
<para>You may exercise the rights granted in the license grant for any purposes only if:</para>
<orderedlist numeration="lowerroman">
<listitem><para>You do not use the Work for the purpose of inflicting Bodily Harm on human beings (subject to criminal prosecution or otherwise) outside of providing medical aid or undergoing a voluntary procedure under no form of Coercion.</para></listitem>
<listitem><para>You do not use the Work for the purpose of Surveilling or tracking individuals for financial gain.</para></listitem>
<listitem><para>You do not use the Work in an Act of War.</para></listitem>
<listitem><para>You do not use the Work for the purpose of supporting or profiting from an Act of War.</para></listitem>
<listitem><para>You do not use the Work for the purpose of Incarceration.</para></listitem>
<listitem><para>You do not use the Work for the purpose of extracting, processing, or refining, oil, gas, or coal. Or to in any other way to deliberately pollute the environment as a byproduct of manufacturing or irresponsible disposal of hazardous materials.</para></listitem>
<listitem><para>You do not use the Work for the purpose of expediting, coordinating, or facilitating paid work undertaken by individuals under the age of 12 years.</para></listitem>
<listitem><para>You do not use the Work to either Discriminate or spread Hate Speech on the basis of sex, sexual orientation, gender identity, race, age, disability, color, national origin, religion, caste, or lower economic status.</para></listitem>
</orderedlist>
</section>
<section role="restriction-attribution">
<para>If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made by any Licensor to remove credit from a Collection or Adaptation, keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing:</para>
<orderedlist numeration="lowerroman">
<listitem><para>the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties;</para></listitem>
<listitem><para>the title of the Work if supplied;</para></listitem>
<listitem><para>to the extent reasonably practicable, the URI, if any, that Licensor to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and,</para></listitem>
<listitem><para>in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author").</para></listitem>
</orderedlist>
<para>If any Licensor has sent notice to request removing credit, You must, to the extent practicable, remove any credit as requested. The credit required by this Section may be implemented in any reasonable manner; provided, however, that in the case of an Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties.</para>
</section>
<para role="restriction">You may exercise the rights granted in the license grant for any purposes only if:</para>
<orderedlist numeration="lowerroman" role="restriction">
<listitem><para>You do not use the Work for the purpose of inflicting Bodily Harm on human beings (subject to criminal prosecution or otherwise) outside of providing medical aid or undergoing a voluntary procedure under no form of Coercion.</para></listitem>
<listitem><para>You do not use the Work for the purpose of Surveilling or tracking individuals for financial gain.</para></listitem>
<listitem><para>You do not use the Work in an Act of War.</para></listitem>
<listitem><para>You do not use the Work for the purpose of supporting or profiting from an Act of War.</para></listitem>
<listitem><para>You do not use the Work for the purpose of Incarceration.</para></listitem>
<listitem><para>You do not use the Work for the purpose of extracting, processing, or refining, oil, gas, or coal. Or to in any other way to deliberately pollute the environment as a byproduct of manufacturing or irresponsible disposal of hazardous materials.</para></listitem>
<listitem><para>You do not use the Work for the purpose of expediting, coordinating, or facilitating paid work undertaken by individuals under the age of 12 years.</para></listitem>
<listitem><para>You do not use the Work to either Discriminate or spread Hate Speech on the basis of sex, sexual orientation, gender identity, race, age, disability, color, national origin, religion, caste, or lower economic status.</para></listitem>
</orderedlist>
<para role="restriction-attribution">If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made by any Licensor to remove credit from a Collection or Adaptation, keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing:</para>
<orderedlist numeration="lowerroman" role="restriction-attribution">
<listitem><para>the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties;</para></listitem>
<listitem><para>the title of the Work if supplied;</para></listitem>
<listitem><para>to the extent reasonably practicable, the URI, if any, that Licensor to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and,</para></listitem>
<listitem><para>in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author").</para></listitem>
</orderedlist>
<para role="restriction-attribution">If any Licensor has sent notice to request removing credit, You must, to the extent practicable, remove any credit as requested. The credit required by this Section may be implemented in any reasonable manner; provided, however, that in the case of an Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties.</para>
<para role="restriction-cooperative">Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License</para>
<para role="restriction-cooperative">Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License if Your exercise of such rights is for a purpose or use which is otherwise than noncommercial as permitted under Commercial Restrictions and otherwise waives the right to collect royalties through any statutory or compulsory licensing scheme.</para>
<para role="restriction-cooperative">Voluntary License Schemes. The Licensor reserves the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License that is for a purpose or use which is otherwise than noncommercial as permitted under the license grant.</para>