1
0
Fork 0
mirror of https://github.com/lise-henry/crowbook synced 2024-05-23 21:36:15 +02:00
crowbook/docs/book/html/chapter_004.html
2017-11-26 21:31:17 +01:00

485 lines
32 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="generator" content="crowbook">
<meta name="author" content="Élisabeth Henry">
<meta name="viewport" content="width=device-width">
<link rel = "icon" href = "images/image_1.svg">
<title>Crowbook User Guide - 5. Templates</title>
<link rel = "stylesheet" href = "stylesheet.css" type = "text/css"
/>
<link rel = "stylesheet" href = "print.css" type = "text/css"
media = "print" />
<script>
function on(name) {
var elements = document.getElementsByClassName(name);
for (var i = 0; i < elements.length; i++) {
var elem = elements[i];
elem.style.backgroundColor = "pink";
}
}
function off(name) {
var elements = document.getElementsByClassName(name);
for (var i = 0; i < elements.length; i++) {
var elem = elements[i];
elem.style.backgroundColor = "white";
}
}
var display_menu = false;
function toggle() {
if (display_menu == true) {
display_menu = false;
document.getElementById("nav").style.left = "-21%";
document.getElementById("content").style.marginLeft = "0%";
document.getElementById("menu").style.left = "1em";
/* if(document.getElementById("top")) {
document.getElementById("top").style.left = "0";
}
if(document.getElementById("footer")) {
document.getElementById("footer").style.marginLeft = "0%";
}*/
} else {
display_menu = true;
document.getElementById("nav").style.left = "0";
document.getElementById("content").style.marginLeft = "20%";
document.getElementById("menu").style.left = "20%";
/* if(document.getElementById("top")) {
document.getElementById("top").style.left = "20%";
}
if(document.getElementById("footer")) {
document.getElementById("footer").style.marginLeft = "20%";
}*/
}
}
</script>
</head>
<body>
<script type = 'application/ld+json'>
{
"@context": "http://schema.org/",
"@type": "Book",
"author": "Élisabeth Henry",
"name": "Crowbook User Guide",
"version": "0.14.0",
"license": "This guide is published under the Creative Commons Attribution-ShareAlike 4.0-International license.",
"about": "Crowbook allows to render a book written in Markdown in various formats. This is some kind of manual for it, and a way to demonstrate and test it.",
"inLanguage": "en"
}
</script>
<nav id = "nav">
<h2><a href = "index.html">Crowbook User Guide</a></h2>
<ul>
<li><a href = "chapter_000.html#link-1">1. Crowbook</a>
<ul><li><a href = "chapter_000.html#link-2">1.1. Example</a></li>
<li><a href = "chapter_000.html#link-3">1.2. Installing</a></li>
<li><a href = "chapter_000.html#link-6">1.3. Dependencies</a></li>
<li><a href = "chapter_000.html#link-7">1.4. Quick tour</a></li>
<li><a href = "chapter_000.html#link-8">1.5. Current features</a></li>
<li><a href = "chapter_000.html#link-18">1.6. Contributors</a></li>
<li><a href = "chapter_000.html#link-19">1.7. Acknowledgements</a></li>
<li><a href = "chapter_000.html#link-20">1.8. ChangeLog</a></li>
<li><a href = "chapter_000.html#link-21">1.9. Contributing</a></li>
<li><a href = "chapter_000.html#link-22">1.10. Library</a></li>
<li><a href = "chapter_000.html#link-23">1.11. License</a></li>
</ul>
</li>
<li><a href = "chapter_001.html#link-24">2. Arguments</a>
<ul><li><a href = "chapter_001.html#link-25">2.1. <code>--create</code></a></li>
<li><a href = "chapter_001.html#link-26">2.2. <code>--single</code></a></li>
<li><a href = "chapter_001.html#link-27">2.3. <code>--set</code></a></li>
<li><a href = "chapter_001.html#link-28">2.4. <code>--list-options</code></a></li>
<li><a href = "chapter_001.html#link-29">2.5. <code>--print-template</code></a></li>
<li><a href = "chapter_001.html#link-30">2.6. <code>--stats</code></a></li>
<li><a href = "chapter_001.html#link-31">2.7. <code>--proofread</code></a></li>
<li><a href = "chapter_001.html#link-32">2.8. <code>--autograph</code></a></li>
<li><a href = "chapter_001.html#link-34">2.9. <code>--verbose</code></a></li>
<li><a href = "chapter_001.html#link-35">2.10. <code>--to</code></a></li>
<li><a href = "chapter_001.html#link-37">2.11. <code>--output</code></a></li>
<li><a href = "chapter_001.html#link-38">2.12. <code>--lang</code></a></li>
</ul>
</li>
<li><a href = "chapter_002.html#link-40">3. The configuration file</a>
<ul><li><a href = "chapter_002.html#link-41">3.1. Configuration in an inline YAML block</a></li>
<li><a href = "chapter_002.html#link-42">3.2. The list of files</a></li>
<li><a href = "chapter_002.html#link-45">3.3. Crowbook options</a></li>
<li><a href = "chapter_002.html#link-60">3.4. Full list of options</a></li>
</ul>
</li>
<li><a href = "chapter_003.html#link-77">4. Markdown format</a>
<ul><li><a href = "chapter_003.html#link-78">4.1. Tables</a></li>
<li><a href = "chapter_003.html#link-79">4.2. Footnotes</a></li>
<li><a href = "chapter_003.html#link-80">4.3. Superscript and subscript</a></li>
<li><a href = "chapter_003.html#link-81">4.4. “Standalone” images</a></li>
<li><a href = "chapter_003.html#link-82">4.5. Interactive fiction</a></li>
</ul>
</li>
<li><a href = "chapter_004.html#link-83">5. Templates</a>
<ul><li><a href = "chapter_004.html#link-84">5.1. Create and edit template</a></li>
<li><a href = "chapter_004.html#link-88">5.2. List of templates</a></li>
<li><a href = "chapter_004.html#link-102">5.3. List of accessible variables</a></li>
</ul>
</li>
<li><a href = "chapter_005.html#link-106">6. Proofreading with Crowbook</a>
<ul><li><a href = "chapter_005.html#link-107">6.1. Enabling proofreading</a></li>
<li><a href = "chapter_005.html#link-108">6.2. Repetition detection</a></li>
<li><a href = "chapter_005.html#link-109">6.3. Grammar checking</a></li>
</ul>
</li>
<li><a href = "chapter_006.html#link-112">7. Interactive fiction</a>
<ul><li><a href = "chapter_006.html#link-113">7.1. Basics</a></li>
<li><a href = "chapter_006.html#link-114">7.2. The interactive fiction renderer</a></li>
<li><a href = "chapter_006.html#link-115">7.3. Using Javascript in your interactive fiction</a></li>
<li><a href = "chapter_006.html#link-116">7.4. Embedding Makdown in your Javascript code embedded in your Markdown</a></li>
<li><a href = "chapter_006.html#link-117">7.5. Conditional blocks</a></li>
<li><a href = "chapter_006.html#link-118">7.6. Interactive fiction options</a></li>
</ul>
</li>
<li><a href = "chapter_007.html#link-119">8. Tips and tricks</a>
<ul><li><a href = "chapter_007.html#link-120">8.1. Using Crowbook with Emacs markdown mode</a></li>
<li><a href = "chapter_007.html#link-122">8.2. Embedding fonts in an EPUB file</a></li>
</ul>
</li>
<li><a href = "chapter_008.html#link-123">9. Contributing</a>
<ul><li><a href = "chapter_008.html#link-124">9.1. Internationalization</a></li>
</ul>
</li>
<li><a href = "chapter_009.html#link-125">ChangeLog</a>
<ul><li><a href = "chapter_009.html#link-126">unreleased</a></li>
<li><a href = "chapter_009.html#link-127">0.14.0-beta (2017-10-08)</a></li>
<li><a href = "chapter_009.html#link-128">0.13.0 (2017-07-14)</a></li>
<li><a href = "chapter_009.html#link-129">0.12.0 (2017-06-05)</a></li>
<li><a href = "chapter_009.html#link-130">0.11.4 (2017-03-21)</a></li>
<li><a href = "chapter_009.html#link-131">0.11.3 (2017-03-19)</a></li>
<li><a href = "chapter_009.html#link-132">0.11.2 (2017-03-05)</a></li>
<li><a href = "chapter_009.html#link-133">0.11.1 (2017-01-05)</a></li>
<li><a href = "chapter_009.html#link-134">0.11.0 (2016-12-31)</a></li>
<li><a href = "chapter_009.html#link-135">0.10.4 (2016-12-16)</a></li>
<li><a href = "chapter_009.html#link-136">0.10.3 (2016-11-19)</a></li>
<li><a href = "chapter_009.html#link-137">0.10.2 (2016-10-21)</a></li>
<li><a href = "chapter_009.html#link-138">0.10.1 (2016-10-18)</a></li>
<li><a href = "chapter_009.html#link-139">0.10.0 (2016-10-18)</a></li>
<li><a href = "chapter_009.html#link-140">0.9.1 (2016-09-29)</a></li>
<li><a href = "chapter_009.html#link-141">0.9.0 (2016-09-23)</a></li>
<li><a href = "chapter_009.html#link-142">0.8.0 (2016-09-19)</a></li>
<li><a href = "chapter_009.html#link-143">0.7.0 (2016-09-11)</a></li>
<li><a href = "chapter_009.html#link-144">0.6.0 (2016-09-09)</a></li>
<li><a href = "chapter_009.html#link-145">0.5.1 (2016-04-14)</a></li>
<li><a href = "chapter_009.html#link-146">0.5.0 (2016-04-02)</a></li>
<li><a href = "chapter_009.html#link-147">0.4.0 (2016-03-01)</a></li>
<li><a href = "chapter_009.html#link-148">0.3.0 (2016-02-27)</a></li>
<li><a href = "chapter_009.html#link-149">0.2.2 (2016-02-25)</a></li>
<li><a href = "chapter_009.html#link-150">0.2.1 (2016-02-25)</a></li>
<li><a href = "chapter_009.html#link-151">0.2.0 (2016-02-25)</a></li>
<li><a href = "chapter_009.html#link-152">0.1.0 (2016-02-21)</a></li>
</ul>
</li>
<li><a href = "chapter_010.html#link-153">GNU LESSER GENERAL PUBLIC LICENSE</a></li>
</ul>
</nav>
<div id = "content">
<div id = "top"><p id = "para-354">Crowbook User Guide 0.14.0</p>
</div>
<div id = "page">
<header>
<div id = "menu">
<img id = "menu-button" onclick="toggle();"
src="menu.svg" alt = "Table of contents" title = "Table of contents" />
</div>
</header>
<p class = "prev_chapter">
<a href = "chapter_003.html">
« 4. Markdown format
</a>
</p>
<h1 id = 'link-83'><span class = 'chapter-header'>Chapter 5</span><br />Templates</h1><p id = "para-186">Crowbook allows the user to specify a number of templates.<a href = "#note-dest-4"><sup id = "note-source-4">[4]</sup></a></p>
<p id = "para-187">Each of this template can be overriden by a custom one, by setting e.g.:</p>
<pre><span style="color:#268bd2;">html.css</span><span style="color:#839496;">:</span><span style="color:#839496;"> </span><span style="color:#2aa198;">my_template.css</span><span style="color:#839496;">
</span></pre><p id = "para-188">in the book configuration file. The templates that you are most susceptible to modify are the following:</p>
<ul>
<li><code>html.css</code>: stylesheet for HTML output;</li>
<li><code>epub.css</code>: stylesheet for EPUB output;</li>
<li><code>tex.template</code>: template of a LaTeX file.</li>
</ul>
<h2 id = "link-84">5.1. Create and edit template</h2>
<p id = "para-189">Except for inline templates, which are set directly in the book configuration file:</p>
<pre><span style="color:#586e75;">#</span><span style="color:#586e75;"> Template that modify how a chapter title is displayed
rendering.chapter.template: &quot;{{{loc_chapter}}} {{{number}}}: {{{chapter_title}}}&quot;
# CSS code added to default CSS templates (but don&#39;t override it)
html.css.add: &quot;h1 { background-color: red; }&quot;
epub.css.add: &quot;h1 { background-color: gray; }&quot;
# LaTeX code added to default LaTeX template (but doesn&#39;t override it)
template.tex.add: &quot;\usepackage{libertineotf}&quot;
</span></pre><p id = "para-190">most templates must be in a separate file:</p>
<pre><span style="color:#268bd2;">tex.template</span><span style="color:#839496;">:</span><span style="color:#839496;"> </span><span style="color:#2aa198;">my_template.tex</span><span style="color:#839496;">
</span></pre><h3 id = "link-85"><code>--print-template</code></h3>
<p id = "para-191">The easiest way to create a new template is to start with the default one. In order to do so, you can use the <code>--print-template</code> argument:</p>
<pre><span style="color:#839496;">$ crowbook --print-template tex.template </span><span style="color:#859900;">&gt;</span><span style="color:#839496;"> my_template.tex
</span></pre><p id = "para-192">In order to get the <code>chapter.xhtml</code> template for EPUB3, youll also have to use <code>--set epub.version 3</code>:</p>
<pre><span style="color:#839496;">$ crowbook --print-template epub.chapter.xhtml --</span><span style="color:#859900;">set</span><span style="color:#839496;"> epub.version 3 </span><span style="color:#859900;">&gt;</span><span style="color:#839496;"> my_epub3_template.xhtml
</span></pre><h3 id = "link-86">Mustache syntax</h3>
<p id = "para-193">Crowbook uses <a href = "https://crates.io/crates/mustache">rust-mustache</a> as its templating engine, which allows to use <a href = "http://mustache.github.io/">Mustache</a> syntax in the templates.</p>
<p id = "para-195">It mainly boils down to using <code>{{{foo}}}</code><a href = "#note-dest-5"><sup id = "note-source-5">[5]</sup></a> to insert the value of variable <code>foo</code> in the document:</p>
<pre><span style="color:#586e75;">&lt;</span><span style="color:#268bd2;">h1</span><span style="color:#657b83;"> </span><span style="color:#b58900;">class</span><span style="color:#657b83;"> </span><span style="color:#657b83;">=</span><span style="color:#657b83;"> </span><span style="color:#839496;">&quot;</span><span style="color:#657b83;">title</span><span style="color:#839496;">&quot;</span><span style="color:#657b83;"> </span><span style="color:#586e75;">&gt;</span><span style="color:#839496;">{{{title}}}</span><span style="color:#586e75;">&lt;</span><span style="color:#268bd2;">h1</span><span style="color:#586e75;">&gt;</span><span style="color:#839496;">
</span><span style="color:#586e75;">&lt;</span><span style="color:#268bd2;">h2</span><span style="color:#657b83;"> </span><span style="color:#b58900;">class</span><span style="color:#657b83;"> </span><span style="color:#657b83;">=</span><span style="color:#657b83;"> </span><span style="color:#839496;">&quot;</span><span style="color:#657b83;">author</span><span style="color:#839496;">&quot;</span><span style="color:#586e75;">&gt;</span><span style="color:#839496;">{{{author}}}</span><span style="color:#586e75;">&lt;/</span><span style="color:#268bd2;">h2</span><span style="color:#586e75;">&gt;</span><span style="color:#839496;">
</span></pre><p id = "para-196">Mustache also provides the possibility of checking whether a variable is set:</p>
<pre><span style="color:#839496;">{{#foo}}
Foo exists
{{/foo}}
{{^foo}}
Foo does not exist
{{^foo}}
</span></pre><p id = "para-197">Crowbook uses this and sets some variables to <code>true</code> to allow templates to conditionally include some portions. E.g., in <code>html.css</code>:</p>
<pre><span style="color:#657b83;">{</span><span style="color:#839496;">{#</span><span style="color:#839496;">lang</span><span style="color:#839496;">_</span><span style="color:#839496;">fr</span><span style="color:#657b83;">}</span><span style="color:#839496;">}
</span><span style="color:#586e75;">/*</span><span style="color:#586e75;"> Make list displays &#39;&#39; instead of bullets </span><span style="color:#586e75;">*/</span><span style="color:#657b83;">
</span><span style="color:#b58900;">ul</span><span style="color:#657b83;"> </span><span style="color:#b58900;">li</span><span style="color:#657b83;"> </span><span style="color:#657b83;">{</span><span style="color:#839496;">
</span><span style="color:#859900;">list-style-type</span><span style="color:#839496;">:</span><span style="color:#839496;"> </span><span style="color:#839496;">&#39;</span><span style="color:#2aa198;"></span><span style="color:#839496;">&#39;</span><span style="color:#839496;">;</span><span style="color:#839496;">
</span><span style="color:#859900;">padding-left</span><span style="color:#839496;">:</span><span style="color:#839496;"> </span><span style="color:#6c71c4;">.5</span><span style="color:#859900;">em</span><span style="color:#839496;">;</span><span style="color:#839496;">
</span><span style="color:#657b83;">}</span><span style="color:#839496;">
</span><span style="color:#657b83;">{</span><span style="color:#839496;">{/</span><span style="color:#839496;">lang</span><span style="color:#839496;">_</span><span style="color:#839496;">fr</span><span style="color:#657b83;">}</span><span style="color:#839496;">}
</span></pre><p id = "para-198">In this case, Crowbook sets a variable whose name is equal to <code>lang_foo</code> to <code>true</code>, allowing to have different styles for some elements according to the language.</p>
<p id = "para-199">For more information about Mustache syntax, see the <a href = "http://mustache.github.io/mustache.5.html">Mustache manual</a>.</p>
<h4 id = "link-87">Syntax in LaTeX</h4>
<p id = "para-201">Since LaTeX already uses a lot of curly brackets, the default template sets an altenative syntax to access variables, with <code>&lt;&lt;&amp;foo&gt;&gt;</code><a href = "#note-dest-6"><sup id = "note-source-6">[6]</sup></a>:</p>
<pre><span style="color:#859900;">\</span><span style="color:#859900;">title</span><span style="color:#839496;">{</span><span style="color:#839496;">&lt;&lt;</span><span style="color:#cb4b16;">&amp;</span><span style="color:#839496;">title&gt;&gt;</span><span style="color:#839496;">}</span><span style="color:#839496;">
</span><span style="color:#859900;">\</span><span style="color:#859900;">author</span><span style="color:#839496;">{</span><span style="color:#839496;">&lt;&lt;</span><span style="color:#cb4b16;">&amp;</span><span style="color:#839496;">author&gt;&gt;</span><span style="color:#839496;">}</span><span style="color:#839496;">
&lt;&lt;#has_date&gt;&gt;</span><span style="color:#859900;">\</span><span style="color:#859900;">date</span><span style="color:#839496;">{</span><span style="color:#839496;">&lt;&lt;</span><span style="color:#cb4b16;">&amp;</span><span style="color:#839496;">date&gt;&gt;</span><span style="color:#839496;">}</span><span style="color:#839496;">&lt;&lt;/has_date&gt;
</span></pre> <h3 id = "link-89">html.js</h3>
<p id = "para-202">The javascript file used by both the standalone HTML renderer and the multiple files HTML renderer.</p>
<p id = "para-203">This is not currently an actual template, just a plain javascript file which cannot contain <code>mustache</code> tags.</p>
<h3 id = "link-90">html.css</h3>
<p id = "para-204">The main CSS file used by both the standalone HTML renderer and the multiple files HTML renderer.</p>
<h3 id = "link-91">html.css.colours</h3>
<p id = "para-205">A CSS file containing only colour settings. Used by <code>html.css</code>.</p>
<p id = "para-206">This is not currently an actual template, just a plain CSS file which cannot contain <code>mustache</code> tags.</p>
<h3 id = "link-92">html.css.print</h3>
<p id = "para-207">An additional CSS file used by both the standalone HTML renderer and the multiple files HTML renderer. Its purpose is to provide CSS instructions for printing (i.e., when the user clicks the <code>print</code> button in her browser).</p>
<p id = "para-208">This is not currently an actual template, just a plain CSS file which cannot contain <code>mustache</code> tags.</p>
<h3 id = "link-93">html.highlight.js</h3>
<p id = "para-209">A javascript file used by both HTML renderers to highlight codes in code blocks. It should be a variant of <a href = "https://highlightjs.org/">highlight.js</a>.</p>
<p id = "para-210">This is not an actual template, just a plain javascript file.</p>
<h3 id = "link-94">html.highlight.css</h3>
<p id = "para-211">A CSS file used by both HTML renderers to set the theme of <a href = "https://highlightjs.org/">highlight.js</a>. It should, though, be an highlight.js theme.</p>
<p id = "para-212">This is not an actual template, just a plain CSS file.</p>
<h3 id = "link-95">html.standalone.js</h3>
<p id = "para-213">A javascript file used only by the standalone HTML renderer. Its main purpose is to handle the displaying of a single chapter at a time when <code>one_chapter</code> is set to true.</p>
<h3 id = "link-96">html.standalone.template</h3>
<p id = "para-214">The main HTML template for standalone HTML renderer.</p>
<h3 id = "link-97">html.dir.template</h3>
<p id = "para-215">The main HTML template for multiple files HTML renderer.</p>
<h3 id = "link-98">tex.template</h3>
<p id = "para-216">The main (and currently only) template used by the LaTeX renderer.</p>
<h3 id = "link-99">epub.chapter.xhtml</h3>
<p id = "para-217">This template is the main template used by the Epub renderer. It contains the XHTML template that will be used for each chapter.</p>
<h3 id = "link-100">epub.css</h3>
<p id = "para-218">This template is used by the Epub renderer and contains the style sheet.</p>
<h3 id = "link-101">Inline templates</h3>
<p id = "para-219">Crowbook also has some inline templates, that are set in the book configuration file:</p>
<ul>
<li><code>tex.template.add</code>, <code>html.css.add</code> and <code>epub.css.add</code> allow to specify some LaTeX or CSS code directly in the book configuration file. This code will be added respectively to <code>tex.template</code>, <code>html.css</code> or <code>epub.css</code> template. For CSS templates, this code is inserted at the end of the template (allowing to redefine rules that are set by the template); for the LaTeX template, the code is inserted at the end of the preambule, just before the <code>\begin{document}</code> tag, allowing to redefine commands.</li>
<li><code>rendering.inline_toc.name</code> sets the name of the inline table of content, if it is displayed. By default, is is set to <code>{{{loc_toc}}}</code>, that is, a localised version of “Table of Contents”.</li>
<li><code>rendering.chapter.template</code> sets the naming scheme for chapters, while <code>rendering.part.template</code> does the same for part. These are used only for text-only output, such as in the TOC. <code>html.chapter.template</code> and <code>html.part.template</code> allow to change the HTML formatting for parts and chapters. <em>These options should probably only be used if you know what youre doing, as they can break the document.</em> If you only need to change the name of chapters or parts, use <code>rendering.part</code> and <code>rendering.chapter</code> instead.</li>
</ul>
<h2 id = "link-102">5.3. List of accessible variables</h2>
<h3 id = "link-103">Metadata</h3>
<p id = "para-220">For every template, Crowbook exports all of the metadata:</p>
<ul>
<li><code>author</code>;</li>
<li><code>title</code>;</li>
<li><code>subtitle</code>;</li>
<li><code>lang</code>;</li>
<li><code>subject</code>;</li>
<li><code>description</code>;</li>
<li><code>license</code>;</li>
<li><code>version</code>;</li>
<li><code>date</code>;</li>
<li>any option <code>metadata.foo</code> defined in the book configuration file will also be exported as <code>metadata_foo</code>.</li>
</ul>
<p id = "para-221">These metadata can contain Markdown, which will be rendered. E.g., setting <code>date: “20th of **september**”</code> will render <code>september</code> in bold, using <code>&lt;b&gt;</code> tag for HTML or <code>\textbf</code> for LaTeX. If you need to use these data in places that dont support formatted text (e.g. in meta tags), you can use the raw content by accessing <code>xxx_raw</code> instead (e.g., <code>author_raw</code>, <code>title_raw</code>, ...). (Note that the content of the raw metadata is <em>not</em> HTML-escaped, so in this case you might want to use <code>{{xxx_raw}}</code> instead of <code>{{{xxx_raw}}}</code>.)</p>
<p id = "para-222">For each metadata <code>foo</code> that is set, Crowbook also inserts a <code>has_foo</code> bool set to true. This allows to use Mustaches section for some logic, e.g.:</p>
<pre><span style="color:#839496;">{{{title}}}
{{#has_version}}, version {{{version}}}{{/has_version}}
</span></pre><p id = "para-223">will avoid rendering “, version” when <code>version</code> is not set.</p>
<h3 id = "link-104">Localisation strings</h3>
<p id = "para-224">For all templates, Crowbook also exports some localisation strings <code>loc_foo</code>. They currently include:</p>
<div class = "table">
<table>
<tr>
<th> Localisation key </th><th> Value in english </th></tr>
<tr>
<td> <code>loc_toc</code> </td><td> Table of contents </td></tr>
<tr>
<td> <code>loc_cover</code> </td><td> Cover </td></tr>
<tr>
<td> <code>loc_title</code> </td><td> Title </td></tr>
<tr>
<td> <code>loc_chapter</code> </td><td> Chapter </td></tr>
<tr>
<td> <code>loc_part</code> </td><td> Part </td></tr>
<tr>
<td> <code>loc_notes</code> </td><td> Notes </td></tr>
<tr>
<td> <code>loc_display_all</code> </td><td> Display all chapters </td></tr>
<tr>
<td> <code>loc_display_one</code> </td><td> Display one chapter </td></tr>
</table>
</div>
<h3 id = "link-105">Template-dependent values</h3>
<p id = "para-225">Crowbook also exports some additional fields for some templates, see below.</p>
<div class = "table">
<table>
<tr>
<th> Mustache tag </th><th> Value </th><th> Available in... </th></tr>
<tr>
<td> <code>content</code> </td><td> A rendered version of the book or chapters content </td><td> <code>html.standalone.template</code>, <code>html.dir.template</code>, <code>tex.template</code>, <code>epub.chapter.xhtml</code> </td></tr>
<tr>
<td> <code>toc</code> </td><td> A rendered version of the table of contents </td><td> <code>html.standalone.template</code>, <code>html.dir.template</code> </td></tr>
<tr>
<td> <code>has_toc</code></td><td> Set to <code>true</code> if the table of contents is not empty </td><td> <code>html.standalone.template</code> </td></tr>
<tr>
<td> <code>colours</code></td><td> The content of <code>html.css.colours</code> </td><td> <code>html.css</code> </td></tr>
<tr>
<td> <code>footer</code> </td><td> The content of <code>html.footer</code> </td><td> <code>html.standalone.template</code>, <code>html.dir.template</code> </td></tr>
<tr>
<td> <code>header</code> </td><td> The content of <code>html.header</code> </td><td> <code>html.standalone.template</code>, <code>html.dirtemplate</code> </td></tr>
<tr>
<td> <code>script</code> </td><td> The javascript file for this HTML document </td><td> <code>html.standalone.template</code>, <code>html.dir.template</code> </td></tr>
<tr>
<td> <code>style</code> </td><td> The CSS file for this HTML document, that is, a rendered version of <code>html.css</code> </td><td> <code>html.standalone.template</code> </td></tr>
<tr>
<td> A variable whose name corresponds to <code>lang</code> in book options (e.g. <code>lang_en</code> if lang is set to “en”, <code>lang_fr</code> if it is set to “fr”, ...) </td><td> <code>true</code> </td><td> <code>html.css</code>, <code>epub.css</code> </td></tr>
<tr>
<td> <code>chapter_title</code> </td><td> The title of current chapter </td><td> <code>html.dir.template</code>, <code>epub.chapter.xhtml</code>, <code>rendering.chapter.template</code> </td></tr>
<tr>
<td> <code>chapter_title_raw</code> </td><td> The title of current chapter (raw text without HTML formatting) </td><td> <code>html.dir.template</code>, <code>epub.chapter.xhtml</code>, <code>rendering.chapter.template</code> </td></tr>
<tr>
<td> <code>json_data</code> </td><td> Contains structured data with books metadata in JSON-LD format </td><td> <code>html.standalone.template</code>, <code>html.dir.template</code> </td></tr>
<tr>
<td> <code>highlight_code</code> </td><td> True if <code>html.highlight_code</code> is true </td><td> <code>html.standalone.template</code>, <code>html.dir.template</code> </td></tr>
<tr>
<td> <code>highlight_css</code> </td><td> The content of <code>html.highlight.css</code> </td><td> <code>html.standalone.template</code> </td></tr>
<tr>
<td> <code>highlight_js</code> </td><td> The base64-encoded content of <code>html.highlight.js</code> </td><td> <code>html.standalone.tempate</code> </td></tr>
<tr>
<td> <code>common_script</code> </td><td> The content of <code>html.js</code> </td><td> <code>html.single.js</code> </td></tr>
<tr>
<td> <code>one_chapter</code> </td><td> True if <code>html.standalone.one_chapter</code> is true, else not present </td><td> <code>html.standalone.template</code>, <code>html.standalone.js</code> </td></tr>
<tr>
<td> <code>book.svg</code> </td><td> The base64-encoded image of the button to display all chapters </td><td> <code>html.standalone.js</code>, <code>html.standalone.template</code> </td></tr>
<tr>
<td> <code>pages.svg</code> </td><td> The base64-encoded image of the button to display one chapter at a time </td><td> <code>html.standalone.js</code>, <code>html.standalone.template</code> </td></tr>
<tr>
<td> <code>favicon</code> </td><td> The <code>&lt;link rel = “icon” ...&gt;</code> tag if <code>html.icon</code> is set </td><td> <code>html.standalone.template</code>, <code>html.dir.template</code> </td></tr>
<tr>
<td> <code>menu_svg</code> </td><td> The base64-encoded image of the hamburger menu image </td><td> <code>html.standalone.template</code> </td></tr>
<tr>
<td> <code>prev_chapter</code> </td><td> Title and a link of previous chapter </td><td> <code>html.dir.template</code> </td></tr>
<tr>
<td> <code>next_chapter</code> </td><td> Title and a link of nexts chapter </td><td> <code>html.dir.template</code> </td></tr>
<tr>
<td> <code>class</code> </td><td> The content of <code>tex.class</code> </td><td> <code>tex.template</code> </td></tr>
<tr>
<td> <code>book</code> </td><td> True if <code>tex.class</code> is <code>book</code>, not set else </td><td> <code>tex.template</code> </td></tr>
<tr>
<td> <code>tex_lang</code> </td><td> The babel equivalent of <code>lang</code> </td><td> <code>tex.template</code> </td></tr>
<tr>
<td> <code>tex_title</code> </td><td> Set to true to run <code>\maketitle</code> </td><td> <code>tex.template</code> </td></tr>
<tr>
<td> <code>tex_size</code> </td><td> The font size to pass to the LaTeX class </td><td> <code>tex.template</code> </td></tr>
<tr>
<td> <code>has_tex_size</code> </td><td> Set to true if <code>tex_size</code> is set </td><td> <code>tex.template</code> </td></tr>
<tr>
<td> <code>margin_left</code>, <code>margin_right</code>, <code>margin_top</code>, <code>margin_bottom</code> </td><td> The margins of the document </td><td> <code>tex.template</code> </td></tr>
<tr>
<td> <code>initials</code> </td><td> True if <code>rendering.initials</code> is true, not set else </td><td> <code>tex.template</code> </td></tr>
<tr>
<td> <code>additional_code</code> </td><td> Set to the content of <code>tex.template.add</code>, <code>html.css.add</code> or <code>epub.css.add</code> </td><td> <code>tex.template</code>, <code>html.css</code>, <code>epub.css</code> </td></tr>
</table>
</div>
<div class = "notes">
<h2 class = "notes">Notes</h2>
<table class = "notes">
<tr class = "notes">
<td class = "note-number">
<p class = "note-number">
<a href = "#note-source-4">[4]</a>
</p>
</td>
<td class = "note">
<aside id = "note-dest-4"><p id = "para-185">Some of them, though, are not “real” templates, they are just files that are inserted, but cant contain mustache tags. This will probably evolve in future versions.</p>
</aside>
</td>
</tr>
<tr class = "notes">
<td class = "note-number">
<p class = "note-number">
<a href = "#note-source-5">[5]</a>
</p>
</td>
<td class = "note">
<aside id = "note-dest-5"><p id = "para-194">Mustache also provides the <code>{{foo}}</code> variant, which HTML-escapes the content of the variable. You should not use this, as Crowbook already renders and correctly escapes the variables it sets for use in templates.</p>
</aside>
</td>
</tr>
<tr class = "notes">
<td class = "note-number">
<p class = "note-number">
<a href = "#note-source-6">[6]</a>
</p>
</td>
<td class = "note">
<aside id = "note-dest-6"><p id = "para-200"><code>&lt;&lt;foo&gt;&gt;</code> might also work, but the ampersand is required to prevent mustache HTML-escaping the value. This is not good because:</p>
<ol>
<li>escaping is already done by Crowbook before setting variable content;</li>
<li>escaping HTML in a LaTeX document wont probably look good.</li>
</ol>
<h2 id = "link-88">5.2. List of templates</h2>
</aside>
</td>
</tr>
</table>
</div>
<p class = "next_chapter">
<a href = "chapter_005.html">
6. Proofreading with Crowbook »
</a>
</p>
</div>
<footer id = "footer"><p id = "para-353">Generated by <a href = "https://github.com/lise-henry/crowbook">Crowbook</a> 0.14.0</p>
</footer>
</div>
</body>
</html>