| Author | DaveJarvis <email> |
|---|---|
| Date | 2021-04-13 22:31:13 GMT-0700 |
| Commit | 9d769d14f2047113b0fedbd34193888413bf10aa |
| Parent | b0b5b74 |
| # Overview | ||
| -This document describes how to typeset from within the text editor. | ||
| - | ||
| -# Background | ||
| +This document describes how to typeset from within the text editor. The requirements include: | ||
| -This text editor helps keep content separated from presentation. Plain text documents will remain readable long after proprietary formats have become obsolete. However, we've come to expect much more in what we read than mere text: from hyperlinked tables of contents to indexes, from footers to footnotes, from mathematical expressions to complex graphics, modern documents are nuanced and multifaceted. | ||
| +* Download and install typesetting software | ||
| +* Download a theme pack | ||
| -Programming computers to typeset internationalized text automatically at the level we've become accustomed takes decades of development effort. Many free and open source software solutions can typeset text, including: ConTeXt, LaTeX, Sile, and others. ConTeXt is ideal for typesetting plain text into beautiful documents because it is developed with a notion of *setups*. These setups can wholly describe how text is to be typeset and---by being external to the text itself---configuring setups provides ample control over the document's final appearance without changing the prose. | ||
| +These are described in the subsequent sections. Once the requirements have been met, continue reading to learn how to typeset a document. | ||
| -# Installation | ||
| +# Install typesetter | ||
| Install ConTeXt as follows: | ||
| **Note:** The `PATH` environment variable must include the ConTeXt `bin` directory, otherwise the text editor will not be able to generate PDF files. | ||
| + | ||
| +# Install theme packs | ||
| + | ||
| +A theme defines how documents appear when typeset. A theme pack is a collection of themes in a zip file. Each theme has its own requirements, described in a separate section, below. Install and configure a theme as follows: | ||
| + | ||
| +1. Download the [https://gitreleases.dev/gh/DaveJarvis/keenwrite/latest/theme-packs.zip](theme-packs.zip) archive. | ||
| +1. Extract archive into a known location. | ||
| +1. Start the text editor. | ||
| +1. Click **Edit → Preferences**. | ||
| +1. Click **Typesetting**. | ||
| +1. Click **Browse** beside **Directories**. | ||
| +1. Navigate to the location where the themes are extracted. | ||
| +1. Select the **tarmes** directory. | ||
| +1. Click **Open**. | ||
| +1. Click **OK**. | ||
| + | ||
| +The "tarmes" theme is applied. | ||
| + | ||
| +## Tarmes theme | ||
| + | ||
| +Typesets using a pre-packaged TeX Gyre Termes font. | ||
| + | ||
| +## Handrit theme | ||
| + | ||
| +Typesets a manuscript using the pre-packaged TeX Gyre Cursor font. | ||
| + | ||
| +## Boschet theme | ||
| + | ||
| +To use this theme, download and install the following font families: | ||
| + | ||
| +* [Libre Baskerville](https://fonts.google.com/specimen/Libre+Baskerville) | ||
| +* [Archivo Narrow](https://fonts.google.com/specimen/Archivo+Narrow) | ||
| +* [Inconsolata](https://fonts.google.com/specimen/Inconsolata) | ||
| # Typeset document | ||
| The document is typeset; open the PDF file in any PDF reader to view the result. | ||
| + | ||
| +# Background | ||
| + | ||
| +This text editor helps keep content separated from presentation. Plain text documents will remain readable long after proprietary formats have become obsolete. However, we've come to expect much more in what we read than mere text: from hyperlinked tables of contents to indexes, from footers to footnotes, from mathematical expressions to complex graphics, modern documents are nuanced and multifaceted. | ||
| + | ||
| +Programming computers to typeset internationalized text automatically at the level we've become accustomed takes decades of development effort. Many free and open source software solutions can typeset text, including: ConTeXt, LaTeX, Sile, and others. ConTeXt is ideal for typesetting plain text into beautiful documents because it is developed with a notion of *setups*. These setups can wholly describe how text is to be typeset and---by being external to the text itself---configuring setups provides ample control over the document's final appearance without changing the prose. | ||
| + | ||
| DEPENDENCIES=( | ||
| "gradle,https://gradle.org" | ||
| + "zip,http://infozip.sourceforge.net" | ||
| "${FILE_PROPERTIES},File containing application name" | ||
| ) | ||
| gradle clean jar | ||
| mv "build/libs/${application_title}.jar" . | ||
| + | ||
| + $log "Create theme packs" | ||
| + rm -f theme-packs.zip | ||
| + zip -9 -r theme-packs.zip themes/ | ||
| } | ||
| -package com.keenwrite.io; | ||
| - | ||
| -import java.nio.file.Path; | ||
| -import java.nio.file.Paths; | ||
| -import java.util.stream.Stream; | ||
| - | ||
| -import static java.lang.System.getenv; | ||
| -import static java.nio.file.Files.isExecutable; | ||
| -import static java.util.regex.Pattern.quote; | ||
| - | ||
| -/** | ||
| - * Responsible for file-related functionality. | ||
| - */ | ||
| -public class File extends java.io.File { | ||
| - /** | ||
| - * For finding executable programs. | ||
| - */ | ||
| - private static final String[] EXTENSIONS = new String[] | ||
| - {"", ".com", ".exe", ".bat", ".cmd"}; | ||
| - | ||
| - /** | ||
| - * Creates a new instance for a given file name. | ||
| - * | ||
| - * @param pathname File name to represent for subsequent operations. | ||
| - */ | ||
| - public File( final String pathname ) { | ||
| - super( pathname ); | ||
| - } | ||
| - | ||
| - /** | ||
| - * For a file name that represents an executable (without an extension) | ||
| - * file, this determines whether the executable is found in the PATH | ||
| - * environment variable. This will search the PATH each time the method | ||
| - * is invoked, triggering a full directory scan for all paths listed in | ||
| - * the environment variable. The result is not cached, so avoid calling | ||
| - * this in a critical loop. | ||
| - * | ||
| - * @return {@code true} when the given file name references an executable | ||
| - * file located in the PATH environment variable. | ||
| - */ | ||
| - public boolean canRun() { | ||
| - final var exe = getName(); | ||
| - final var paths = getenv( "PATH" ).split( quote( pathSeparator ) ); | ||
| - return Stream.of( paths ).map( Paths::get ).anyMatch( | ||
| - path -> { | ||
| - final var p = path.resolve( exe ); | ||
| - | ||
| - for( final var extension : EXTENSIONS ) { | ||
| - if( isExecutable( Path.of( p.toString() + extension ) ) ) { | ||
| - return true; | ||
| - } | ||
| - } | ||
| - | ||
| - return false; | ||
| - } | ||
| - ); | ||
| - } | ||
| -} | ||
| package com.keenwrite.io; | ||
| -import java.io.BufferedInputStream; | ||
| -import java.io.FileInputStream; | ||
| -import java.io.IOException; | ||
| -import java.io.InputStream; | ||
| +import java.io.*; | ||
| import java.nio.file.Path; | ||
| import java.util.LinkedHashMap; | ||
| * @return The IANA-defined {@link MediaType}, or | ||
| * {@link MediaType#UNDEFINED} if indeterminate. | ||
| - * @throws IOException Could not read from the {@link File}. | ||
| + * @throws IOException Could not read from the {@link SysFile}. | ||
| */ | ||
| public static MediaType getMediaType( final Path path ) throws IOException { | ||
| return getMediaType( path.toFile() ); | ||
| } | ||
| /** | ||
| * Convenience method to return the probed media type for the given | ||
| - * {@link File} instance by delegating to {@link #getMediaType(InputStream)}. | ||
| + * {@link SysFile} instance by delegating to | ||
| + * {@link #getMediaType(InputStream)}. | ||
| * | ||
| * @param file File to ascertain the {@link MediaType}. | ||
| * @return The IANA-defined {@link MediaType}, or | ||
| * {@link MediaType#UNDEFINED} if indeterminate. | ||
| - * @throws IOException Could not read from the {@link File}. | ||
| + * @throws IOException Could not read from the {@link SysFile}. | ||
| */ | ||
| - public static MediaType getMediaType( final java.io.File file ) | ||
| + public static MediaType getMediaType( final File file ) | ||
| throws IOException { | ||
| try( final var fis = new FileInputStream( file ) ) { | ||
| * @return The IANA-defined {@link MediaType}, or | ||
| * {@link MediaType#UNDEFINED} if indeterminate. | ||
| - * @throws IOException Could not read from the {@link File}. | ||
| + * @throws IOException Could not read from the {@link SysFile}. | ||
| */ | ||
| public static MediaType getMediaType( final BufferedInputStream bis ) | ||
| +package com.keenwrite.io; | ||
| + | ||
| +import java.nio.file.Path; | ||
| +import java.nio.file.Paths; | ||
| +import java.util.stream.Stream; | ||
| + | ||
| +import static java.lang.System.getenv; | ||
| +import static java.nio.file.Files.isExecutable; | ||
| +import static java.util.regex.Pattern.quote; | ||
| + | ||
| +/** | ||
| + * Responsible for file-related functionality. | ||
| + */ | ||
| +public class SysFile extends java.io.File { | ||
| + /** | ||
| + * For finding executable programs. | ||
| + */ | ||
| + private static final String[] EXTENSIONS = new String[] | ||
| + {"", ".com", ".exe", ".bat", ".cmd"}; | ||
| + | ||
| + /** | ||
| + * Creates a new instance for a given file name. | ||
| + * | ||
| + * @param pathname File name to represent for subsequent operations. | ||
| + */ | ||
| + public SysFile( final String pathname ) { | ||
| + super( pathname ); | ||
| + } | ||
| + | ||
| + /** | ||
| + * For a file name that represents an executable (without an extension) | ||
| + * file, this determines whether the executable is found in the PATH | ||
| + * environment variable. This will search the PATH each time the method | ||
| + * is invoked, triggering a full directory scan for all paths listed in | ||
| + * the environment variable. The result is not cached, so avoid calling | ||
| + * this in a critical loop. | ||
| + * | ||
| + * @return {@code true} when the given file name references an executable | ||
| + * file located in the PATH environment variable. | ||
| + */ | ||
| + public boolean canRun() { | ||
| + final var exe = getName(); | ||
| + final var paths = getenv( "PATH" ).split( quote( pathSeparator ) ); | ||
| + return Stream.of( paths ).map( Paths::get ).anyMatch( | ||
| + path -> { | ||
| + final var p = path.resolve( exe ); | ||
| + | ||
| + for( final var extension : EXTENSIONS ) { | ||
| + if( isExecutable( Path.of( p.toString() + extension ) ) ) { | ||
| + return true; | ||
| + } | ||
| + } | ||
| + | ||
| + return false; | ||
| + } | ||
| + ); | ||
| + } | ||
| +} | ||
| package com.keenwrite.typesetting; | ||
| -import com.keenwrite.io.File; | ||
| +import com.keenwrite.io.SysFile; | ||
| import com.keenwrite.preferences.Key; | ||
| import com.keenwrite.preferences.Workspace; | ||
| */ | ||
| public class Typesetter { | ||
| - private static final File TYPESETTER = new File( "mtxrun" ); | ||
| + private static final SysFile TYPESETTER = new SysFile( "mtxrun" ); | ||
| private final Workspace mWorkspace; | ||
| } | ||
| - private String getProperty( final Key key ) { | ||
| + @SuppressWarnings( "SameParameterValue" ) | ||
| + private String stringProperty( final Key key ) { | ||
| return mWorkspace.stringProperty( key ).get(); | ||
| + } | ||
| + | ||
| + @SuppressWarnings( "SameParameterValue" ) | ||
| + private File fileProperty( final Key key ) { | ||
| + return mWorkspace.fileProperty( key ).get(); | ||
| } | ||
| private boolean reinitialize() { | ||
| final var filename = mOutput.getFileName(); | ||
| - final var paths = getProperty( KEY_TYPESET_CONTEXT_PATH ); | ||
| - final var envs = getProperty( KEY_TYPESET_CONTEXT_ENV ); | ||
| + final var paths = fileProperty( KEY_TYPESET_CONTEXT_PATH ); | ||
| + final var envs = stringProperty( KEY_TYPESET_CONTEXT_ENV ); | ||
| final var cacheExists = !isEmpty( getCacheDir().toPath() ); | ||
| mArgs.add( "--result='" + filename + "'" ); | ||
| mArgs.add( mInput.toString() ); | ||
| + | ||
| + final var sb = new StringBuilder( 128 ); | ||
| + mArgs.forEach( arg -> sb.append( arg ).append( " " ) ); | ||
| + clue( sb.toString() ); | ||
| } | ||
| else { | ||
| task.setOnFailed( e -> { | ||
| - clue( task.getException() ); | ||
| - fireExportFailedEvent(); | ||
| + final var ex = task.getException(); | ||
| + clue( ex ); | ||
| + | ||
| + if( ex instanceof TypeNotPresentException ) { | ||
| + fireExportFailedEvent(); | ||
| + } | ||
| } ); | ||
| import org.junit.jupiter.api.Test; | ||
| +import java.io.File; | ||
| + | ||
| import static com.keenwrite.io.MediaTypeExtension.valueFrom; | ||
| import static org.apache.commons.io.FilenameUtils.getExtension; |
| +# Overview | ||
| + | ||
| +Themes define how ConTeXt renders the final document into a PDF file. This | ||
| +document provides information that may be helpful for configuring the | ||
| +typesetter. | ||
| + | ||
| +# Fonts | ||
| + | ||
| +This section lists fonts recommended by various websites regarding serif | ||
| +fonts used by professional typesetters. | ||
| + | ||
| +## Highly Recommended | ||
| + | ||
| +Recommendations from at least two sources: | ||
| + | ||
| +* Bembo | ||
| +* Caslon Pro | ||
| +* Dante | ||
| +* Adobe Garamond Pro | ||
| +* Minion Pro | ||
| +* Palatino | ||
| +* Sabon | ||
| + | ||
| +## Typical | ||
| + | ||
| +Recommendations from one source: | ||
| + | ||
| +* Agmena Pro | ||
| +* Baskerville | ||
| +* Bodoni | ||
| +* Bookman Old Style | ||
| +* Cardo | ||
| +* Centaur | ||
| +* Century | ||
| +* Electra | ||
| +* Filosophia | ||
| +* Fournier | ||
| +* Jenson | ||
| +* Georgia | ||
| +* Goudy Bookletter 1911 | ||
| +* Hawking | ||
| +* Hoefler Text | ||
| +* Solitas Serif | ||
| +* Theano Didot | ||
| +* Tryst | ||
| + | ||
| +## Kindle | ||
| + | ||
| +Fonts available for use by Kindle readers: | ||
| + | ||
| +* Arial | ||
| +* Baskerville | ||
| +* Caecilia | ||
| +* Courier | ||
| +* Georgia | ||
| +* Helvetica | ||
| +* Lucida Sans Unicode | ||
| +* Palatino | ||
| +* Times New Roman | ||
| +* Trebuchet | ||
| +* Verdana | ||
| + | ||
| -# Overview | ||
| - | ||
| -Themes define how ConTeXt renders the final document into a PDF file. This | ||
| -document provides information that may be helpful for configuring the | ||
| -typesetter. | ||
| - | ||
| -# Fonts | ||
| - | ||
| -This section lists fonts recommended by various websites regarding serif | ||
| -fonts used by professional typesetters. | ||
| - | ||
| -## Highly Recommended | ||
| - | ||
| -Recommendations from at least two sources: | ||
| - | ||
| -* Bembo | ||
| -* Caslon Pro | ||
| -* Dante | ||
| -* Adobe Garamond Pro | ||
| -* Minion Pro | ||
| -* Palatino | ||
| -* Sabon | ||
| - | ||
| -## Typical | ||
| - | ||
| -Recommendations from one source: | ||
| - | ||
| -* Agmena Pro | ||
| -* Baskerville | ||
| -* Bodoni | ||
| -* Bookman Old Style | ||
| -* Cardo | ||
| -* Centaur | ||
| -* Century | ||
| -* Electra | ||
| -* Filosophia | ||
| -* Fournier | ||
| -* Jenson | ||
| -* Georgia | ||
| -* Goudy Bookletter 1911 | ||
| -* Hawking | ||
| -* Hoefler Text | ||
| -* Solitas Serif | ||
| -* Theano Didot | ||
| -* Tryst | ||
| - | ||
| -## Kindle | ||
| - | ||
| -Fonts available for use by Kindle readers: | ||
| - | ||
| -* Arial | ||
| -* Baskerville | ||
| -* Caecilia | ||
| -* Courier | ||
| -* Georgia | ||
| -* Helvetica | ||
| -* Lucida Sans Unicode | ||
| -* Palatino | ||
| -* Times New Roman | ||
| -* Trebuchet | ||
| -* Verdana | ||
| - | ||
| +\define\WPui{User Interface} | ||
| +\define\WPintro{Overview} | ||
| +\define\WPname{\Liberum{} \Consilium{}} | ||
| +\define\WPnavigation{Navigation} | ||
| +\define\WPproposal{proposal} | ||
| +\define\WPproposals{\WPproposal{}s} | ||
| +\define\WPProposal{\Word{\WPproposal{}}} | ||
| +\define\WPProposals{\WPProposal{}s} | ||
| + | ||
| +\define\WPdeliberation{deliberation} | ||
| +\define\WPdeliberations{\WPdeliberation{}s} | ||
| +\define\WPDeliberation{\Word{\WPdeliberation{}}} | ||
| +\define\WPDeliberations{\WPdeliberation{}s} | ||
| + | ||
| +% Separator for contiguous citations. | ||
| +\define\WPcitesep{\high{\,}} | ||
| + | ||
| +% Links to the web site for demonstration purposes. | ||
| +\def\WPhomepagebase{http://djarvis.bitbucket.org/xml/} | ||
| +\edef\WPpageaccount{\WPhomepagebase account.xml} | ||
| +\edef\WPpagediscuss{\WPhomepagebase discuss.xml} | ||
| +\edef\WPpagehome{\WPhomepagebase index.xml} | ||
| +\edef\WPpagehypothesis{\WPhomepagebase hypothesis.xml} | ||
| +\edef\WPpageproposal{\WPhomepagebase proposal.xml} | ||
| +\edef\WPpagesummary{\WPhomepagebase summary.xml} | ||
| +\edef\WPpagesupport{\WPhomepagebase support.xml} | ||
| +\edef\WPpageresources{\WPhomepagebase resources.xml} | ||
| + | ||
| +% Since the TOC suppresses a chapter title, conditionally set the | ||
| +% page heading. | ||
| +\define\WPheaderchapter{% | ||
| + \doiftextelse{\getmarking[chapter]}% | ||
| + {\vl{} \ss{\getmarking[chapter]}% | ||
| + {}}% | ||
| +} | ||
| + | ||
| +\define\WPheadertitle{% | ||
| + \doiftextelse{\getmarking[chapter]}% | ||
| + {\ss{\WPname} \vl{}}% | ||
| + {}% | ||
| +} | ||
| + | ||
| +\define[1]\WPcode{The #1 page source:\\} | ||
| + | ||
| +\define[3]\WPquote{% | ||
| + \quotation{#1} | ||
| + \par | ||
| + \startalignment[flushright] | ||
| + \textasciitilde{} #2, \it{#3} | ||
| + \stopalignment | ||
| +} | ||
| + | ||
| +\define[1]\WPpage{% | ||
| + \placefigure[force][fig:page-#1]{\Word{#1 Page}}{% | ||
| + \externalfigure[#1.svg] | ||
| + } | ||
| +} | ||
| + | ||
| +\define[1]\WPxref{% | ||
| + \in{Figure}[fig:#1] illustrates% | ||
| +} | ||
| + | ||
| +\define[1]\WPrefpage{% | ||
| + (see page \at[cha:#1])% | ||
| +} | ||
| + | ||
| +\define[1]\WPrefchapter{% | ||
| + \about[cha:#1] \WPrefpage{#1}% | ||
| +} | ||
| + | ||
| +\define[1]\WPreffigure{% | ||
| + illustrated in \in{Figure}[fig:#1] (on page \at[fig:#1])% | ||
| +} | ||
| + | ||
| +\define[1]\WPregistered{% | ||
| + #1\fontchar{registered}% | ||
| +} | ||
| +\usemodule[bib] | ||
| +\usemodule[vim] | ||
| +\usesymbols[nav] | ||
| +% Set up Roman numerals for the TOC | ||
| +\definestructureconversionset[frontpart:pagenumber][][romannumerals] | ||
| + | ||
| +\setuplist[chapter][pageconversionset=pagenumber] | ||
| + | ||
| +% Set up the ToC so that the page numbers are the internal link colour. | ||
| +\setuplist[chapter, section, subsection][ | ||
| + pagecolor=WPinternal, | ||
| + color=WPtocheading, | ||
| + before={\setupheader[state=stop]}, | ||
| +] | ||
| + | ||
| +% Clickable table of contents and leader dots. | ||
| +\setupcombinedlist[content][ | ||
| + alternative=c, | ||
| + interaction=all, | ||
| + list={chapter}, | ||
| +] | ||
| + | ||
| +\startsectionblockenvironment[frontpart] | ||
| + % Ensure the ToC starts at iii to match PDF page number. | ||
| + \setcounter [userpage] [2] | ||
| +\stopsectionblockenvironment | ||
| + | ||
| +\startsectionblockenvironment [bodypart] | ||
| + % Ensure the first chapter starts at 1 to match PDF page number. | ||
| + \setcounter [userpage] [1] | ||
| +\stopsectionblockenvironment | ||
| + | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| -% | ||
| -% Custom styling for annotations that appear in the document | ||
| -% | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| - | ||
| -\defineframedtext[projection][ | ||
| - style=tt, | ||
| - width=\textwidth, | ||
| -] | ||
| - | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| -% | ||
| -% Constant declarations for colours used throughout the document | ||
| -% | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| - | ||
| -% Darken or lighten the colours by the same amount. | ||
| -\def\TextColourDk{0.5} | ||
| -\def\TextColourLt{1.5} | ||
| - | ||
| -% Main colour | ||
| -\definecolor[TextColourPrimary][h=0081C2] | ||
| - | ||
| -% Accent colour | ||
| -\definecolor[TextColourSecondary][h=CB4A4C] | ||
| - | ||
| -% Shade colours | ||
| -\definecolor[TextColourTertiary][h=454545] | ||
| - | ||
| -% Hyperlink colour | ||
| -\definecolor[TextColourHyperlink][h=6C984C] | ||
| - | ||
| -\definespotcolor[TextColourPrimaryDk][TextColourPrimary][p=\TextColourDk] | ||
| -\definespotcolor[TextColourPrimaryLt][TextColourPrimary][p=\TextColourLt] | ||
| - | ||
| -\definespotcolor[TextColourSecondaryDk][TextColourSecondary][p=\TextColourDk] | ||
| -\definespotcolor[TextColourSecondaryLt][TextColourSecondary][p=\TextColourLt] | ||
| - | ||
| -\definespotcolor[TextColourTertiaryDk][TextColourTertiary][p=\TextColourDk] | ||
| -\definespotcolor[TextColourTertiaryLt][TextColourTertiary][p=\TextColourLt] | ||
| - | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| -% | ||
| -% Settings that apply to the whole document | ||
| -% | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| - | ||
| -% Enable full-colour documents | ||
| -\setupcolors[ | ||
| - state=start, | ||
| - rgb=yes, | ||
| - color=TextColourHyperlink, | ||
| - textcolor=TextColourTertiaryDk, | ||
| - pagecolormodel=auto, | ||
| -] | ||
| - | ||
| -% Enable clickable hyperlinks | ||
| -\setupinteraction[ | ||
| - state=start | ||
| -] | ||
| - | ||
| -% Prevent widows and orphans by forcing at least two (2) lines together | ||
| -\startsetups[grid][TextPenalties] | ||
| - \setdefaultpenalties | ||
| - \setpenalties\widowpenalties{2}{10000} | ||
| - \setpenalties\clubpenalties {2}{10000} | ||
| -\stopsetups | ||
| - | ||
| -\setuplayout[ | ||
| - grid=yes, | ||
| - setups=TextPenalties, | ||
| -] | ||
| - | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| -% | ||
| -% Map XHTML document entities to ConTeXt symbols and TeX macros | ||
| -% | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| - | ||
| -\xmltexentity{ldquo}{\symbol[leftquotation]{}} | ||
| -\xmltexentity{rdquo}{\symbol[rightquotation]{}} | ||
| -\xmltexentity{rsquo}{\quotesingle{}} | ||
| -\xmltexentity{mdash}{\emdash{}} | ||
| -\xmltexentity{ndash}{\endash{}} | ||
| -\xmltexentity{hellip}{\dots{}} | ||
| - | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| -% | ||
| -% Configure how images are presented | ||
| -% | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| - | ||
| -\setupexternalfigures[ | ||
| - order={svg,pdf,png}, | ||
| - maxwidth=\makeupwidth, | ||
| -] | ||
| - | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| -% | ||
| -% Configure floating element styles and behaviours | ||
| -% | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| - | ||
| -% Indent the paragraph following each table or image | ||
| -\setupfloats[indentnext=yes] | ||
| - | ||
| -% Force images to flow exactly where they fall in the text, captionlessly | ||
| -\setupfloat[figure][default={force,none}] | ||
| - | ||
| -% Allow tables to split across pages, force location in the text | ||
| -\setupfloat[table][default={here,split}] | ||
| - | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| -% | ||
| -% Define body fonts | ||
| -% | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| - | ||
| -\usetypescript[termes] | ||
| -\setupbodyfont[termes, 11pt] | ||
| - | ||
| -% Enable italics synonym | ||
| -\setupbodyfontenvironment[default][em=italic] | ||
| - | ||
| -\definefontfeature[default][default][ | ||
| - expansion=quality, | ||
| -] | ||
| - | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| -% | ||
| -% Configure heading styles and behaviours | ||
| -% | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| - | ||
| -\setuphead[chapter][ | ||
| - page=yes, | ||
| - header=empty, | ||
| - after={\blank[line]} | ||
| -] | ||
| - | ||
| -\setuphead[section,subsection][ | ||
| - page=no, | ||
| - number=yes, | ||
| - before={\blank[big]}, | ||
| - after={\blank[line]} | ||
| -] | ||
| - | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| -% | ||
| -% Command to simplify hyperlink syntax | ||
| -% | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| - | ||
| -\define[2]\href{% | ||
| - \begingroup | ||
| - \setupinteraction[ | ||
| - style=normal, | ||
| - color=TextColourHyperlink, | ||
| - ]% | ||
| - \goto{\color[TextColourHyperlink]{#1}}[url(#2)]% | ||
| - \endgroup% | ||
| -} | ||
| - | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| -% | ||
| -% Configure bullet and enumerated lists | ||
| -% | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| - | ||
| -\definesymbol[bullet][•] | ||
| - | ||
| -% Reduce the spacing around bullets. | ||
| -\setupitemgroup[itemize][1][packed,paragraph][ | ||
| - leftmargin=2em, | ||
| - distance=\zeropoint, | ||
| - symbol=bullet, | ||
| -] | ||
| - | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| -% | ||
| -% Import all definition and setup configurations | ||
| -% | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| - | ||
| -\input entities.tex | ||
| -\input xhtml.tex | ||
| -\input fonts.tex | ||
| -\input colours.tex | ||
| -\input classes.tex | ||
| -\input document.tex | ||
| -\input hyperlinks.tex | ||
| -\input headings.tex | ||
| -\input floats.tex | ||
| -\input figures.tex | ||
| -\input lists.tex | ||
| -\input tables.tex | ||
| -\input paragraphs.tex | ||
| - | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| -% | ||
| -% Configure how paragraphs are presented | ||
| -% | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| - | ||
| -\setupindenting[medium, yes] | ||
| - | ||
| -\setbreakpoints[compound] | ||
| - | ||
| -\setupalign[ | ||
| - hz, | ||
| - hanging, | ||
| - lesshyphenation, | ||
| -] | ||
| - | ||
| -\setuptolerance[ | ||
| - stretch, | ||
| - verytolerant, | ||
| -] | ||
| - | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| -% | ||
| -% Configures how tables are presented | ||
| -% | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| - | ||
| -\setupcaption[table][number=no] | ||
| - | ||
| -\setupxtable[ | ||
| - frame=off, | ||
| - framecolor=TextColourTertiaryLt, | ||
| - option={stretch,width}, | ||
| - split=yes, | ||
| - header=repeat, | ||
| - footer=repeat, | ||
| -] | ||
| - | ||
| -\setupxtable[head][ | ||
| - topframe=on, | ||
| - bottomframe=on, | ||
| - rulethickness=1pt] | ||
| -\setupxtable[body][] | ||
| -\setupxtable[foot][ | ||
| - bottomframe=on, | ||
| - rulethickness=1pt] | ||
| - | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| -% | ||
| -% Map XHTML elements to ConTeXt commands | ||
| -% | ||
| -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| - | ||
| -\startxmlsetups xml:xhtml | ||
| - % Do not typeset the HTML document's header title element | ||
| - \xmlsetsetup{\xmldocument}{*}{-} | ||
| - | ||
| - % Document elements | ||
| - \xmlsetsetup{\xmldocument}{html|body}{xml:*} | ||
| - | ||
| - % Header elements | ||
| - \xmlsetsetup{\xmldocument}{h1|h2|h3}{xml:*} | ||
| - | ||
| - % Block elements | ||
| - \xmlsetsetup{\xmldocument}{p|blockquote|div}{xml:*} | ||
| - | ||
| - % List elements | ||
| - \xmlsetsetup{\xmldocument}{ul|ol|li|dl|dt|dd}{xml:*} | ||
| - | ||
| - % Break elements | ||
| - \xmlsetsetup{\xmldocument}{hr|br}{xml:*} | ||
| - | ||
| - % Inline elements | ||
| - \xmlsetsetup{\xmldocument}{img|a|code|b|strong|em|q|sub|sup}{xml:*} | ||
| - | ||
| - % Table elements | ||
| - \xmlsetsetup{\xmldocument}{table|thead|tbody|tfoot|th|td|caption}{xml:*} | ||
| - \xmlsetsetup{\xmldocument}{tr[position()!=last()]}{xml:tr} | ||
| - \xmlsetsetup{\xmldocument}{tr[position()=last()]}{xml:tr:last} | ||
| - | ||
| - % TeX elements | ||
| - \xmlsetsetup{\xmldocument}{tex}{xml:*} | ||
| -\stopxmlsetups | ||
| - | ||
| -\input xml-document | ||
| -\input xml-headings | ||
| -\input xml-blocks | ||
| -\input xml-lists | ||
| -\input xml-breaks | ||
| -\input xml-inline | ||
| -\input xml-table | ||
| -\input xml-tex | ||
| - | ||
| -\xmlregistersetup{xml:xhtml} | ||
| - | ||
| -% Paragraphs are followed by a paragraph break. | ||
| -\startxmlsetups xml:p | ||
| - \xmlflush{#1}\par | ||
| -\stopxmlsetups | ||
| - | ||
| -% Indented quotations. | ||
| -\startxmlsetups xml:blockquote | ||
| - \quotation{\xmlflush{#1}} | ||
| -\stopxmlsetups | ||
| - | ||
| -% Map arbitrary div classes, defined by fenced divs. | ||
| -\startxmlsetups xml:div | ||
| - \start[\xmlatt{#1}{class}]\xmlflush{#1}\stop | ||
| -\stopxmlsetups | ||
| -\startxmlsetups xml:hr | ||
| - \blank | ||
| - \hrule | ||
| - \blank | ||
| -\stopxmlsetups | ||
| - | ||
| -\startxmlsetups xml:br | ||
| - \par | ||
| -\stopxmlsetups | ||
| -\startxmlsetups xml:html | ||
| - \xmlflush{#1} | ||
| -\stopxmlsetups | ||
| - | ||
| -\startxmlsetups xml:body | ||
| - \xmlflush{#1} | ||
| -\stopxmlsetups | ||
| -\startxmlsetups xml:h1 | ||
| - \chapter{\xmlflush{#1}} | ||
| -\stopxmlsetups | ||
| - | ||
| -\startxmlsetups xml:h2 | ||
| - \section{\xmlflush{#1}} | ||
| -\stopxmlsetups | ||
| - | ||
| -\startxmlsetups xml:h3 | ||
| - \subsection{\xmlflush{#1}} | ||
| -\stopxmlsetups | ||
| -\startxmlsetups xml:img | ||
| - \starttexcode | ||
| - \placefigure{}{% | ||
| - \externalfigure[\xmlatt{#1}{src}][conversion=mp] | ||
| - } | ||
| - \stoptexcode | ||
| -\stopxmlsetups | ||
| - | ||
| -% Requires the \href macro. | ||
| -\startxmlsetups xml:a | ||
| - \href{\xmlflush{#1}}{\xmlatt{#1}{href}} | ||
| -\stopxmlsetups | ||
| - | ||
| -\startxmlsetups xml:code | ||
| - \dontleavehmode{\tt\xmlflush{#1}} | ||
| -\stopxmlsetups | ||
| - | ||
| -% Strong text is bolded, typically. | ||
| -\startxmlsetups xml:strong | ||
| - \dontleavehmode{\bf\xmlflush{#1}} | ||
| -\stopxmlsetups | ||
| -\startxmlsetups xml:b | ||
| - \dontleavehmode{\bf\xmlflush{#1}} | ||
| -\stopxmlsetups | ||
| - | ||
| -% Emphasized text is italicized, typically. | ||
| -\startxmlsetups xml:em | ||
| - \dontleavehmode{\em\xmlflush{#1}} | ||
| -\stopxmlsetups | ||
| -\startxmlsetups xml:i | ||
| - \dontleavehmode{\em\xmlflush{#1}} | ||
| -\stopxmlsetups | ||
| - | ||
| -\startxmlsetups xml:q | ||
| - \quote{\xmlflush{#1}} | ||
| -\stopxmlsetups | ||
| - | ||
| -\startxmlsetups xml:sub | ||
| - \low{\xmlflush{#1}} | ||
| -\stopxmlsetups | ||
| - | ||
| -\startxmlsetups xml:sup | ||
| - \high{\xmlflush{#1}} | ||
| -\stopxmlsetups | ||
| -\startxmlsetups xml:ol | ||
| - \startitemize[n] | ||
| - \xmlflush{#1} | ||
| - \stopitemize | ||
| -\stopxmlsetups | ||
| - | ||
| -\startxmlsetups xml:ul | ||
| - \startitemize | ||
| - \xmlflush{#1} | ||
| - \stopitemize | ||
| -\stopxmlsetups | ||
| - | ||
| -\startxmlsetups xml:li | ||
| - \startitem \xmlflush{#1} \stopitem | ||
| -\stopxmlsetups | ||
| -\startxmlsetups xml:table | ||
| - \blank[medium] | ||
| - \startembeddedxtable | ||
| - \xmlflush{#1} | ||
| - \stopembeddedxtable | ||
| - \blank[medium] | ||
| -\stopxmlsetups | ||
| - | ||
| -\startxmlsetups xml:thead | ||
| - \startxtablebody[head] | ||
| - \xmlflush{#1} | ||
| - \stopxtablebody | ||
| -\stopxmlsetups | ||
| - | ||
| -\startxmlsetups xml:tbody | ||
| - \startxtablebody[body] | ||
| - \xmlflush{#1} | ||
| -\stopxmlsetups | ||
| - | ||
| -\startxmlsetups xml:tfoot | ||
| - \startxtablebody[foot] | ||
| - \xmlflush{#1} | ||
| - \stopxtablebody | ||
| -\stopxmlsetups | ||
| - | ||
| -\startxmlsetups xml:tr | ||
| - \startxrow | ||
| - \xmlflush{#1} | ||
| - \stopxrow | ||
| -\stopxmlsetups | ||
| - | ||
| -\startxmlsetups xml:tr:last | ||
| - \stopxtablebody | ||
| - \startxtablebody[foot] | ||
| - \startxrow\xmlflush{#1}\stopxrow | ||
| - \stopxtablebody | ||
| -\stopxmlsetups | ||
| - | ||
| -\startxmlsetups xml:th | ||
| - \startxcell | ||
| - \bold{\xmlflush{#1}} | ||
| - \stopxcell | ||
| -\stopxmlsetups | ||
| - | ||
| -\startxmlsetups xml:td | ||
| - \startxcell | ||
| - \xmlflush{#1} | ||
| - \stopxcell | ||
| -\stopxmlsetups | ||
| -\startxmlsetups xml:tex | ||
| - \xmlflushcontext{#1} | ||
| -\stopxmlsetups | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| +% | ||
| +% Custom styling for annotations that appear in the document | ||
| +% | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| + | ||
| +\defineframedtext[projection][ | ||
| + style=tt, | ||
| + width=\textwidth, | ||
| +] | ||
| + | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| +% | ||
| +% Constant declarations for colours used throughout the document | ||
| +% | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| + | ||
| +% Darken or lighten the colours by the same amount. | ||
| +\def\TextColourDk{0.5} | ||
| +\def\TextColourLt{1.5} | ||
| + | ||
| +% Main colour | ||
| +\definecolor[TextColourPrimary][h=0081C2] | ||
| + | ||
| +% Accent colour | ||
| +\definecolor[TextColourSecondary][h=CB4A4C] | ||
| + | ||
| +% Shade colours | ||
| +\definecolor[TextColourTertiary][h=454545] | ||
| + | ||
| +% Hyperlink colour | ||
| +\definecolor[TextColourHyperlink][h=6C984C] | ||
| + | ||
| +\definespotcolor[TextColourPrimaryDk][TextColourPrimary][p=\TextColourDk] | ||
| +\definespotcolor[TextColourPrimaryLt][TextColourPrimary][p=\TextColourLt] | ||
| + | ||
| +\definespotcolor[TextColourSecondaryDk][TextColourSecondary][p=\TextColourDk] | ||
| +\definespotcolor[TextColourSecondaryLt][TextColourSecondary][p=\TextColourLt] | ||
| + | ||
| +\definespotcolor[TextColourTertiaryDk][TextColourTertiary][p=\TextColourDk] | ||
| +\definespotcolor[TextColourTertiaryLt][TextColourTertiary][p=\TextColourLt] | ||
| + | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| +% | ||
| +% Settings that apply to the whole document | ||
| +% | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| + | ||
| +% Enable full-colour documents | ||
| +\setupcolors[ | ||
| + state=start, | ||
| + rgb=yes, | ||
| + color=TextColourHyperlink, | ||
| + textcolor=TextColourTertiaryDk, | ||
| + pagecolormodel=auto, | ||
| +] | ||
| + | ||
| +% Enable clickable hyperlinks | ||
| +\setupinteraction[ | ||
| + state=start | ||
| +] | ||
| + | ||
| +% Prevent widows and orphans by forcing at least two (2) lines together | ||
| +\startsetups[grid][TextPenalties] | ||
| + \setdefaultpenalties | ||
| + \setpenalties\widowpenalties{2}{10000} | ||
| + \setpenalties\clubpenalties {2}{10000} | ||
| +\stopsetups | ||
| + | ||
| +\setuplayout[ | ||
| + grid=yes, | ||
| + setups=TextPenalties, | ||
| +] | ||
| + | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| +% | ||
| +% Configure how images are presented | ||
| +% | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| + | ||
| +\setupexternalfigures[ | ||
| + order={svg,pdf,png}, | ||
| + maxwidth=\makeupwidth, | ||
| +] | ||
| + | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| +% | ||
| +% Configure floating element styles and behaviours | ||
| +% | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| + | ||
| +% Indent the paragraph following each table or image | ||
| +\setupfloats[indentnext=yes] | ||
| + | ||
| +% Force images to flow exactly where they fall in the text, captionlessly | ||
| +\setupfloat[figure][default={force,none}] | ||
| + | ||
| +% Allow tables to split across pages, force location in the text | ||
| +\setupfloat[table][default={here,split}] | ||
| + | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| +% | ||
| +% Define body fonts | ||
| +% | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| + | ||
| +\usetypescript[termes] | ||
| +\setupbodyfont[termes, 11pt] | ||
| + | ||
| +% Enable italics synonym | ||
| +\setupbodyfontenvironment[default][em=italic] | ||
| + | ||
| +\definefontfeature[default][default][ | ||
| + expansion=quality, | ||
| +] | ||
| + | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| +% | ||
| +% Configure heading styles and behaviours | ||
| +% | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| + | ||
| +\setuphead[chapter][ | ||
| + page=yes, | ||
| + header=empty, | ||
| + after={\blank[line]} | ||
| +] | ||
| + | ||
| +\setuphead[section,subsection][ | ||
| + page=no, | ||
| + number=yes, | ||
| + before={\blank[big]}, | ||
| + after={\blank[line]} | ||
| +] | ||
| + | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| +% | ||
| +% Command to simplify hyperlink syntax | ||
| +% | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| + | ||
| +\define[2]\href{% | ||
| + \begingroup | ||
| + \setupinteraction[ | ||
| + style=normal, | ||
| + color=TextColourHyperlink, | ||
| + ]% | ||
| + \goto{\color[TextColourHyperlink]{#1}}[url(#2)]% | ||
| + \endgroup% | ||
| +} | ||
| + | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| +% | ||
| +% Configure bullet and enumerated lists | ||
| +% | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| + | ||
| +\definesymbol[bullet][•] | ||
| + | ||
| +% Reduce the spacing around bullets. | ||
| +\setupitemgroup[itemize][1][packed,paragraph][ | ||
| + leftmargin=2em, | ||
| + distance=\zeropoint, | ||
| + symbol=bullet, | ||
| +] | ||
| + | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| +% | ||
| +% Import all definition and setup configurations | ||
| +% | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| + | ||
| +\input xhtml | ||
| +\input fonts | ||
| +\input colours | ||
| +\input classes | ||
| +\input document | ||
| +\input hyperlinks | ||
| +\input headings | ||
| +\input floats | ||
| +\input figures | ||
| +\input lists | ||
| +\input tables | ||
| +\input paragraphs | ||
| + | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| +% | ||
| +% Configure how paragraphs are presented | ||
| +% | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| + | ||
| +\setupindenting[medium, yes] | ||
| + | ||
| +\setbreakpoints[compound] | ||
| + | ||
| +\setupalign[ | ||
| + hz, | ||
| + hanging, | ||
| + lesshyphenation, | ||
| +] | ||
| + | ||
| +\setuptolerance[ | ||
| + stretch, | ||
| + verytolerant, | ||
| +] | ||
| + | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| +% | ||
| +% Configures how tables are presented | ||
| +% | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| + | ||
| +\setupcaption[table][number=no] | ||
| + | ||
| +\setupxtable[ | ||
| + frame=off, | ||
| + framecolor=TextColourTertiaryLt, | ||
| + option={stretch,width}, | ||
| + split=yes, | ||
| + header=repeat, | ||
| + footer=repeat, | ||
| +] | ||
| + | ||
| +\setupxtable[head][ | ||
| + topframe=on, | ||
| + bottomframe=on, | ||
| + rulethickness=1pt, | ||
| +] | ||
| +\setupxtable[body][] | ||
| +\setupxtable[foot][ | ||
| + bottomframe=on, | ||
| + rulethickness=1pt, | ||
| +] | ||
| + | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| +% | ||
| +% Import XHTML to ConTeXt setups | ||
| +% | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| + | ||
| +\usesubpath[../xhtml] | ||
| +\input ../xhtml/setups | ||
| + | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| +% | ||
| +% Map XHTML elements to ConTeXt commands | ||
| +% | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| + | ||
| +\startxmlsetups xml:xhtml | ||
| + % Do not typeset the HTML document's header title element | ||
| + \xmlsetsetup{\xmldocument}{*}{-} | ||
| + | ||
| + % Document elements | ||
| + \xmlsetsetup{\xmldocument}{html|body}{xml:*} | ||
| + | ||
| + % Header elements | ||
| + \xmlsetsetup{\xmldocument}{h1|h2|h3}{xml:*} | ||
| + | ||
| + % Block elements | ||
| + \xmlsetsetup{\xmldocument}{p|blockquote|div}{xml:*} | ||
| + | ||
| + % List elements | ||
| + \xmlsetsetup{\xmldocument}{ul|ol|li|dl|dt|dd}{xml:*} | ||
| + | ||
| + % Break elements | ||
| + \xmlsetsetup{\xmldocument}{hr|br}{xml:*} | ||
| + | ||
| + % Inline elements | ||
| + \xmlsetsetup{\xmldocument}{img|a|code|b|strong|em|q|sub|sup}{xml:*} | ||
| + | ||
| + % Table elements | ||
| + \xmlsetsetup{\xmldocument}{table|thead|tbody|tfoot|th|td|caption}{xml:*} | ||
| + \xmlsetsetup{\xmldocument}{tr[position()!=last()]}{xml:tr} | ||
| + \xmlsetsetup{\xmldocument}{tr[position()=last()]}{xml:tr:last} | ||
| + | ||
| + % TeX elements | ||
| + \xmlsetsetup{\xmldocument}{tex}{xml:*} | ||
| +\stopxmlsetups | ||
| + | ||
| +\input xml-entities | ||
| +\input xml-document | ||
| +\input xml-headings | ||
| +\input xml-blocks | ||
| +\input xml-lists | ||
| +\input xml-breaks | ||
| +\input xml-inline | ||
| +\input xml-table | ||
| +\input xml-tex | ||
| + | ||
| +\xmlregistersetup{xml:xhtml} | ||
| + | ||
| +% Paragraphs are followed by a paragraph break. | ||
| +\startxmlsetups xml:p | ||
| + \xmlflush{#1}\par | ||
| +\stopxmlsetups | ||
| + | ||
| +% Indented quotations. | ||
| +\startxmlsetups xml:blockquote | ||
| + \quotation{\xmlflush{#1}} | ||
| +\stopxmlsetups | ||
| + | ||
| +% Map arbitrary div classes, defined by fenced divs. | ||
| +\startxmlsetups xml:div | ||
| + \start[\xmlatt{#1}{class}]\xmlflush{#1}\stop | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:hr | ||
| + \blank | ||
| + \hrule | ||
| + \blank | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:br | ||
| + \par | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:html | ||
| + \xmlflush{#1} | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:body | ||
| + \xmlflush{#1} | ||
| +\stopxmlsetups | ||
| + | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| +% | ||
| +% Map XHTML document entities to ConTeXt symbols and TeX macros | ||
| +% | ||
| +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| + | ||
| +\xmltexentity{ldquo}{\symbol[leftquotation]{}} | ||
| +\xmltexentity{rdquo}{\symbol[rightquotation]{}} | ||
| +\xmltexentity{rsquo}{\quotesingle{}} | ||
| +\xmltexentity{mdash}{\emdash{}} | ||
| +\xmltexentity{ndash}{\endash{}} | ||
| +\xmltexentity{hellip}{\dots{}} | ||
| + | ||
| +\startxmlsetups xml:h1 | ||
| + \chapter{\xmlflush{#1}} | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:h2 | ||
| + \section{\xmlflush{#1}} | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:h3 | ||
| + \subsection{\xmlflush{#1}} | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:img | ||
| + \starttexcode | ||
| + \placefigure{}{% | ||
| + \externalfigure[\xmlatt{#1}{src}][conversion=mp] | ||
| + } | ||
| + \stoptexcode | ||
| +\stopxmlsetups | ||
| + | ||
| +% Requires the \href macro. | ||
| +\startxmlsetups xml:a | ||
| + \href{\xmlflush{#1}}{\xmlatt{#1}{href}} | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:code | ||
| + \dontleavehmode{\tt\xmlflush{#1}} | ||
| +\stopxmlsetups | ||
| + | ||
| +% Strong text is bolded, typically. | ||
| +\startxmlsetups xml:strong | ||
| + \dontleavehmode{\bf\xmlflush{#1}} | ||
| +\stopxmlsetups | ||
| +\startxmlsetups xml:b | ||
| + \dontleavehmode{\bf\xmlflush{#1}} | ||
| +\stopxmlsetups | ||
| + | ||
| +% Emphasized text is italicized, typically. | ||
| +\startxmlsetups xml:em | ||
| + \dontleavehmode{\em\xmlflush{#1}} | ||
| +\stopxmlsetups | ||
| +\startxmlsetups xml:i | ||
| + \dontleavehmode{\em\xmlflush{#1}} | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:q | ||
| + \quote{\xmlflush{#1}} | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:sub | ||
| + \low{\xmlflush{#1}} | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:sup | ||
| + \high{\xmlflush{#1}} | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:ol | ||
| + \startitemize[n] | ||
| + \xmlflush{#1} | ||
| + \stopitemize | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:ul | ||
| + \startitemize | ||
| + \xmlflush{#1} | ||
| + \stopitemize | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:li | ||
| + \startitem \xmlflush{#1} \stopitem | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:table | ||
| + \blank[medium] | ||
| + \startembeddedxtable | ||
| + \xmlflush{#1} | ||
| + \stopembeddedxtable | ||
| + \blank[medium] | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:thead | ||
| + \startxtablebody[head] | ||
| + \xmlflush{#1} | ||
| + \stopxtablebody | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:tbody | ||
| + \startxtablebody[body] | ||
| + \xmlflush{#1} | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:tfoot | ||
| + \startxtablebody[foot] | ||
| + \xmlflush{#1} | ||
| + \stopxtablebody | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:tr | ||
| + \startxrow | ||
| + \xmlflush{#1} | ||
| + \stopxrow | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:tr:last | ||
| + \stopxtablebody | ||
| + \startxtablebody[foot] | ||
| + \startxrow\xmlflush{#1}\stopxrow | ||
| + \stopxtablebody | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:th | ||
| + \startxcell | ||
| + \bold{\xmlflush{#1}} | ||
| + \stopxcell | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:td | ||
| + \startxcell | ||
| + \xmlflush{#1} | ||
| + \stopxcell | ||
| +\stopxmlsetups | ||
| + | ||
| +\startxmlsetups xml:tex | ||
| + \xmlflushcontext{#1} | ||
| +\stopxmlsetups | ||
| + | ||
| Delta | 774 lines added, 588 lines removed, 186-line increase |
|---|