add support for new "texte adopté" document (#10328)

This commit is contained in:
Frédéric Péters 2016-11-01 17:24:20 +01:00
parent 36678eecf7
commit 01a7bd6f00
2 changed files with 24 additions and 1 deletions

View File

@ -253,10 +253,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
</xsl:if>
<xsl:call-template name="content-templates"/>
<xsl:if test="not($parchemin)">
<xsl:text>\end{multicols}&#10;</xsl:text>
<xsl:choose>
<!-- if it's a document getting straight to a legistic level we keep
the columns open and they'll get closed when the end-of-document
processing instruction will be met.
-->
<xsl:when test="not(following-sibling::legistic_title)"></xsl:when>
<xsl:when test="not(following-sibling::legistic_chapter)"></xsl:when>
<xsl:when test="not(following-sibling::legistic_section)"></xsl:when>
<xsl:otherwise>
<xsl:text>\end{multicols}&#10;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<xsl:template match="processing-instruction('end-of-document')">
<xsl:if test="not($parchemin)">
<!-- columns have been left open after <nosection/>, they must be closed
now that the end of the document has been reached.
-->
<xsl:if test="//nosection/following-sibling::legistic_title"><xsl:text>\end{multicols}&#10;</xsl:text></xsl:if>
<xsl:if test="//nosection/following-sibling::legistic_chapter"><xsl:text>\end{multicols}&#10;</xsl:text></xsl:if>
<xsl:if test="//nosection/following-sibling::legistic_section"><xsl:text>\end{multicols}&#10;</xsl:text></xsl:if>
</xsl:if>
</xsl:template>
<xsl:template match="part">
<xsl:param name="bridgehead" select="ancestor::preface|ancestor::colophon|ancestor::dedication"/>

View File

@ -1140,6 +1140,8 @@ def convert_to_legi_xml(content, metadata=None, styles=None):
# clear it.
offstructure.remove(offstructure.getchildren()[0])
legi.append(ET.ProcessingInstruction('end-of-document'))
# get content as an XML tree
out = StringIO()
ET.ElementTree(legi).write(out)