Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

476 landscape #478

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 36 additions & 5 deletions src/guide/xml/ch02.xml
Original file line number Diff line number Diff line change
Expand Up @@ -896,10 +896,6 @@ purpose:</para>
</tgroup>
</table>

<para>In addition, the stylesheets support profiling on several common attributes
that are not explicitly for effectivity: <att>xml:lang</att>, <att>revisionflag</att>,
and <att>role</att>.</para>

<note>
<para>DocBook places no constraints on the values used for effectivity
and the stylesheets don’t either. You’re free to use “cat” and “dog”
Expand Down Expand Up @@ -949,6 +945,22 @@ some common text. Options are introduced with the
</blockquote>
<para>That is unlikely to work well.</para>
</important>
</section>
<section xml:id="other-common-attributes">
<title>Other common Attributes</title>
<para>In addition, the stylesheets support profiling on several common attributes
that are not explicitly for effectivity: <att>xml:lang</att>, <att>revisionflag</att>,
and <att>role</att>.</para>

<note>
<title>The role Attribute is multivalued</title>
<para>Please note that the stylesheets treat the <att>role</att> attribute as
<emphasis>multivalued,</emphasis> similar to the <tag>class</tag> attribute in HTML. It
may contain a sequence of tokens, seperated by whitespace. This allows you, for example,
to classify a section as <emphasis>informal</emphasis> which should be printed in
<emphasis>landscape</emphasis> orientation with the following value for it's <att>role</att>
attribute: <code>role='informal landscape'</code>.</para>
</note>

</section>
<section>
Expand Down Expand Up @@ -1484,7 +1496,27 @@ presentation, in the printed version.</para>

<para>The resulting HTML document can be formatted directly with a
CSS paged-media formatter.</para>
</section>

<section xml:id="landscape">
<title>Landscape orientation in print output</title>
<para>The default orientation for pages in print output is portrait. You can switch to
landscape orientation with <code>landscape</code> as a token within the
<att>role</att> attribute
<footnote>
<para>See the note about the multivalued <att>role</att> Attribute in <xref linkend="other-common-attributes" xrefstyle="%label"/>.</para>
</footnote>.</para>
<para>This may apply to the whole <tag>book</tag> or
<tag>article</tag>, or to individual <tag>chapter</tag>, <tag>section</tag> or
<tag>appendix</tag> elements. You can also print individual tables or figures in landscape,
if they are to wide for portrait pages. For wide tables, you should use the <att>orient</att> attribute with the value <code>land</code>,
because it is provided precisely for this purpose.
However, in the interests of a uniform solution, the <att>role</att> attribute with the value <code>landscape</code> can also be used for tables.</para>

<para>For legacy reasons, the <code>landscapeFigure</code> processing instruction from the XSLT 1.0 stylesheets is also supported for <tag>figure</tag> and
<tag>informalfigure</tag> elements, as described
in <link xlink:href="http://www.sagehill.net/docbookxsl/LandscapeImage.html">Chapter 18 of Bob Staytons <quote>Complete Guide</quote>.</link>
</para>
</section>

<section xml:id="epub">
Expand Down Expand Up @@ -1635,4 +1667,3 @@ has a background color.

</section>
</chapter>

11 changes: 11 additions & 0 deletions src/main/scss/page-setup.scss
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,17 @@ html.book-style .book .list-of-titles {
counter-reset: page;
}

/* ============================================================ */
/* Support for landscape orientation */

@page landscape {
size: landscape;
}

.landscape {
page: landscape;
}

/* ============================================================ */

html.article-style > header {
Expand Down
50 changes: 43 additions & 7 deletions src/main/xslt/modules/attributes.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,20 @@

<xsl:template match="db:article" mode="m:attributes" as="attribute()*">
<xsl:variable name="attr" select="fp:common-attributes(.)"/>

<xsl:variable name="landscape" as="xs:string?">
<xsl:if test="contains-token(@role, 'landscape')">
<xsl:sequence select="'landscape'"/>
</xsl:if>
</xsl:variable>

<xsl:sequence select="f:attributes(., $attr,
(local-name(.),
'component',
@status, @otherclass,
if (@otherclass)
then 'otherclass'
else @class),
else @class, $landscape),
())"/>
<xsl:if test="@label">
<xsl:attribute name="db-label" select="@label"/>
Expand All @@ -44,8 +51,15 @@
<xsl:template match="db:set|db:book|db:part|db:reference"
mode="m:attributes" as="attribute()*">
<xsl:variable name="attr" select="fp:common-attributes(.)"/>

