Своя TeX-заготовка
взял 1.txt за основу, но и так понятно
This commit is contained in:
parent
355733ff94
commit
9f8d6fd39f
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
build/
|
||||
*.epub
|
||||
*.html
|
||||
*.org
|
||||
|
|
3
Makefile
Normal file
3
Makefile
Normal file
|
@ -0,0 +1,3 @@
|
|||
all:
|
||||
pandoc --lua-filter=pangamebook.lua -o build/build.tex game.md
|
||||
xelatex -interaction=nonstopmode -output-directory=build start.tex
|
160
README.md
160
README.md
|
@ -1,159 +1 @@
|
|||
# Pangamebook
|
||||
[Pandoc](https://pandoc.org) is a free tool that converts documents between a
|
||||
large number of file formats. *Pangamebook* is a filter that can be used with
|
||||
Pandoc to shuffle and number sections in the document being converted. The only
|
||||
known use-case is to create a classic [gamebook](https://en.wikipedia.org/wiki/Gamebook).
|
||||
|
||||
Pandoc and Pangamebook should run on most modern computers. It has been tested
|
||||
on desktop computers running Windows 10, Linux (Lubuntu and Debian) and FreeBSD
|
||||
13.0. Also on a Raspberry Pi 4 running Raspberry Pi OS and on an Android phone
|
||||
(in Termux).
|
||||
|
||||
(TBD: Test in OSX.)
|
||||
|
||||
# Installing
|
||||
To use this filter you need to have Pandoc 2.1 or later installed (see
|
||||
[https://pandoc.org/installing.html]). Also see the [Pandoc Getting Started
|
||||
Article](https://pandoc.org/getting-started.html) if you never used Pandoc
|
||||
before.
|
||||
|
||||
The Pangamebook filter itself does not have to be installed. The file
|
||||
*pangamebook.lua* must be copied to somewhere on your computer and
|
||||
named on the command-line when running pandoc (see examples below).
|
||||
|
||||
## Windows
|
||||
Install Pandoc. Install MikTex (as linked from the Pandoc download page).
|
||||
Restart computer. Download *pangamebook.lua* and *example.md*.
|
||||
That should be enough to be able to run all the
|
||||
examples below. Otherwise search for help.
|
||||
|
||||
# Input Document
|
||||
First you need to write your gamebook. The recommended format is [Pandoc's
|
||||
Markdown](https://pandoc.org/MANUAL.html#pandocs-markdown). That is the format
|
||||
used for this README file and there is also an *example.md* document in this
|
||||
repository.
|
||||
|
||||
Other formats are also possible, but it can be tricky to make Pandoc and
|
||||
Pangamebook to properly interpret cross-references in some formats. Also
|
||||
Pandoc's Markdown supports inserting meta-data and inlining style information
|
||||
that can be very useful for advanced users, so it can be a good idea to get used
|
||||
to that format. Most modern text editors support Markdown, so
|
||||
it should not be difficult to get started.
|
||||
|
||||
# What the Filter Does
|
||||
Pangamebook looks for all top-level headers that contain of only lowercase
|
||||
letters, digits, and underscores. Headers like *start*, *first_room*, or
|
||||
*finding_some_loot_23* will be affected, but headers like *Introduction*, *How
|
||||
To Play*, *Character Sheet*, or *Epilogue* will be ignored.
|
||||
|
||||
A top-level header that is a (positive) number will also be ignored, as that
|
||||
number will be used as-is instead.
|
||||
|
||||
Pangamebook shuffles all affected headers together with everything that
|
||||
follows it up until the next top-level header, including lower-level headers
|
||||
and all text and images and tables etc. That collection of things that
|
||||
is moved together with the header is considered a *section*.
|
||||
|
||||
Sections will never be moved from before an ignored top-level header to after
|
||||
that header, or vice-versa. An important effect of this is that headers that are
|
||||
numbers, like **1** will *stay where they are*, and will also naturally divide
|
||||
the gamebook into parts that keeps the story from jump around too much. Most
|
||||
books will probably have a **1** header to mark the beginning of the story, and
|
||||
that will be guaranteed to remain the first one in the output as well. If the
|
||||
last header has a sufficiently high number (say **400**) it will remain the
|
||||
last. Any other header can also have a number to fix it in the story, but if
|
||||
there are too many sections to shuffle in between fixed headers the filter will
|
||||
not be happy (say if you fix **1** and **400**, but there are actually 410
|
||||
sections in the book).
|
||||
|
||||
After shuffling all sections that are to be shuffled, all their headings
|
||||
are numbered in sequence. There may be gaps created where there are
|
||||
headers that were given a fixed number. Headers that were already numbers,
|
||||
as mentioned above, will not be affected.
|
||||
|
||||
All cross-references in the document will lastly be updated to display
|
||||
the number they refer to, so what was in the original document
|
||||
"see first_room" (where *first_room* is a valid cross-reference, not just text)
|
||||
will become something like "see 12".
|
||||
|
||||
The best way to learn is probably to experiment with the included
|
||||
*example.md* and skim some of Pandoc's documentation.
|
||||
|
||||
# Output Document
|
||||
Most or all of the output formats Pandoc support should be possible (e.g. EPUB,
|
||||
PDF, HTML). By default Pandoc is going to remove almost all styling from
|
||||
documents as part of converting them, but see [Pandoc's User
|
||||
Guide](https://pandoc.org/MANUAL.html) for information on all the ways you can
|
||||
add style to the output document.
|
||||
|
||||
# Examples
|
||||
The file *example.md* is a Pandoc Markdown example gamebook. Open your favorite
|
||||
terminal and cd to this directory. The following commands can be used to
|
||||
generate a PDF, EPUB, and HTML book:
|
||||
|
||||
pandoc --lua-filter=pangamebook.lua -o example.html example.md
|
||||
pandoc --lua-filter=pangamebook.lua -o example.epub example.md
|
||||
pandoc --lua-filter=pangamebook.lua -o example.pdf example.md
|
||||
|
||||
(Pandoc needs *pdflatex* to be installed to generate a PDF. It will otherwise
|
||||
complain loudly when you run that last line. How to install pdflatex is beyond
|
||||
the scope of this README file.)
|
||||
|
||||
If you want to edit the generated book in a word processor it is also possible
|
||||
to generate for instance a MS Word or LibreOffice Word document:
|
||||
|
||||
pandoc --lua-filter=pangamebook.lua -o example.docx example.md
|
||||
pandoc --lua-filter=pangamebook.lua -o example.odt example.md
|
||||
|
||||
Manually editing the document after running Pandoc is probably a bad idea. Any
|
||||
edits will have to be done again if the document is ever recreated. It is better
|
||||
to read up on how to apply styles to the generated file, for instance by using a
|
||||
template style Word document.
|
||||
|
||||
# Export Heading Map (Advanced)
|
||||
Most will never need to use this, but
|
||||
the mapping of headers to numbers
|
||||
is added as metadata by the filter, normally not
|
||||
included in the output.
|
||||
One way to look at it is to output a JSON file using Pandoc:
|
||||
|
||||
pandoc --lua-filter=pangamebook.lua -o example.json example.md
|
||||
|
||||
Look for the key **pangamebook-mapping**. The value is an object with
|
||||
all headers mapped to numbers (as strings), although with some extra
|
||||
data that has to be filtered out because of how Pandoc stores metadata.
|
||||
Here is an example of what a key and value can look like:
|
||||
"#second" : {"t" : "MetaString",
|
||||
"c" : "2"}
|
||||
# Development
|
||||
Bug reports and feature requests are welcome on GitHub. The goal is to keep this
|
||||
tool very simple and focus on only numbering the sections. Additions are most
|
||||
likely better done by creating additional Pandoc filters, leaving it to
|
||||
end-users to decide what filters to combine.
|
||||
|
||||
Pangamebook is version managed using a private
|
||||
[Fossil](https://fossil-scm.org/) repository. The git repository on GitHub is a
|
||||
mirror that is updated with new releases.
|
||||
|
||||
# LICENSE
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Pelle Nilsson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
Pangamebook is copyright (c) 2021 Pelle Nilsson, MIT license
|
||||
|
|
0
build/.blankfile
Normal file
0
build/.blankfile
Normal file
67
start.tex
Normal file
67
start.tex
Normal file
|
@ -0,0 +1,67 @@
|
|||
\documentclass[twoside,12pt]{book}
|
||||
|
||||
\usepackage{calligra}
|
||||
\usepackage{polyglossia}
|
||||
\setdefaultlanguage{russian}
|
||||
\defaultfontfeatures{Ligatures=TeX, Scale=MatchLowercase}
|
||||
\newfontfamily{\cyrillicfont}{PT Serif}
|
||||
\setmainfont{PT Serif}
|
||||
|
||||
\usepackage{indentfirst}
|
||||
\usepackage{hyperref}
|
||||
\usepackage{color}
|
||||
\usepackage[nopagecolor=white]{pagecolor}
|
||||
\pagecolor{yellow!10}
|
||||
\definecolor{maroon}{RGB}{60,30,10}
|
||||
\definecolor{darkgreen}{RGB}{0,80,0}
|
||||
|
||||
\usepackage{geometry}
|
||||
\geometry{
|
||||
tmargin=5cm,
|
||||
bmargin=5cm,
|
||||
lmargin=5cm,
|
||||
rmargin=3cm,
|
||||
headheight=1.5cm,
|
||||
headsep=0.8cm,
|
||||
footskip=0.5cm}
|
||||
|
||||
\setlength{\parskip}{1.3ex plus 0.2ex minus 0.2ex}
|
||||
|
||||
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
|
||||
\renewcommand{\sectionmark}[1]{\markright{#1}}
|
||||
|
||||
\newcommand{\estcab}[1]{\itshape\textcolor{maroon}{#1}}
|
||||
|
||||
\setlength{\parindent}{1em} % Sangría española
|
||||
|
||||
\renewcommand{\footnoterule}{\vspace{-0.5em}\noindent\textcolor{marron}{\decosix \raisebox{2.9pt}{\line(1,0){100}} \lefthand} \vspace{.5em} }
|
||||
\usepackage[hang,splitrule]{footmisc}
|
||||
\addtolength{\footskip}{0.5cm}
|
||||
\setlength{\footnotemargin}{0.3cm}
|
||||
\setlength{\footnotesep}{0.4cm}
|
||||
|
||||
\renewcommand{\thesection}{\arabic{section}}
|
||||
\newcommand{\key}[1]{\emph{\textcolor{darkgreen}{#1}}}
|
||||
|
||||
%\newfontface\init{Oranienbaum}[Color=darkgreen]
|
||||
%\renewcommand{\LettrineFontHook}{\init}
|
||||
%\renewcommand*{\DefaultLoversize}{.18}
|
||||
%\renewcommand*{\DefaultLhang}{.1}
|
||||
\begin{document}
|
||||
\begin{titlepage}
|
||||
\begin{center}
|
||||
\vspace*{0.14\textheight}
|
||||
\raisebox{0pt}[0pt][0pt]{\Large%
|
||||
\textbf{1.t\raisebox{-0.3ex}{x}%
|
||||
\raisebox{-0.7ex}{t}%
|
||||
}
|
||||
}
|
||||
\vfill
|
||||
{\calligra goraph, 2017\\}
|
||||
\vfill
|
||||
\end{center}
|
||||
\end{titlepage}
|
||||
|
||||
\input{build/build.tex}
|
||||
|
||||
\end{document}
|
Loading…
Reference in a new issue