Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Stephane Crozat
hdoc
Commits
fe385ac9
Commit
fe385ac9
authored
Jan 07, 2017
by
bperraud
Browse files
Flatten of sections divs
parent
d9a9b2c9
Changes
4
Hide whitespace changes
Inline
Side-by-side
hdoc_to_pdf/xsl/find_content.xsl
View file @
fe385ac9
...
...
@@ -65,7 +65,8 @@
<xslt
in=
"{$TempDirectory}/{$path}"
out=
"{$dirpath}/hdoc_nsless.xhtml"
style=
"xsl/ns_remover.xsl"
classpath=
"./lib/saxon9he.jar"
/>
<xslt
in=
"{$dirpath}/hdoc_nsless.xhtml"
out=
"{$dirpath}/flat_hdoc.xhtml"
style=
"xsl/hdoc_flattenizer.xsl"
classpath=
"./lib/saxon9he.jar"
/>
<xslt
in=
"{$dirpath}/flat_hdoc.xhtml"
out=
"{$dirpath}/final.xhtml"
style=
"xsl/last_transformer.xsl"
classpath=
"./lib/saxon9he.jar"
/>
<xslt
in=
"{$dirpath}/flat_hdoc.xhtml"
out=
"{$dirpath}/pre_final.xhtml"
style=
"xsl/toc_generator.xsl"
classpath=
"./lib/saxon9he.jar"
/>
<xslt
in=
"{$dirpath}/pre_final.xhtml"
out=
"{$dirpath}/final.xhtml"
style=
"xsl/last_transformer.xsl"
classpath=
"./lib/saxon9he.jar"
/>
<propertyfile
file=
"{$TempDirectory}/my.properties"
>
<entry
key=
"dirpath"
value=
"{$dirpath}"
/>
...
...
hdoc_to_pdf/xsl/hdoc_flattenizer.xsl
View file @
fe385ac9
...
...
@@ -37,7 +37,7 @@
<!-- "Aplatissement" des sections en div avec numérotation correcte des hn -->
<xsl:template
match=
"section"
>
<xsl:variable
name=
"level"
select=
"count(ancestor::section) + 2"
/>
<div>
<div
class=
"section"
>
<xsl:element
name=
"h{$level}"
>
<xsl:attribute
name=
"id"
>
<xsl:value-of
select=
"concat('h', $level, '-')"
/>
...
...
@@ -49,8 +49,7 @@
</div>
</xsl:template>
<xsl:template
match=
"header"
>
</xsl:template>
<xsl:template
match=
"header"
/>
<xsl:template
match=
"h6"
>
<xsl:variable
name=
"level"
select=
"count(ancestor::section) + 2"
/>
...
...
hdoc_to_pdf/xsl/last_transformer.xsl
View file @
fe385ac9
...
...
@@ -20,13 +20,14 @@
<p
class=
"authors"
><xsl:value-of
select=
"/html/head/meta[@name='author']/@content"
/></p>
<xsl:apply-templates
select=
"node()|@*"
/>
<xsl:call-template
name=
"toc"
>
<xsl:with-param
name=
"toclevel"
select=
"2"
/>
</xsl:call-template>
</body>
</xsl:template>
<!-- Suppression des div de section -->
<xsl:template
match=
"div[@class='section']"
>
<xsl:apply-templates
select=
"node()"
/>
</xsl:template>
<!-- Traitement des liens hypertextes pour autoriser le saut à la ligne-->
<xsl:template
match=
"a"
>
<a>
...
...
@@ -50,75 +51,7 @@
<!-- Cleaning des footers vides -->
<xsl:template
match=
"footer[not(node())]"
/>
<!-- Cleaning des tags -->
<xsl:template
match=
"div[@data-hdoc-type='tags']"
/>
<!-- Gestion de la table des matières -->
<xsl:template
name=
"toc"
>
<xsl:param
name=
"toclevel"
/>
<xsl:variable
name=
"hnlevel"
select=
"concat('h', $toclevel)"
/>
<xsl:choose>
<xsl:when
test=
"$toclevel = 2"
>
<xsl:if
test=
"count(//*[local-name()=$hnlevel]) > 0"
>
<h2
class=
"nocount toc-title"
>
Table des matières
</h2>
<ul
class=
"toc level2"
>
<xsl:for-each
select=
"//*[local-name()=$hnlevel]"
>
<li>
<xsl:call-template
name=
"toc-a"
/>
<xsl:call-template
name=
"toc"
>
<xsl:with-param
name=
"toclevel"
select=
"3"
/>
</xsl:call-template>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:if
test=
"count(..//*[local-name()=$hnlevel]) > 0"
>
<ul
class=
"toc level{$toclevel}"
>
<xsl:for-each
select=
"..//*[local-name()=$hnlevel]"
>
<li>
<xsl:call-template
name=
"toc-a"
/>
<xsl:if
test=
"$toclevel < 4"
>
<xsl:call-template
name=
"toc"
>
<xsl:with-param
name=
"toclevel"
select=
"$toclevel + 1"
/>
</xsl:call-template>
</xsl:if>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template
name=
"toc-a"
>
<a>
<xsl:attribute
name=
"href"
>
<xsl:text>
#
</xsl:text>
<xsl:value-of
select=
"./@id"
/>
</xsl:attribute>
<xsl:value-of
select=
"."
/>
</a>
<span>
<xsl:attribute
name=
"href"
>
<xsl:text>
#
</xsl:text>
<xsl:value-of
select=
"./@id"
/>
</xsl:attribute>
</span>
</xsl:template>
</xsl:stylesheet>
hdoc_to_pdf/xsl/toc_generator.xsl
0 → 100644
View file @
fe385ac9
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform"
version=
"2.0"
xpath-default-namespace=
"http://www.w3.org/1999/xhtml"
xmlns=
"http://www.w3.org/1999/xhtml"
>
<xsl:output
method=
"xml"
indent=
"yes"
/>
<xsl:template
match=
"node()|@*"
>
<xsl:copy>
<xsl:apply-templates
select=
"node()|@*"
/>
</xsl:copy>
</xsl:template>
<!-- Traitement du titre et des auteurs du document -->
<xsl:template
match=
"body"
>
<body>
<xsl:apply-templates
select=
"node()|@*"
/>
<xsl:call-template
name=
"toc"
>
<xsl:with-param
name=
"toclevel"
select=
"2"
/>
</xsl:call-template>
</body>
</xsl:template>
<!-- Gestion de la table des matières -->
<xsl:template
name=
"toc"
>
<xsl:param
name=
"toclevel"
/>
<xsl:variable
name=
"hnlevel"
select=
"concat('h', $toclevel)"
/>
<xsl:choose>
<xsl:when
test=
"$toclevel = 2"
>
<xsl:if
test=
"count(//*[local-name()=$hnlevel]) > 0"
>
<h2
class=
"nocount toc-title"
>
Table des matières
</h2>
<ul
class=
"toc level2"
>
<xsl:for-each
select=
"//*[local-name()=$hnlevel]"
>
<li>
<xsl:call-template
name=
"toc-a"
/>
<xsl:call-template
name=
"toc"
>
<xsl:with-param
name=
"toclevel"
select=
"3"
/>
</xsl:call-template>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:if
test=
"count(..//*[local-name()=$hnlevel]) > 0"
>
<ul
class=
"toc level{$toclevel}"
>
<xsl:for-each
select=
"..//*[local-name()=$hnlevel]"
>
<li>
<xsl:call-template
name=
"toc-a"
/>
<xsl:if
test=
"$toclevel < 4"
>
<xsl:call-template
name=
"toc"
>
<xsl:with-param
name=
"toclevel"
select=
"$toclevel + 1"
/>
</xsl:call-template>
</xsl:if>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template
name=
"toc-a"
>
<a>
<xsl:attribute
name=
"href"
>
<xsl:text>
#
</xsl:text>
<xsl:value-of
select=
"./@id"
/>
</xsl:attribute>
<xsl:value-of
select=
"."
/>
</a>
<span>
<xsl:attribute
name=
"href"
>
<xsl:text>
#
</xsl:text>
<xsl:value-of
select=
"./@id"
/>
</xsl:attribute>
</span>
</xsl:template>
</xsl:stylesheet>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment