Skip to content

Commit

Permalink
Theatre better handling
Browse files Browse the repository at this point in the history
  • Loading branch information
glorieux-f committed Apr 4, 2024
1 parent a77f098 commit 27f70ee
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 24 deletions.
16 changes: 9 additions & 7 deletions docx/docx_teilike.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,16 @@
<xsl:template match="mc:Fallback"/>
<!-- Recursive search for title level -->
<xsl:template name="lvl">
<xsl:param name="w:style" select="nonode"/>
<xsl:param name="style-name"/>
<xsl:variable name="w:style" select="key('w:style', $style-name)"/>
<xsl:choose>
<xsl:when test="not($w:style)"/>
<xsl:when test="$w:style/w:pPr/w:outlineLvl/@w:val">
<xsl:value-of select="$w:style/w:pPr/w:outlineLvl/@w:val"/>
</xsl:when>
<xsl:when test="$w:style/w:basedOn">
<xsl:call-template name="lvl">
<xsl:with-param name="w:style" select="key('w:style', $w:style/w:basedOn)"/>
<xsl:with-param name="style-name" select="$w:style/w:basedOn/@w:val"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
Expand All @@ -113,7 +115,9 @@
</xsl:variable>
<xsl:variable name="teinte_p" select="key('teinte_p', $style_name)"/>
<xsl:variable name="lvl">
<xsl:call-template name="lvl"/>
<xsl:call-template name="lvl">
<xsl:with-param name="style-name" select="w:pPr/w:pStyle/@w:val"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<!-- para in table cell -->
Expand Down Expand Up @@ -162,7 +166,7 @@
</xsl:when>
<!-- known semantic style names, should not be structuring heading (?) -->
<!-- Bug lev -->
<xsl:when test="number($lvl) &gt; 0 and number($lvl) &lt; 9 and not(ancestor::w:tc|ancestor::w:footnote)">
<xsl:when test="number($lvl) &gt;= 0 and number($lvl) &lt; 9 and not(ancestor::w:tc|ancestor::w:footnote)">
<head level="{$lvl+1}">
<xsl:apply-templates select="w:hyperlink | w:r"/>
</head>
Expand Down Expand Up @@ -640,9 +644,7 @@ Seen
<xsl:template match="w:sectPr"/>
<!-- spaces -->
<xsl:template match="w:tab">
<space rend="tab">
<xsl:text> </xsl:text>
</space>
<xsl:text> </xsl:text>
</xsl:template>
<!--
<w:tblGrid>
Expand Down
3 changes: 2 additions & 1 deletion docx/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ LGPL http://www.gnu.org/licenses/lgpl.html
<style level="0" name="notesdebasdepage"/>
<style level="0" name="notedefin"/>
<style level="0" name="notesdefin"/>
<style level="0" name="standard"/>
<style level="0" name="style"/>
<style level="0" name="texte"/>
<style level="0" name="texteducorps"/>
Expand Down Expand Up @@ -202,7 +203,7 @@ LGPL http://www.gnu.org/licenses/lgpl.html
<style level="p" name="signed" element="signed" doc="true"/>
<style level="p" name="signature" element="signed"/>
<style level="p" name="soustitre" element="head" attribute="type" value="sub"/>
<style level="p" name="speaker" element="speaker" doc="true"/>
<style level="p" name="speaker" element="speaker" doc="true"/>
<style level="p" name="stage" element="stage" doc="true"/>
<style level="p" name="stageromain" element="stage" attribute="rend" value="not-i"/>
<style level="p" name="stageitaliquecourt" element="stage" attribute="rend" value="right"/>
Expand Down
49 changes: 33 additions & 16 deletions docx/tei_tmpl.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,34 @@ s#</(bg|color|font|mark)_[^>]+>#</hi>#g
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Generate who value candidate -->
<xsl:template name="who">
<!-- No note -->
<xsl:variable name="text" select="text()"/>
<xsl:variable name="who">
<xsl:choose>
<xsl:when test="contains($text, ',')">
<xsl:value-of select="substring-before(., ',')"/>
</xsl:when>
<xsl:when test="contains($text, '.')">
<xsl:value-of select="substring-before(., '.')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="translate(normalize-space($who),$ABC ,$abc)"/>
</xsl:template>
<!-- role, id for speaker -->
<xsl:template match="tei:role">
<xsl:copy>
<xsl:attribute name="xml:id">
<xsl:call-template name="who"/>
</xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- -->
<xsl:template match="tei:div">
<xsl:variable name="head" select="translate(normalize-space(tei:head), $ABC, $abc)"/>
Expand All @@ -622,31 +650,20 @@ s#</(bg|color|font|mark)_[^>]+>#</hi>#g
<xsl:variable name="first" select="generate-id(tei:speaker[1])"/>
<xsl:apply-templates select="*[following-sibling::*[generate-id()=$first]]"/>
<xsl:for-each select="tei:speaker">
<xsl:text>&#10;</xsl:text>
<sp>
<xsl:attribute name="who">
<!-- No note -->
<xsl:variable name="text" select="text()"/>
<xsl:variable name="who">
<xsl:choose>
<xsl:when test="contains($text, ',')">
<xsl:value-of select="substring-before(., ',')"/>
</xsl:when>
<xsl:when test="contains($text, '.')">
<xsl:value-of select="substring-before(., '.')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="translate(normalize-space($who),$ABC ,$abc)"/>
<xsl:call-template name="who"/>
</xsl:attribute>
<xsl:copy-of select="tei:anchor[1]/@xml:id"/>
<xsl:text>&#10;</xsl:text>
<xsl:apply-templates select="."/>
<xsl:for-each select="following-sibling::*[1]">
<xsl:call-template name="sp"/>
</xsl:for-each>
<xsl:text>&#10;</xsl:text>
</sp>
<xsl:text>&#10;</xsl:text>
</xsl:for-each>
</xsl:copy>
</xsl:when>
Expand Down

0 comments on commit 27f70ee

Please sign in to comment.