diff --git a/examples/letter.gamebook b/examples/letter.gamebook new file mode 100644 index 0000000..48e4e06 --- /dev/null +++ b/examples/letter.gamebook @@ -0,0 +1,5 @@ +title = Letter +* start +LaTeX output (and this PDF output) from this book +should be in letter size rather than the default A5 size +(see command-line options used in letter.gamebook.options). diff --git a/examples/letter.gamebook.options b/examples/letter.gamebook.options new file mode 100644 index 0000000..0c4cc80 --- /dev/null +++ b/examples/letter.gamebook.options @@ -0,0 +1 @@ +--option letter \ No newline at end of file diff --git a/expected/letter.debug b/expected/letter.debug new file mode 100644 index 0000000..726dd2c --- /dev/null +++ b/expected/letter.debug @@ -0,0 +1,8 @@ +BEGIN DEBUG OUTPUT +Book title: Letter +Number of sections: 1 + + +Turn to 1 to begin. +1 (start) - LaTeX output (and this PDF output) from this book should be in letter size rather than the default A5 size (see command-line options used in letter.gamebook.options). +END DEBUG OUTPUT diff --git a/expected/letter.dot b/expected/letter.dot new file mode 100644 index 0000000..5315c7f --- /dev/null +++ b/expected/letter.dot @@ -0,0 +1,3 @@ +digraph gamebook { + + } diff --git a/expected/letter.html b/expected/letter.html new file mode 100644 index 0000000..096a732 --- /dev/null +++ b/expected/letter.html @@ -0,0 +1,68 @@ + + + + + + Letter + + + + + + +
+ + + + + +
+
1
+
+ LaTeX output (and this PDF output) from this book should be in letter size rather than the default A5 size (see command-line options used in letter.gamebook.options). +
+
+
+
+
+ + +
+
+
+
+
+ + +
+ + + + + + diff --git a/expected/letter.rtf b/expected/letter.rtf new file mode 100644 index 0000000..409bd75 --- /dev/null +++ b/expected/letter.rtf @@ -0,0 +1,20 @@ +{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360 +{\fonttbl\f0\fswiss\fcharset0 Helvetica;} +{\colortbl;\red255\green255\blue255;} +\paperw11900\paperh16840\margl1440\margr1440\vieww14140\viewh14860\viewkind0 +\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural + +\f0\b\fs24 \cf0 + +\b \qc Letter +\b0\ + +\b Turn to 1 to begin. +\b0\ +\ +\b \qc 1 +\b0\ +\ql LaTeX output (and this PDF output) from this book should be in letter size rather than the default A5 size (see command-line options used in letter.gamebook.options). \ +\ + +} diff --git a/expected/letter.tex b/expected/letter.tex new file mode 100644 index 0000000..277aed2 --- /dev/null +++ b/expected/letter.tex @@ -0,0 +1,46 @@ +\documentclass[letter,onecolumn]{book} +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +\usepackage[hidelinks]{hyperref} +\usepackage{graphicx} + +\usepackage[top=3.3cm, bottom=3.3cm, left=2cm, right=2cm]{geometry} +\newif\ifpdf +\ifx\pdfoutput\undefined + \pdffalse +\else + \ifnum\pdfoutput=1 + \pdftrue + \else + \pdffalse + \fi +\fi + +\title{Letter} +\author{} +\date{} + +\newcounter{sectionnr} + +\begin{document} + +\maketitle + +\thispagestyle{empty} + +\pagestyle{empty} + +\clearpage + + + +Turn to 1 to begin. +\phantomsection +\refstepcounter{sectionnr} +\label{section1} +\subsection*{\begin{center} \textbf{1} \end{center}} + + \noindent + LaTeX output (and this PDF output) from this book should be in letter size rather than the default A5 size (see command-line options used in letter.gamebook.options). +\vspace{1em} +\end{document} diff --git a/expected/letter.txt b/expected/letter.txt new file mode 100644 index 0000000..27249f3 --- /dev/null +++ b/expected/letter.txt @@ -0,0 +1,8 @@ + Letter + + + +Turn to 1 to begin. +1 + LaTeX output (and this PDF output) from this book should be in letter size rather than the default A5 size (see command-line options used in letter.gamebook.options). + diff --git a/formatgamebook.py b/formatgamebook.py index aaf91c5..e09eb89 100755 --- a/formatgamebook.py +++ b/formatgamebook.py @@ -193,15 +193,22 @@ if __name__ == '__main__': help='ignore default map file') ap.add_argument('-t', '--template', metavar='D', dest='templatedirs', action='append', help='add custom template dir') + ap.add_argument('-o', '--option', metavar='D', dest='optionsdirs', + action='append', help='add template override options dir') ap.add_argument('-S', '--no-shuffle', action='store_false', dest='shuffle', help='do not shuffle sections') args = ap.parse_args() templatedirs = ['templates', os.path.join(os.path.dirname(sys.argv[0]), 'templates')] + optionsbasedir = os.path.join(os.path.dirname(sys.argv[0]), 'options') if args.templatedirs: for t in args.templatedirs: templatedirs.insert(-2, t) + if args.optionsdirs: + for o in args.optionsdirs: + print os.path.join(optionsbasedir, o) + templatedirs.insert(-2, os.path.join(optionsbasedir, o)) format_gamebook(args.inputfiles, args.outputfile, args.import_default_map_file, diff --git a/o/a4/tex/documentclass.tex b/options/a4/tex/documentclass.tex similarity index 100% rename from o/a4/tex/documentclass.tex rename to options/a4/tex/documentclass.tex diff --git a/o/a5/tex/documentclass.tex b/options/a5/tex/documentclass.tex similarity index 100% rename from o/a5/tex/documentclass.tex rename to options/a5/tex/documentclass.tex diff --git a/o/letter/tex/documentclass.tex b/options/letter/tex/documentclass.tex similarity index 100% rename from o/letter/tex/documentclass.tex rename to options/letter/tex/documentclass.tex diff --git a/readme.org b/readme.org index feb4a31..8bcaf10 100644 --- a/readme.org +++ b/readme.org @@ -15,6 +15,7 @@ gamebook on paper or a screen (or for debugging it). : -i T, --include T only include sections with tag : -M, --no-default-map ignore default map file : -t D, --template D add custom template dir +: -o D, --option D add template override options dir : -S, --no-shuffle do not shuffle sections ** Supported Output Formats @@ -28,7 +29,25 @@ gamebook on paper or a screen (or for debugging it). | Plain Text | .txt | Raw plain text without formatting. | | Debug Plain Text | .debug | Plain text debug output of gamebook contents. | -More to be added. +More to be added. Custom output formats or modifications to the +default formats can easily be added. Use the *-t* command-line +option to add subdirectories containing new templates or +overrides for default templates. + +** Included Optional Templates + +The *-o* command-line option is like *-t* but searches the *options* +subdirectory (next to the default *templates* subdirectory) that +contains useful overrides for some behavior of the default output +formats. For example adding *-o letter* to the command-line will +produce LaTeX files in Letter size rather than the default A5 size. + +| Name | Formats | Description | +|--------+---------+--------------------------------------| +| a4 | tex | A4 paper size documents (PDF). | +| a5 | tex | A5 paper size documents (PDF). | +| letter | tex | Letter paper size documents (PDF). | +| static | html | Remove script link from HTML output. | ** Gamebook Format