Skip to content

Commit

Permalink
[mod-sbs] Make .precedingseparator work in combination with .noindent
Browse files Browse the repository at this point in the history
  • Loading branch information
bertfrees committed Aug 9, 2018
1 parent d94a29c commit 4e38fc0
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 18 deletions.
29 changes: 14 additions & 15 deletions modules/sbs/braille/src/main/resources/css/default.scss
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ p {
text-indent: 2;
}

.precedingemptyline{
.precedingemptyline {
margin-top:1;
}

Expand All @@ -854,20 +854,19 @@ hr.emptyline {

$separator-width: 6;

p.precedingseparator {
text-indent: 0;
&::before {
content: "\A" /* empty line */
repeat(" ", ($page-width - $separator-width)/2) /* centering */
repeat("", $separator-width) "\A" /* separator */
"\A" /* empty line */
"  "; /* text indent */
white-space: pre-line;
text-transform: none;
hyphens: initial;
}
}

/*
* Depends on handle-precedingseparator.xsl, which inserts hr elements
* before elements with class "precedingseparator":
* ~~~
* <p class="precedingseparator"/>
* ~~~
* in the input becomes:
* ~~~
* <hr class="separator"/>
* <p/>
* ~~~
* before any CSS is applied.
*/
hr.separator {
display: block;
text-align: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
resolve-uri('handle-toc-and-running-line.xsl'),
resolve-uri('handle-dl.xsl'),
resolve-uri('handle-pageref.xsl'),
resolve-uri('handle-precedingseparator.xsl'),
resolve-uri('insert-boilerplate.xsl'),
$stylesheet),' ')">
<p:inline>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dtb="http://www.daisy.org/z3986/2005/dtbook/"
exclude-result-prefixes="#all">

<!--
Insert hr.separator before elements with class "precedingseparator"
-->

<xsl:template match="*[@class]">
<xsl:choose>
<xsl:when test="tokenize(@class,'\s+')='precedingseparator'">
<dtb:hr class="separator"/>
<xsl:copy>
<xsl:apply-templates select="@* except @class"/>
<xsl:variable name="classes" as="xs:string*" select="tokenize(@class,'\s+')[not(.=('','precedingseparator'))]"/>
<xsl:if test="exists($classes)">
<xsl:attribute name="class" select="string-join($classes,' ')"/>
</xsl:if>
<xsl:apply-templates/>
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:next-match/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@
<level1>
<p> Bla bla bla </p>
<p class="precedingseparator"> Bla bla bla </p>
<p> Bla bla bla </p>
<p class="precedingseparator noindent"> Bla bla bla </p>
</level1>
</bodymatter>
</book>
Expand Down Expand Up @@ -242,11 +244,11 @@
<row>⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠒⠒⠒⠒⠒⠒</row>
<row/>
<row>⠀⠀⠃⠇⠁⠀⠃⠇⠁⠀⠃⠇⠁</row>
<row/>
<row/>
<row/>
<row>⠀⠀⠃⠇⠁⠀⠃⠇⠁⠀⠃⠇⠁</row>
<row/>
<row>⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠒⠒⠒⠒⠒⠒</row>
<row/>
<row>⠃⠇⠁⠀⠃⠇⠁⠀⠃⠇⠁</row>
<row/>
<row/>
<row/>
Expand Down

0 comments on commit 4e38fc0

Please sign in to comment.