mirror of
https://github.com/Oreolek/gamebookformat.git
synced 2024-06-16 15:10:45 +03:00
Option to add extra map-files for parsing.
This commit is contained in:
parent
f6716ef69d
commit
d67604822e
2
Makefile
2
Makefile
|
@ -80,7 +80,7 @@ clean:
|
|||
examples/*.txt examples/*.debug examples/*.log \
|
||||
examples/*.pdf examples/*.out *~ examples/*~ *.pyc \
|
||||
examples/*.dot examples/*.aux examples/*.toc $(png) \
|
||||
examples/*.map templates/*~ templates/*/*~ \
|
||||
$(map) templates/*~ templates/*/*~ \
|
||||
$(examples:.gamebook=.png) readme.html \
|
||||
examples/*.js examples/*.css
|
||||
|
||||
|
|
9
examples/withmaps.gamebook
Normal file
9
examples/withmaps.gamebook
Normal file
|
@ -0,0 +1,9 @@
|
|||
title = Example Gamebook With Maps
|
||||
author = Pelle Nilsson
|
||||
|
||||
* start
|
||||
This should have number 10, as specified in first map file.
|
||||
The end, at [[end]], should be at 99.
|
||||
|
||||
* end
|
||||
Number 99, as specified in second map file.
|
1
examples/withmaps.gamebook.options
Normal file
1
examples/withmaps.gamebook.options
Normal file
|
@ -0,0 +1 @@
|
|||
-M -m examples/withmaps1.map -m examples/withmaps2.map
|
1
examples/withmaps.map
Normal file
1
examples/withmaps.map
Normal file
|
@ -0,0 +1 @@
|
|||
{"Dummy": 98, "end": 99, "start": 10}
|
1
examples/withmaps1.map
Normal file
1
examples/withmaps1.map
Normal file
|
@ -0,0 +1 @@
|
|||
{"start" : 10}
|
1
examples/withmaps2.map
Normal file
1
examples/withmaps2.map
Normal file
|
@ -0,0 +1 @@
|
|||
{"end" : 99}
|
|
@ -27,12 +27,11 @@
|
|||
|
||||
\maketitle
|
||||
|
||||
\clearpage
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\pagestyle{empty}
|
||||
|
||||
\clearpage
|
||||
|
||||
\subsection*{\begin{center} \textbf{Introduction} \end{center}}
|
||||
|
||||
|
||||
|
|
|
@ -27,13 +27,12 @@
|
|||
|
||||
\maketitle
|
||||
|
||||
\clearpage
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\pagestyle{empty}
|
||||
|
||||
\clearpage
|
||||
|
||||
|
||||
|
||||
Turn to 1 to begin.
|
||||
\phantomsection
|
||||
|
|
|
@ -27,12 +27,11 @@
|
|||
|
||||
\maketitle
|
||||
|
||||
\clearpage
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\pagestyle{empty}
|
||||
|
||||
\clearpage
|
||||
|
||||
\subsection*{\begin{center} \textbf{Introduction} \end{center}}
|
||||
|
||||
|
||||
|
|
|
@ -27,12 +27,11 @@
|
|||
|
||||
\maketitle
|
||||
|
||||
\clearpage
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\pagestyle{empty}
|
||||
|
||||
\clearpage
|
||||
|
||||
\subsection*{\begin{center} \textbf{Introduction} \end{center}}
|
||||
|
||||
|
||||
|
|
|
@ -27,13 +27,12 @@
|
|||
|
||||
\maketitle
|
||||
|
||||
\clearpage
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\pagestyle{empty}
|
||||
|
||||
\clearpage
|
||||
|
||||
|
||||
|
||||
Turn to 1 to begin.
|
||||
\phantomsection
|
||||
|
|
|
@ -26,13 +26,12 @@
|
|||
|
||||
\maketitle
|
||||
|
||||
\clearpage
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\pagestyle{empty}
|
||||
|
||||
\clearpage
|
||||
|
||||
|
||||
|
||||
Turn to 1 to begin.
|
||||
\phantomsection
|
||||
|
|
|
@ -27,12 +27,11 @@
|
|||
|
||||
\maketitle
|
||||
|
||||
\clearpage
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\pagestyle{empty}
|
||||
|
||||
\clearpage
|
||||
|
||||
\subsection*{\begin{center} \textbf{Introduction} \end{center}}
|
||||
|
||||
|
||||
|
|
|
@ -27,12 +27,11 @@
|
|||
|
||||
\maketitle
|
||||
|
||||
\clearpage
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\pagestyle{empty}
|
||||
|
||||
\clearpage
|
||||
|
||||
\subsection*{\begin{center} \textbf{Introduction} \end{center}}
|
||||
|
||||
|
||||
|
|
|
@ -27,13 +27,12 @@
|
|||
|
||||
\maketitle
|
||||
|
||||
\clearpage
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\pagestyle{empty}
|
||||
|
||||
\clearpage
|
||||
|
||||
|
||||
|
||||
Turn to 1 to begin.
|
||||
\phantomsection
|
||||
|
|
|
@ -27,13 +27,12 @@
|
|||
|
||||
\maketitle
|
||||
|
||||
\clearpage
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\pagestyle{empty}
|
||||
|
||||
\clearpage
|
||||
|
||||
|
||||
|
||||
Turn to 1 to begin.
|
||||
\phantomsection
|
||||
|
|
106
expected/withmaps.debug
Normal file
106
expected/withmaps.debug
Normal file
|
@ -0,0 +1,106 @@
|
|||
BEGIN DEBUG OUTPUT
|
||||
Book title: Example Gamebook With Maps
|
||||
Number of sections: 99
|
||||
|
||||
|
||||
Turn to 1 to begin.
|
||||
1 () - (EMPTY)
|
||||
2 () - (EMPTY)
|
||||
3 () - (EMPTY)
|
||||
4 () - (EMPTY)
|
||||
5 () - (EMPTY)
|
||||
6 () - (EMPTY)
|
||||
7 () - (EMPTY)
|
||||
8 () - (EMPTY)
|
||||
9 () - (EMPTY)
|
||||
10 (start) - This should have number 10, as specified in first map file. The end, at 99, should be at 99.
|
||||
11 () - (EMPTY)
|
||||
12 () - (EMPTY)
|
||||
13 () - (EMPTY)
|
||||
14 () - (EMPTY)
|
||||
15 () - (EMPTY)
|
||||
16 () - (EMPTY)
|
||||
17 () - (EMPTY)
|
||||
18 () - (EMPTY)
|
||||
19 () - (EMPTY)
|
||||
20 () - (EMPTY)
|
||||
21 () - (EMPTY)
|
||||
22 () - (EMPTY)
|
||||
23 () - (EMPTY)
|
||||
24 () - (EMPTY)
|
||||
25 () - (EMPTY)
|
||||
26 () - (EMPTY)
|
||||
27 () - (EMPTY)
|
||||
28 () - (EMPTY)
|
||||
29 () - (EMPTY)
|
||||
30 () - (EMPTY)
|
||||
31 () - (EMPTY)
|
||||
32 () - (EMPTY)
|
||||
33 () - (EMPTY)
|
||||
34 () - (EMPTY)
|
||||
35 () - (EMPTY)
|
||||
36 () - (EMPTY)
|
||||
37 () - (EMPTY)
|
||||
38 () - (EMPTY)
|
||||
39 () - (EMPTY)
|
||||
40 () - (EMPTY)
|
||||
41 () - (EMPTY)
|
||||
42 () - (EMPTY)
|
||||
43 () - (EMPTY)
|
||||
44 () - (EMPTY)
|
||||
45 () - (EMPTY)
|
||||
46 () - (EMPTY)
|
||||
47 () - (EMPTY)
|
||||
48 () - (EMPTY)
|
||||
49 () - (EMPTY)
|
||||
50 () - (EMPTY)
|
||||
51 () - (EMPTY)
|
||||
52 () - (EMPTY)
|
||||
53 () - (EMPTY)
|
||||
54 () - (EMPTY)
|
||||
55 () - (EMPTY)
|
||||
56 () - (EMPTY)
|
||||
57 () - (EMPTY)
|
||||
58 () - (EMPTY)
|
||||
59 () - (EMPTY)
|
||||
60 () - (EMPTY)
|
||||
61 () - (EMPTY)
|
||||
62 () - (EMPTY)
|
||||
63 () - (EMPTY)
|
||||
64 () - (EMPTY)
|
||||
65 () - (EMPTY)
|
||||
66 () - (EMPTY)
|
||||
67 () - (EMPTY)
|
||||
68 () - (EMPTY)
|
||||
69 () - (EMPTY)
|
||||
70 () - (EMPTY)
|
||||
71 () - (EMPTY)
|
||||
72 () - (EMPTY)
|
||||
73 () - (EMPTY)
|
||||
74 () - (EMPTY)
|
||||
75 () - (EMPTY)
|
||||
76 () - (EMPTY)
|
||||
77 () - (EMPTY)
|
||||
78 () - (EMPTY)
|
||||
79 () - (EMPTY)
|
||||
80 () - (EMPTY)
|
||||
81 () - (EMPTY)
|
||||
82 () - (EMPTY)
|
||||
83 () - (EMPTY)
|
||||
84 () - (EMPTY)
|
||||
85 () - (EMPTY)
|
||||
86 () - (EMPTY)
|
||||
87 () - (EMPTY)
|
||||
88 () - (EMPTY)
|
||||
89 () - (EMPTY)
|
||||
90 () - (EMPTY)
|
||||
91 () - (EMPTY)
|
||||
92 () - (EMPTY)
|
||||
93 () - (EMPTY)
|
||||
94 () - (EMPTY)
|
||||
95 () - (EMPTY)
|
||||
96 () - (EMPTY)
|
||||
97 () - (EMPTY)
|
||||
98 () - (EMPTY)
|
||||
99 (end) - Number 99, as specified in second map file.
|
||||
END DEBUG OUTPUT
|
4
expected/withmaps.dot
Normal file
4
expected/withmaps.dot
Normal file
|
@ -0,0 +1,4 @@
|
|||
digraph gamebook {
|
||||
|
||||
10->99
|
||||
}
|
79
expected/withmaps.html
Normal file
79
expected/withmaps.html
Normal file
|
@ -0,0 +1,79 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title>Example Gamebook With Maps</title>
|
||||
<script type="text/javascript" src="gamebookformatplay.js"></script>
|
||||
<link rel="stylesheet" href="gamebookformat.css"
|
||||
type="text/css" />
|
||||
<script>
|
||||
if (typeof gamebook !== 'undefined') {
|
||||
gamebook.id = 'withmaps';
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="hideintrolink nodisplay"
|
||||
onclick="gamebook.hideIntroSections()">(hide instructions)</div>
|
||||
<div class="gamebook">
|
||||
|
||||
<div class="resumelink nodisplay"
|
||||
onclick="gamebook.loadGame()">Resume saved game.</div>
|
||||
|
||||
<div class="startlink"
|
||||
onclick="gamebook.turnTo(1)">Turn to 1 to begin.</div>
|
||||
<script>
|
||||
if (typeof gamebook !== 'undefined' && gamebook.hasSavedGame()) {
|
||||
var resumeLinks = document.getElementsByClassName('resumelink');
|
||||
Array.prototype.forEach.call(resumeLinks, function(e) {
|
||||
e.classList.remove('nodisplay');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<div class="section" id="section10">
|
||||
<div class="sectionnumber" id="para10">10</div>
|
||||
<div class="sectiontext">
|
||||
This should have number 10, as specified in first map file. The end, at <a class="sectionref enabledlink" data-ref="99"
|
||||
href="#section99">99</a>, should be at 99.
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (typeof gamebook !== 'undefined') {
|
||||
gamebook.addSection(10, document.getElementById('section10'));
|
||||
}
|
||||
</script><div class="section" id="section99">
|
||||
<div class="sectionnumber" id="para99">99</div>
|
||||
<div class="sectiontext">
|
||||
Number 99, as specified in second map file.
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (typeof gamebook !== 'undefined') {
|
||||
gamebook.addSection(99, document.getElementById('section99'));
|
||||
}
|
||||
</script> <div id="counters" class="counters">
|
||||
</div>
|
||||
<div id="counterTemplate" class="counterTemplate">
|
||||
<span class="counterheading"></span>
|
||||
<span class="countercontents"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="collections" class="collections">
|
||||
</div>
|
||||
<div id="collectionTemplate" class="collectionTemplate">
|
||||
<span class="collectionheading"></span>
|
||||
<span class="collectioncontents"></span>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (typeof gamebook !== 'undefined') {
|
||||
gamebook.prepare();
|
||||
}
|
||||
</script>
|
||||
<div class="displayintrolink nodisplay"
|
||||
onclick="gamebook.showIntroSections()">(show instructions)</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
27
expected/withmaps.rtf
Normal file
27
expected/withmaps.rtf
Normal file
|
@ -0,0 +1,27 @@
|
|||
{\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 Example Gamebook With Maps
|
||||
\b0\
|
||||
|
||||
\b Turn to 1 to begin.
|
||||
\b0\
|
||||
\
|
||||
\b \qc 10
|
||||
\b0\
|
||||
\ql This should have number 10, as specified in first map file. The end, at \b 99
|
||||
\b0
|
||||
, should be at 99. \
|
||||
\
|
||||
|
||||
\b \qc 99
|
||||
\b0\
|
||||
\ql Number 99, as specified in second map file. \
|
||||
\
|
||||
|
||||
}
|
151
expected/withmaps.tex
Normal file
151
expected/withmaps.tex
Normal file
|
@ -0,0 +1,151 @@
|
|||
\documentclass[a5paper,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{Example Gamebook With Maps}
|
||||
\author{Pelle Nilsson}
|
||||
\date{}
|
||||
|
||||
\newcounter{sectionnr}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\maketitle
|
||||
|
||||
\clearpage
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\pagestyle{empty}
|
||||
|
||||
|
||||
Turn to 1 to begin.
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\phantomsection
|
||||
\refstepcounter{sectionnr}
|
||||
\label{section10}
|
||||
\subsection*{\begin{center} \textbf{10} \end{center}}
|
||||
|
||||
\noindent
|
||||
This should have number 10, as specified in first map file. The end, at \textbf{\autoref{section99}}, should be at 99.
|
||||
\vspace{1em}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\refstepcounter{sectionnr}
|
||||
\phantomsection
|
||||
\refstepcounter{sectionnr}
|
||||
\label{section99}
|
||||
\subsection*{\begin{center} \textbf{99} \end{center}}
|
||||
|
||||
\noindent
|
||||
Number 99, as specified in second map file.
|
||||
\vspace{1em}
|
||||
\end{document}
|
11
expected/withmaps.txt
Normal file
11
expected/withmaps.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
Example Gamebook With Maps
|
||||
|
||||
|
||||
|
||||
Turn to 1 to begin.
|
||||
10
|
||||
This should have number 10, as specified in first map file. The end, at 99, should be at 99.
|
||||
|
||||
99
|
||||
Number 99, as specified in second map file.
|
||||
|
|
@ -27,13 +27,12 @@
|
|||
|
||||
\maketitle
|
||||
|
||||
\clearpage
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\pagestyle{empty}
|
||||
|
||||
\clearpage
|
||||
|
||||
|
||||
|
||||
Turn to 1 to begin.
|
||||
\phantomsection
|
||||
|
|
|
@ -68,13 +68,15 @@ def format_gamebook(inputfilenames,
|
|||
import_default_map_file,
|
||||
templatedirs,
|
||||
shuffle,
|
||||
includetag):
|
||||
includetag,
|
||||
mapfilenames):
|
||||
output_format = make_output(outputfilename, templatedirs)
|
||||
book = sections.Book(make_bookid(outputfilename), includetag)
|
||||
for inputfilename in inputfilenames:
|
||||
parse_file_to_book(open(inputfilename, 'r'), book)
|
||||
if import_default_map_file:
|
||||
import_default_nr_map(outputfilename, book)
|
||||
import_nr_maps(mapfilenames, book)
|
||||
write_book(book, shuffle, output_format, outputfilename)
|
||||
|
||||
def make_bookid(filename):
|
||||
|
@ -162,7 +164,13 @@ def write_book(book, shuffle, output_format, outputfilename):
|
|||
save_section_mapping(shuffled_sections, outputfilename)
|
||||
|
||||
def import_default_nr_map(outputfilename, book):
|
||||
mapfilename = make_default_map_filename(outputfilename)
|
||||
import_nr_map(make_default_map_filename(outputfilename), book)
|
||||
|
||||
def import_nr_maps(mapfilenames, book):
|
||||
for m in mapfilenames:
|
||||
import_nr_map(m, book)
|
||||
|
||||
def import_nr_map(mapfilename, book):
|
||||
if os.path.exists(mapfilename): #FIXME better check
|
||||
for name,nr in json.load(open(mapfilename)).iteritems():
|
||||
book.force_section_nr(name, nr)
|
||||
|
@ -198,6 +206,8 @@ if __name__ == '__main__':
|
|||
ap.add_argument('-S', '--no-shuffle', action='store_false',
|
||||
dest='shuffle',
|
||||
help='do not shuffle sections')
|
||||
ap.add_argument('-m', '--map-file', metavar='F', dest='mapfiles',
|
||||
action='append', help='number map file')
|
||||
args = ap.parse_args()
|
||||
templatedirs = ['templates',
|
||||
os.path.join(os.path.dirname(sys.argv[0]), 'templates')]
|
||||
|
@ -213,4 +223,5 @@ if __name__ == '__main__':
|
|||
args.import_default_map_file,
|
||||
templatedirs,
|
||||
args.shuffle,
|
||||
args.includetag)
|
||||
args.includetag,
|
||||
args.mapfiles or [])
|
||||
|
|
19
readme.org
19
readme.org
|
@ -17,7 +17,7 @@ gamebook on paper or a screen (or for debugging it).
|
|||
: -t D, --template D add custom template dir
|
||||
: -o D, --option D add template override options dir
|
||||
: -S, --no-shuffle do not shuffle sections
|
||||
|
||||
: -m F, --map-file F number map file
|
||||
** Supported Output Formats
|
||||
|
||||
| Name | Extension | Description |
|
||||
|
@ -49,6 +49,23 @@ produce LaTeX files in Letter size rather than the default A5 size.
|
|||
| letter | tex | Letter paper size documents (PDF). |
|
||||
| static | html | Remove script link from HTML output. |
|
||||
|
||||
** Number Map Files
|
||||
Whenever formatgamebook.py runs it looks for a file with the same
|
||||
name as the output file, but with a .map suffix (eg output.map if
|
||||
the output file is output.html). That file is expected to contain
|
||||
a JSON object mapping section names to numbers, and all sections
|
||||
included in that file are given those numbers rather than being
|
||||
randomly shuffled like other paragraphs. You can also add more
|
||||
map files using the --map-file (or -m) option on the command-line.
|
||||
The -M flag disables the default map file. Unless it has been
|
||||
disabled a default map file is also written, containing all
|
||||
the sections output. This way if you generate the same output
|
||||
file (or files with the same name but different types) they
|
||||
always get the same section numbers assigned. The generated
|
||||
map file can also be used from other scripts to easily read
|
||||
what numbers were assigned to sections, if you need to
|
||||
use the number of some section for something outside of
|
||||
the gamebook itself.
|
||||
** Gamebook Format
|
||||
|
||||
The input file expected by the formatgamebook.py script must be in a
|
||||
|
|
Loading…
Reference in a new issue