<xsl:variable name="landscape" as="xs:string?">
<xsl:if test="contains-token(@role, 'landscape')">
<xsl:sequence select="'landscape'"/>
</xsl:if>
</xsl:variable>

<xsl:sequence
select="f:attributes(., $attr, (local-name(.), 'division', @status), ())"/>
select="f:attributes(., $attr, (local-name(.), 'division', @status, $landscape), ())"/>
<xsl:if test="@label">
<xsl:attribute name="db-label" select="@label"/>
</xsl:if>
Expand All @@ -56,8 +70,15 @@
|db:preface|db:chapter|db:appendix"
mode="m:attributes" as="attribute()*">
<xsl:variable name="attr" select="fp:common-attributes(.)"/>

<xsl:variable name="landscape" as="xs:string?">
<xsl:if test="contains-token(@role, 'landscape')">
<xsl:sequence select="'landscape'"/>
</xsl:if>
</xsl:variable>

<xsl:sequence
select="f:attributes(., $attr, (local-name(.), 'component', @status), ())"/>
select="f:attributes(., $attr, (local-name(.), 'component', @status, $landscape), ())"/>
<xsl:if test="@label">
<xsl:attribute name="db-label" select="@label"/>
</xsl:if>
Expand All @@ -70,8 +91,15 @@
<!-- tempting to add a 'section' class here, but note that if we did
it would become much harder to distinguish a section from a sect1.
(I'm not sure that matters, but ...) -->

<xsl:variable name="landscape" as="xs:string?">
<xsl:if test="contains-token(@role, 'landscape')">
<xsl:sequence select="'landscape'"/>
</xsl:if>
</xsl:variable>

<xsl:sequence
select="f:attributes(., $attr, (local-name(.), @status), ())"/>
select="f:attributes(., $attr, (local-name(.), @status, $landscape), ())"/>
<xsl:if test="@label">
<xsl:attribute name="db-label" select="@label"/>
</xsl:if>
Expand Down Expand Up @@ -174,7 +202,7 @@
</xsl:if>
</xsl:variable>
<xsl:variable name="landscape" as="xs:string?">
<xsl:if test="@orient = 'land'">
<xsl:if test="@orient = 'land' or contains-token(@role, 'landscape')">
<xsl:sequence select="'landscape'"/>
</xsl:if>
</xsl:variable>
Expand Down Expand Up @@ -208,7 +236,7 @@
</xsl:variable>

<xsl:variable name="landscape" as="xs:string?">
<xsl:if test="@orient = 'land'">
<xsl:if test="@orient = 'land' or contains-token(@role, 'landscape')">
<xsl:sequence select="'landscape'"/>
</xsl:if>
</xsl:variable>
Expand Down Expand Up @@ -332,13 +360,21 @@
<xsl:sequence select="'pgwide'"/>
</xsl:if>
</xsl:variable>

<!-- landscapeFigure is legacy PI from XSLT 1.0 Stylesheets,
see http://www.sagehill.net/docbookxsl/LandscapeImage.html -->
<xsl:variable name="landscape" as="xs:string?">
<xsl:if test="contains-token(@role, 'landscape') or processing-instruction('landscapeFigure')">
<xsl:sequence select="'landscape'"/>
</xsl:if>
</xsl:variable>

<xsl:variable name="type"
select="if (starts-with(local-name(.), 'informal'))
then 'informalobject'
else 'formalobject'"/>

<xsl:sequence select="f:attributes(., $attr, (local-name(.), $type, $pgwide, $class), ())"/>
<xsl:sequence select="f:attributes(., $attr, (local-name(.), $type, $pgwide, $landscape, $class), ())"/>
</xsl:template>

<xsl:template match="db:index|db:bibliography|db:glossary"
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/expected/article.016.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" class="no-js"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script><title>Unit Test: article.016</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link href="https://purl.org/dc/elements/1.1/" rel="schema.dc"/><meta content="2011-04-22T17:02:00-06:00" name="dc.modified"/><meta content="DocBook xslTNG" name="generator"/><link href="./css/docbook.css" rel="stylesheet" media="screen"/></head><body class="home"><nav class="top"></nav><main><article class="article component landscape"><header><h1>Unit Test: article.016</h1></header><p>Content in landscape orientation (for PDF)</p></article></main><nav class="bottom"></nav></body></html>
6 changes: 6 additions & 0 deletions src/test/resources/expected/book.015.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" class="no-js"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script><title>More fun with landscape orientation</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link href="https://purl.org/dc/elements/1.1/" rel="schema.dc"/><meta content="2011-04-22T17:02:00-06:00" name="dc.modified"/><meta content="DocBook xslTNG" name="generator"/><link href="./css/docbook.css" rel="stylesheet" media="screen"/></head><body class="home"><nav class="top"></nav><main><article id="book" class="book division"><header><h1>More fun with landscape orientation</h1><div class="abstract"><p>A series of book unit test that checks landscape orientation.</p></div></header><div class="list-of-titles"><div class="lot toc"><div class="title">Table of Contents</div><ul class="toc"><li><a href="#book_ch1"><span class="label">1</span><span class="sep">. </span>Purpose of this Book</a></li><li><a href="#book_ch2"><span class="label">2</span><span class="sep">. </span>Second Chapter</a></li></ul></div></div><section id="book_ch1" class="chapter component landscape"><header><h2>Chapter <span class="label">1</span><span class="sep">. </span>Purpose of this Book</h2></header><p>This book contains a table with two wide columns.
The table won't fit on a regular, portrait-oriented page which is about 160 or 170mm wide (assuming A$ paper size).
This is why it is printed in landscape orientation in PDF output.
But as always, there are different ways to achieve this goal.</p><p>Only this chapter should be printed in landscape orientation</p><div id="book_ch1_informaltable1" class="informalobject informaltable"><table><colgroup><col style="width: 454px"/><col style="width: 302px"/></colgroup><tbody><tr><td><p>This is a very wide column (120mm)</p></td><td><p>The second column is also wide (80mm)</p></td></tr></tbody></table><div class="caption"><p>The caption for ths table should be printed in the same orientation as the table itself.</p></div></div><p>This is a regular <code class="tag tag-element">para</code> below the very wide table.
It has nothing to say, but will show the orientation within the firts chapter of this book</p></section><section id="book_ch2" class="chapter component"><header><h2>Chapter <span class="label">2</span><span class="sep">. </span>Second Chapter</h2></header><p>The second chapter will end this book, which is very short indeed. It does not tell us anything about the outside world,
it's only purpuse is to show the effect of PDF pages in landscape orientation.</p></section></article></main><nav class="bottom"></nav></body></html>
10 changes: 10 additions & 0 deletions src/test/resources/expected/book.016.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" class="no-js"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script><title>Still more fun with landscape orientation</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link href="https://purl.org/dc/elements/1.1/" rel="schema.dc"/><meta content="2011-04-22T17:02:00-06:00" name="dc.modified"/><meta content="DocBook xslTNG" name="generator"/><link href="./css/docbook.css" rel="stylesheet" media="screen"/></head><body class="home"><nav class="top"></nav><main><article id="book" class="book division"><header><h1>Still more fun with landscape orientation</h1><div class="abstract"><p>A series of book unit test that checks landscape orientation.</p></div></header><div class="list-of-titles"><div class="lot toc"><div class="title">Table of Contents</div><ul class="toc"><li><a href="#book_ch1"><span class="label">1</span><span class="sep">. </span>Purpose of this Book</a></li><li><a href="#book_ch2"><span class="label">2</span><span class="sep">. </span>Second Chapter</a></li></ul></div></div><section id="book_ch1" class="chapter component"><header><h2>Chapter <span class="label">1</span><span class="sep">. </span>Purpose of this Book</h2></header><p>This book contains a table with two wide columns.
The table won't fit on a regular, portrait-oriented page which is about 160 or 170mm wide (assuming A$ paper size).
This is why it is printed in landscape orientation in PDF output.
But as always, there are different ways to achieve this goal.</p><p>This table with it's caption should be printed in landscape orientation</p><div id="book_ch1_informaltable1" class="informalobject informaltable landscape"><table><colgroup><col style="width: 454px"/><col style="width: 302px"/></colgroup><tbody><tr><td><p>This is a very wide column (120mm)</p></td><td><p>The second column is also wide (80mm)</p></td></tr><tr><td class="center" colspan="2">
<p>We use the table's <code>orient</code> Attribute</p>
</td></tr></tbody></table><div class="caption"><p>The caption for ths table should be printed in the same orientation as the table itself.</p></div></div><p>This is a regular <code class="tag tag-element">para</code> below the very wide table.
It has nothing to say, but will show the orientation within the firts chapter of this book</p><div id="book_ch1_informaltable2" class="informalobject informaltable landscape"><table><colgroup><col style="width: 454px"/><col style="width: 302px"/></colgroup><tbody><tr><td><p>This is a very wide column (120mm)</p></td><td><p>The second column is also wide (80mm)</p></td></tr><tr><td class="center" colspan="2">
<p>We use the table's <code>role</code> Attribute</p>
</td></tr></tbody></table><div class="caption"><p>The caption for ths table should be printed in the same orientation as the table itself.</p></div></div></section><section id="book_ch2" class="chapter component"><header><h2>Chapter <span class="label">2</span><span class="sep">. </span>Second Chapter</h2></header><p>The second chapter will end this book, which is very short indeed. It does not tell us anything about the outside world,
it's only purpuse is to show the effect of PDF pages in landscape orientation.</p></section></article></main><nav class="bottom"></nav></body></html>
6 changes: 6 additions & 0 deletions src/test/resources/expected/book.017.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" class="no-js"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script><title>Landscape orientation, revisited</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link href="https://purl.org/dc/elements/1.1/" rel="schema.dc"/><meta content="2011-04-22T17:02:00-06:00" name="dc.modified"/><meta content="DocBook xslTNG" name="generator"/><link href="./css/docbook.css" rel="stylesheet" media="screen"/></head><body class="home"><nav class="top"></nav><main><article id="book" class="book division"><header><h1>Landscape orientation, revisited</h1><div class="abstract"><p>A series of book unit test that checks landscape orientation.</p></div></header><div class="list-of-titles"><div class="lot toc"><div class="title">Table of Contents</div><ul class="toc"><li><a href="#book_article1">Purpose of this Book</a></li><li><a href="#book_article2">Second Chapter</a></li></ul></div></div><section id="book_article1" class="article component landscape"><header><h1>Purpose of this Book</h1></header><p>This book contains a table with two wide columns.
The table won't fit on a regular, portrait-oriented page which is about 160 or 170mm wide (assuming A$ paper size).
This is why it is printed in landscape orientation in PDF output.
But as always, there are different ways to achieve this goal.</p><p>This article should be printed in landscape orientation</p><div id="book_article1_informaltable1" class="informalobject informaltable"><table><colgroup><col style="width: 454px"/><col style="width: 302px"/></colgroup><tbody><tr><td><p>This is a very wide column (120mm)</p></td><td><p>The second column is also wide (80mm)</p></td></tr></tbody></table><div class="caption"><p>The caption for ths table should be printed in the same orientation as the table itself.</p></div></div><p>This is a regular <code class="tag tag-element">para</code> below the very wide table.
It has nothing to say, but will show the orientation within the firts chapter of this book</p></section><section id="book_article2" class="article component"><header><h1>Second Chapter</h1></header><p>The second chapter will end this book, which is very short indeed. It does not tell us anything about the outside world,
it's only purpuse is to show the effect of PDF pages in landscape orientation.</p></section></article></main><nav class="bottom"></nav></body></html>
2 changes: 2 additions & 0 deletions src/test/resources/expected/book.018.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" class="no-js"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script><title>Fun with landscape orientend graphics</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link href="https://purl.org/dc/elements/1.1/" rel="schema.dc"/><meta content="2011-04-22T17:02:00-06:00" name="dc.modified"/><meta content="DocBook xslTNG" name="generator"/><link href="./css/docbook.css" rel="stylesheet" media="screen"/></head><body class="home"><nav class="top"></nav><main><article id="book" class="book division"><header><h1>Fun with landscape orientend graphics</h1><div class="abstract"><p>A series of book unit test that checks landscape orientation.</p></div></header><div class="list-of-titles"><div class="lot toc"><div class="title">Table of Contents</div><ul class="toc"><li><a href="#book_ch1"><span class="label">1</span><span class="sep">. </span>Purpose of this Book</a></li><li><a href="#book_ch2"><span class="label">2</span><span class="sep">. </span>Second Chapter</a></li></ul></div></div><section id="book_ch1" class="chapter component"><header><h2>Chapter <span class="label">1</span><span class="sep">. </span>Purpose of this Book</h2></header><p>The folowing figure should be printed in landscape orientation</p><div id="book_ch1_informalfigure1" class="informal informalfigure informalobject landscape"><div class="mediaobject"><div class="media image"><picture class="imageobject"><img src="media/duck.png"/></picture></div><div class="caption"><p>A duck in its full beauty</p></div></div></div><p>This is a regular paragraph below the figure, it shoud be in portrait orientation.</p></section><section id="book_ch2" class="chapter component"><header><h2>Chapter <span class="label">2</span><span class="sep">. </span>Second Chapter</h2></header><p>The second chapter will end this book, which is very short indeed. It does not tell us anything about the outside world,
it's only purpuse is to show the effect of PDF pages in landscape orientation.</p></section></article></main><nav class="bottom"></nav></body></html>
Loading
Loading