filter/source/xslt/odf2xhtml/export/xhtml/body.xsl          |   11 ++++
 filter/source/xslt/odf2xhtml/export/xhtml/header.xsl        |   31 ++++++++++++
 filter/source/xslt/odf2xhtml/export/xhtml/opendoc2xhtml.xsl |    6 ++
 3 files changed, 48 insertions(+)

New commits:
commit 5ee2f4ee7838401afdae5eef5669881601fb4ee6
Author:     Franklin Weng <frank...@goodhorse.idv.tw>
AuthorDate: Wed Mar 1 00:04:11 2023 +0800
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Mar 16 11:46:09 2023 +0000

    tdf#153839: add newline after certain tags
    
    Add newline after certain tags in head section and paragraphs, to make 
generated xhtml easier to read.
    
    Change-Id: I9562ef48d9dd1283110be4a45527616dce186681
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148026
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    (cherry picked from commit d2e8705c9cc503afdaed366b1f71ed012b0c568f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148869
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl 
b/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
index 430b834b3cca..ca7a6906b82c 100644
--- a/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
+++ b/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
@@ -50,9 +50,11 @@
     <xsl:key name="writingModeStyles" 
match="/*/office:styles/style:style/style:paragraph-properties/@style:writing-mode
 | 
/*/office:automatic-styles/style:style/style:paragraph-properties/@style:writing-mode"
 use="'test'"/>
     <xsl:template name="create-body">
         <xsl:param name="globalData"/>
+        <xsl:text>&#xa;</xsl:text>
         <xsl:call-template name="create-body.collect-page-properties">
             <xsl:with-param name="globalData" select="$globalData"/>
         </xsl:call-template>
+        <xsl:text>&#xa;</xsl:text>
     </xsl:template>
 
     <xsl:template name="create-body.collect-page-properties">
@@ -178,6 +180,7 @@
                     </xsl:if>
                 </xsl:attribute>
             </xsl:if>
+            <xsl:text>&#xa;</xsl:text>
             <!-- processing the content of the OpenDocument content file -->
             <xsl:apply-templates select="/*/office:body/*">
                 <xsl:with-param name="globalData" select="$globalData"/>
@@ -233,6 +236,7 @@
                 <xsl:with-param name="globalData" select="$globalData"/>
             </xsl:apply-templates>
         </xsl:element>
+        <xsl:text>&#xa;</xsl:text>
     </xsl:template>
 
 
@@ -472,10 +476,12 @@
                         </xsl:if>
                     </xsl:when>
                     <xsl:otherwise>
+                        <xsl:text>&#xa;</xsl:text>
                         <xsl:call-template name="create-paragraph">
                             <xsl:with-param name="globalData" 
select="$globalData" />
                             <xsl:with-param name="footnotePrefix" 
select="$footnotePrefix" />
                         </xsl:call-template>
+                        <xsl:text>&#xa;</xsl:text>
                     </xsl:otherwise>
                 </xsl:choose>
             </xsl:otherwise>
@@ -547,6 +553,7 @@
                         <xsl:with-param name="globalData" 
select="$globalData"/>
                     </xsl:apply-templates>
                 </xsl:element>
+                <xsl:text>&#xa;</xsl:text>
                 <xsl:apply-templates select="following-sibling::node()[1]" 
mode="tabHandling">
                     <xsl:with-param name="globalData" select="$globalData"/>
                     <xsl:with-param name="tabStops" select="$tabStops"/>
@@ -558,6 +565,7 @@
             <xsl:when test="name() = 'text:line-break'">
                 <!-- A line-break resets the tabCount to '0' -->
                 <br/>
+                <xsl:text>&#xa;</xsl:text>
                 <xsl:apply-templates select="following-sibling::node()[1]" 
mode="tabHandling">
                     <xsl:with-param name="globalData" select="$globalData"/>
                     <xsl:with-param name="tabStops" select="$tabStops"/>
@@ -565,6 +573,7 @@
                     <xsl:with-param name="parentMarginLeft" 
select="$parentMarginLeft"/>
                     <xsl:with-param name="pageMarginLeft" 
select="$pageMarginLeft"/>
                 </xsl:apply-templates>
+                <xsl:text>&#xa;</xsl:text>
             </xsl:when>
             <xsl:otherwise>
                 <!-- only before the first tab all content is written out -->
@@ -580,6 +589,7 @@
                     <xsl:with-param name="parentMarginLeft" 
select="$parentMarginLeft"/>
                     <xsl:with-param name="pageMarginLeft" 
select="$pageMarginLeft"/>
                 </xsl:apply-templates>
+                <xsl:text>&#xa;</xsl:text>
             </xsl:otherwise>
         </xsl:choose>
     </xsl:template>
@@ -1193,6 +1203,7 @@
             </xsl:apply-templates>
         </xsl:element>
 
+        <xsl:text>&#xa;</xsl:text>
     </xsl:template>
 
     <xsl:template name="create-heading-anchor">
diff --git a/filter/source/xslt/odf2xhtml/export/xhtml/header.xsl 
b/filter/source/xslt/odf2xhtml/export/xhtml/header.xsl
index 2bd07d8d29e4..581b8b8d3421 100644
--- a/filter/source/xslt/odf2xhtml/export/xhtml/header.xsl
+++ b/filter/source/xslt/odf2xhtml/export/xhtml/header.xsl
@@ -55,12 +55,14 @@
     <xsl:template name="create-header">
         <xsl:param name="globalData" />
 
+        <xsl:text>&#xa;</xsl:text>
         <xsl:element name="head">
         <xsl:attribute 
name="profile">http://dublincore.org/documents/dcmi-terms/</xsl:attribute>
             <xsl:if test="$debugEnabled"><xsl:message>CSS helper variable will 
be created...</xsl:message></xsl:if>
             <xsl:call-template name='xhtml-header-properties'>
                 <xsl:with-param name="globalData" select="$globalData" />
             </xsl:call-template>
+            <xsl:text>&#xa;</xsl:text>
 
             <xsl:if test="$debugEnabled"><xsl:message>CSS variable ready, 
header will be created...</xsl:message></xsl:if>
             <!-- constructing the css header simulating inheritance of 
style-families by style order -->
@@ -68,6 +70,7 @@
                 <xsl:with-param name="globalData" select="$globalData" />
             </xsl:call-template>
             <xsl:if test="$debugEnabled"><xsl:message>CSS header creation 
finished!</xsl:message></xsl:if>
+            <xsl:text>&#xa;</xsl:text>
         </xsl:element>
 
     </xsl:template>
@@ -246,11 +249,13 @@
         <xsl:for-each 
select="$globalData/meta-file/*/office:meta/meta:user-defined">
         <xsl:if test="./@meta:name='ODF.base'">
         <xsl:value-of select="." />
+        <xsl:text>&#xa;</xsl:text>
         </xsl:if>
         </xsl:for-each>
         <xsl:for-each 
select="$globalData/meta-file/*/office:meta/meta:user-defined">
         <xsl:if test="./@meta:name='ODF.filename'">
         <xsl:value-of select="." />
+        <xsl:text>&#xa;</xsl:text>
         </xsl:if>
         </xsl:for-each>
         </xsl:variable>
@@ -262,6 +267,7 @@
                  </xsl:when>
                  <xsl:otherwise>en-US</xsl:otherwise>
              </xsl:choose>
+             <xsl:text>&#xa;</xsl:text>
         </xsl:variable>
 
         <xsl:variable name="prov">
@@ -271,6 +277,7 @@
                  </xsl:when>
                  <xsl:otherwise />
              </xsl:choose>
+             <xsl:text>&#xa;</xsl:text>
         </xsl:variable>
 
         <xsl:variable name="keywords">
@@ -280,13 +287,16 @@
                         <xsl:text>, </xsl:text>
                     </xsl:if>
             </xsl:for-each>
+            <xsl:text>&#xa;</xsl:text>
         </xsl:variable>
 
+        <xsl:text>&#xa;</xsl:text>
         <!-- explicit output content-type for low-tech browser (e.g. IE6) -->
         <xsl:element name="meta">
             <xsl:attribute name="http-equiv">Content-Type</xsl:attribute>
             <xsl:attribute name="content">application/xhtml+xml; 
charset=utf-8</xsl:attribute>
         </xsl:element>
+        <xsl:text>&#xa;</xsl:text>
 
         <!-- title of document for browser frame title -->
         <xsl:element name="title">
@@ -304,6 +314,7 @@
                 </xsl:otherwise>
             </xsl:choose>
         </xsl:element>
+        <xsl:text>&#xa;</xsl:text>
 
         <!-- title, in DC syntax -->
         <xsl:element name="meta">
@@ -315,6 +326,7 @@
                <xsl:value-of select="$lang" />
             </xsl:attribute>
         </xsl:element>
+        <xsl:text>&#xa;</xsl:text>
 
         <!-- the identifier for source  (identifier) -->
         <xsl:call-template name="add-meta-tag">
@@ -322,6 +334,7 @@
             <xsl:with-param name="meta-data" select="translate($netloc, ' 
','')" />
             <xsl:with-param name="meta-enc" select="'DCTERMS.URI'" />
         </xsl:call-template>
+        <xsl:text>&#xa;</xsl:text>
 
         <!-- the language for source  (language) -->
         <xsl:call-template name="add-meta-tag">
@@ -329,18 +342,21 @@
             <xsl:with-param name="meta-data" select="$lang" />
             <xsl:with-param name="meta-enc" select="'DCTERMS.RFC4646'" />
         </xsl:call-template>
+        <xsl:text>&#xa;</xsl:text>
 
         <!-- a bit commercial (generator) -->
         <xsl:element name="meta">
             <xsl:attribute name="name">DCTERMS.source</xsl:attribute>
             <xsl:attribute 
name="content">http://xml.openoffice.org/odf2xhtml</xsl:attribute>
         </xsl:element>
+        <xsl:text>&#xa;</xsl:text>
 
         <!-- the author of the input source (author) -->
         <xsl:call-template name="add-meta-tag">
             <xsl:with-param name="meta-name" select="'DCTERMS.creator'" />
             <xsl:with-param name="meta-data" 
select="$globalData/meta-file/*/office:meta/meta:initial-creator" />
         </xsl:call-template>
+        <xsl:text>&#xa;</xsl:text>
 
         <!-- creation-date of the input source (issued) -->
         <xsl:call-template name="add-meta-tag">
@@ -348,12 +364,14 @@
             <xsl:with-param name="meta-data" 
select="$globalData/meta-file/*/office:meta/meta:creation-date" />
             <xsl:with-param name="meta-enc" select="'DCTERMS.W3CDTF'" />
         </xsl:call-template>
+        <xsl:text>&#xa;</xsl:text>
 
         <!-- name of last changing person of the input source (changedby) -->
         <xsl:call-template name="add-meta-tag">
             <xsl:with-param name="meta-name" select="'DCTERMS.contributor'" />
             <xsl:with-param name="meta-data" 
select="$globalData/meta-file/*/office:meta/dc:creator" />
         </xsl:call-template>
+        <xsl:text>&#xa;</xsl:text>
 
         <!-- last changing date of the input source (changed) -->
         <xsl:call-template name="add-meta-tag">
@@ -361,6 +379,7 @@
             <xsl:with-param name="meta-data" 
select="$globalData/meta-file/*/office:meta/dc:date" />
             <xsl:with-param name="meta-enc" select="'DCTERMS.W3CDTF'" />
         </xsl:call-template>
+        <xsl:text>&#xa;</xsl:text>
 
         <!-- Last print, as provenance -->
         <xsl:if test="$prov">
@@ -369,6 +388,7 @@
             <xsl:with-param name="meta-data" select="$prov" />
             <xsl:with-param name="meta-lang" select="$lang" />
         </xsl:call-template>
+        <xsl:text>&#xa;</xsl:text>
         </xsl:if>
 
         <!-- keywords about the input source (keywords) -->
@@ -380,6 +400,7 @@
                         <xsl:with-param name="meta-data" 
select="normalize-space(concat($globalData/meta-file/*/office:meta/dc:subject,',
 ',$keywords))" />
                         <xsl:with-param name="meta-lang" select="$lang" />
                     </xsl:call-template>
+                    <xsl:text>&#xa;</xsl:text>
                 </xsl:when>
                 <xsl:when 
test="($globalData/meta-file/*/office:meta/dc:subject != '')">
                     <xsl:call-template name="add-meta-tag">
@@ -387,6 +408,7 @@
                         <xsl:with-param name="meta-data" 
select="normalize-space($globalData/meta-file/*/office:meta/dc:subject)" />
                         <xsl:with-param name="meta-lang" select="$lang" />
                     </xsl:call-template>
+                    <xsl:text>&#xa;</xsl:text>
                 </xsl:when>
                 <xsl:otherwise>
                     <xsl:call-template name="add-meta-tag">
@@ -394,6 +416,7 @@
                         <xsl:with-param name="meta-data" 
select="normalize-space($keywords)" />
                         <xsl:with-param name="meta-lang" select="$lang" />
                     </xsl:call-template>
+                    <xsl:text>&#xa;</xsl:text>
                 </xsl:otherwise>
             </xsl:choose>
         </xsl:if>
@@ -404,6 +427,7 @@
             <xsl:with-param name="meta-data" 
select="$globalData/meta-file/*/office:meta/dc:description" />
             <xsl:with-param name="meta-lang" select="$lang" />
         </xsl:call-template>
+        <xsl:text>&#xa;</xsl:text>
 
 
         <!-- user defined use of DCTERM tags -->
@@ -413,6 +437,7 @@
             <xsl:with-param name="meta-data" select="." />
             <!-- <xsl:with-param name="meta-lang" select="$lang" /> -->
         </xsl:call-template>
+        <xsl:text>&#xa;</xsl:text>
         </xsl:for-each>
         <!-- user defined use of DC tags (legacy) -->
         <xsl:for-each 
select="$globalData/meta-file/*/office:meta/meta:user-defined[starts-with(@meta:name,'DC.')][not(.='')]">
@@ -421,16 +446,22 @@
             <xsl:with-param name="meta-data" select="." />
             <!-- <xsl:with-param name="meta-lang" select="$lang" /> -->
         </xsl:call-template>
+        <xsl:text>&#xa;</xsl:text>
         </xsl:for-each>
         <xsl:call-template name="add-meta-tag">
             <xsl:with-param name="meta-name" select="'xsl:vendor'" />
             <xsl:with-param name="meta-data" 
select="system-property('xsl:vendor')" />
         </xsl:call-template>
+        <xsl:text>&#xa;</xsl:text>
 
         <link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"; 
hreflang="en" />
+        <xsl:text>&#xa;</xsl:text>
         <link rel="schema.DCTERMS" href="http://purl.org/dc/terms/"; 
hreflang="en" />
+        <xsl:text>&#xa;</xsl:text>
         <link rel="schema.DCTYPE" href="http://purl.org/dc/dcmitype/"; 
hreflang="en" />
+        <xsl:text>&#xa;</xsl:text>
         <link rel="schema.DCAM" href="http://purl.org/dc/dcam/"; hreflang="en" 
/>
+        <xsl:text>&#xa;</xsl:text>
         <!-- W3C GRDDL Profile -->
         <!--
         <link rel="transformation" 
href="http://xml.openoffice.org/odf2xhtml/rdf-extract.xsl"; />
diff --git a/filter/source/xslt/odf2xhtml/export/xhtml/opendoc2xhtml.xsl 
b/filter/source/xslt/odf2xhtml/export/xhtml/opendoc2xhtml.xsl
index 196b85eae859..d65831a8338c 100644
--- a/filter/source/xslt/odf2xhtml/export/xhtml/opendoc2xhtml.xsl
+++ b/filter/source/xslt/odf2xhtml/export/xhtml/opendoc2xhtml.xsl
@@ -154,18 +154,24 @@
              </xsl:choose>
         </xsl:variable>
 
+        <xsl:text>&#xa;</xsl:text>
         <xsl:element name="html">
 
             <xsl:attribute name="lang"><xsl:value-of 
select="$lang"/></xsl:attribute>
+            <xsl:text>&#xa;</xsl:text>
             <xsl:comment>This file was converted to xhtml by LibreOffice - see 
https://cgit.freedesktop.org/libreoffice/core/tree/filter/source/xslt for the 
code.</xsl:comment>
+            <xsl:text>&#xa;</xsl:text>
             <xsl:call-template name='create-header'>
                 <xsl:with-param name="globalData" select="$globalData" />
             </xsl:call-template>
 
+            <xsl:text>&#xa;</xsl:text>
             <xsl:call-template name='create-body'>
                 <xsl:with-param name="globalData" select="$globalData" />
             </xsl:call-template>
+            <xsl:text>&#xa;</xsl:text>
         </xsl:element>
+        <xsl:text>&#xa;</xsl:text>
     </xsl:template>
 
 

Reply via email to