diff --git a/Makefile b/Makefile
index 2dadcf0..897ea73 100644
--- a/Makefile
+++ b/Makefile
@@ -3,10 +3,12 @@ examples=$(wildcard examples/*.gamebook)
all: rtf pdf html debug png txt
rtf: $(examples:.gamebook=.rtf)
+tex: $(examples:.gamebook=.tex)
pdf: $(examples:.gamebook=.pdf)
html: $(examples:.gamebook=.html) examples/gamebookformatplay.js \
examples/gamebookformat.css
debug: $(examples:.gamebook=.debug)
+dot: $(examples:.gamebook=.dot)
png: $(examples:.gamebook=.png)
txt: $(examples:.gamebook=.txt)
@@ -22,22 +24,22 @@ examples/gamebookformat.css:
cp gamebookformat.css $@
%.rtf: %.gamebook *.py templates/rtf/*.rtf
- ./formatgamebook.py --no-shuffle $< $@
+ python ./buildexamplegamebook.py $< $@
%.html: %.gamebook *.py templates/html/*.html
- ./formatgamebook.py --no-shuffle $< $@
+ python ./buildexamplegamebook.py $< $@
%.tex: %.gamebook *.py templates/tex/*.tex
- ./formatgamebook.py --no-shuffle $< $@
+ python ./buildexamplegamebook.py $< $@
%.dot: %.gamebook *.py templates/dot/*.dot
- ./formatgamebook.py --no-shuffle $< $@
+ python ./buildexamplegamebook.py $< $@
%.debug: %.gamebook *.py templates/debug/*.debug
- ./formatgamebook.py --no-shuffle $< $@
+ python ./buildexamplegamebook.py $< $@
%.txt: %.gamebook *.py templates/txt/*.txt
- ./formatgamebook.py --no-shuffle $< $@
+ python ./buildexamplegamebook.py $< $@
%.pdf: %.tex
cd $(dir $<) && pdflatex $(notdir $<) && pdflatex $(notdir $<)
@@ -52,7 +54,7 @@ expected: all
cp examples/*.{rtf,tex,html,debug,txt,dot,map} \
expected
-checkexpected: clean all
+checkexpected: clean rtf tex html debug dot txt
diff -r -x "*.aux" -x "*.gamebook" -x "*.log" -x "*.out" -x "*.png" \
-x "*.pdf" -x .gitignore -x "*.js" -x "*.css" \
-q examples expected
diff --git a/buildexamplegamebook.py b/buildexamplegamebook.py
new file mode 100755
index 0000000..70d3f8c
--- /dev/null
+++ b/buildexamplegamebook.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+
+import os
+import sys
+
+DEFAULT_OPTIONS = '--no-shuffle'
+
+if __name__ == '__main__':
+ if len(sys.argv) != 3:
+ print >> sys.stderr, "usage: %s infile outfile" % sys.argv[0]
+ sys.exit(1)
+ infile = sys.argv[1]
+ outfile = sys.argv[2]
+ print infile, outfile
+ optionsfilename = infile + '.options'
+ options = DEFAULT_OPTIONS
+ if os.path.exists(optionsfilename):
+ optionsfile = open(optionsfilename)
+ options += ' ' + ' '.join(optionsfile.readlines())
+ optionsfile.close()
+ os.system("python ./formatgamebook.py %s %s %s" % (
+ options, infile, outfile))
diff --git a/examples/withdemo.gamebook b/examples/withdemo.gamebook
new file mode 100644
index 0000000..3d95723
--- /dev/null
+++ b/examples/withdemo.gamebook
@@ -0,0 +1,36 @@
+missingto = demoinfo
+
+* 1 start :demo:
+This gamebook contains a few sections tagged as demo, that will
+be included when building the example
+(see withdemo.gamebook.options file). There are also some sections
+without the demo tag that will be ignored.
+Go on to [[demo1]] or [[demo2]] or [[notindemo1]].
+
+* notindemo1
+This section is not included in the demo. Turn to [[notindemo2]].
+
+* demo1 :demo:
+This is the first demo section (not counting the start section).
+You can go on to the end at [[theend]].
+
+* notindemo2
+This section is not included in the demo. You can go on to
+[[demo2]] or [[theend]] or [[altend]].
+
+* demo2 :demo:
+This is the second demo section.
+You can go on to the end at [[theend]] or alternative (not in demo)
+end at [[altend]].
+
+* theend :demo:
+This is the end. It is also included in the demo.
+
+* demoinfo :demo:
+This is where references to non-demo sections will lead you.
+It is configured at the top of the gamebook file.
+Remember to tag this section correctly to be included.
+Go on to [[demo2]].
+
+* altend
+Alternative end. Not included in the demo.
diff --git a/examples/withdemo.gamebook.options b/examples/withdemo.gamebook.options
new file mode 100644
index 0000000..bedbae2
--- /dev/null
+++ b/examples/withdemo.gamebook.options
@@ -0,0 +1 @@
+--include demo
\ No newline at end of file
diff --git a/examples/withoutdemo.gamebook b/examples/withoutdemo.gamebook
new file mode 100644
index 0000000..094993b
--- /dev/null
+++ b/examples/withoutdemo.gamebook
@@ -0,0 +1,39 @@
+missingto = demoinfo
+
+* 1 start :demo:
+This gamebook contains a few sections tagged as demo, that will
+be included when building the example as withdemo.gamebook
+(see withdemo.gamebook.options file). There are also some sections
+without the demo tag that will be ignored. This version is built
+without options and includes all sections.
+Go on to [[demo1]] or [[demo2]] or [[notindemo1]].
+
+* notindemo1
+This section is not included in the demo. Turn to [[notindemo2]].
+
+* demo1 :demo:
+This is the first demo section (not counting the start section).
+You can go on to the end at [[theend]].
+
+* notindemo2
+This section is not included in the demo. You can go on to
+[[demo2]] or [[theend]] or [[altend]].
+
+* demo2 :demo:
+This is the second demo section.
+You can go on to the end at [[theend]] or alternative (not in demo)
+end at [[altend]].
+
+* theend :demo:
+This is the end. It is also included in the demo.
+
+* demoinfo :demo:
+This is where references to non-demo sections will lead you.
+It is configured at the top of the gamebook file.
+Remember to tag this section correctly to be included.
+Nothing should lead to this section when building without
+the demo tag option.
+Go on to [[demo2]].
+
+* altend
+Alternative end. Not included in the demo.
diff --git a/expected/withdemo.debug b/expected/withdemo.debug
new file mode 100644
index 0000000..189753b
--- /dev/null
+++ b/expected/withdemo.debug
@@ -0,0 +1,12 @@
+BEGIN DEBUG OUTPUT
+Book title: Gamebook
+Number of sections: 5
+
+
+Turn to 1 to begin.
+1 (start) - This gamebook contains a few sections tagged as demo, that will be included when building the example (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. Go on to 5 or 4 or 2.
+2 (demoinfo) - This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Go on to 4.
+3 (theend) - This is the end. It is also included in the demo.
+4 (demo2) - This is the second demo section. You can go on to the end at 3 or alternative (not in demo) end at 2.
+5 (demo1) - This is the first demo section (not counting the start section). You can go on to the end at 3.
+END DEBUG OUTPUT
diff --git a/expected/withdemo.dot b/expected/withdemo.dot
new file mode 100644
index 0000000..865809e
--- /dev/null
+++ b/expected/withdemo.dot
@@ -0,0 +1,13 @@
+digraph gamebook {
+
+ 1->5
+
+1->2
+
+1->4
+2->4
+4->2
+
+4->3
+5->3
+}
diff --git a/expected/withdemo.html b/expected/withdemo.html
new file mode 100644
index 0000000..39d508e
--- /dev/null
+++ b/expected/withdemo.html
@@ -0,0 +1,99 @@
+
+
+
+
+
+ Gamebook
+
+
+
+
+
+
(hide instructions)
+
+
+
Resume saved game.
+
+
Turn to 1 to begin.
+
+
+
1
+
+ This gamebook contains a few sections tagged as demo, that will be included when building the example (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. Go on to 5 or 4 or 2.
+
+
+
+
2
+
+ This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Go on to 4.
+
+
+
+
3
+
+ This is the end. It is also included in the demo.
+
+
+
+
4
+
+ This is the second demo section. You can go on to the end at 3 or alternative (not in demo) end at 2.
+
+
+
+
5
+
+ This is the first demo section (not counting the start section). You can go on to the end at 3.
+
+
+
+
+
+
+
+
+
+
+
(show instructions)
+
+
+
diff --git a/expected/withdemo.rtf b/expected/withdemo.rtf
new file mode 100644
index 0000000..1038ef5
--- /dev/null
+++ b/expected/withdemo.rtf
@@ -0,0 +1,54 @@
+{\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 Gamebook
+\b0\
+
+\b Turn to 1 to begin.
+\b0\
+\
+\b \qc 1
+\b0\
+\ql This gamebook contains a few sections tagged as demo, that will be included when building the example (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. Go on to \b 5
+\b0
+ or \b 4
+\b0
+ or \b 2
+\b0
+. \
+\
+
+\b \qc 2
+\b0\
+\ql This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Go on to \b 4
+\b0
+. \
+\
+
+\b \qc 3
+\b0\
+\ql This is the end. It is also included in the demo. \
+\
+
+\b \qc 4
+\b0\
+\ql This is the second demo section. You can go on to the end at \b 3
+\b0
+ or alternative (not in demo) end at \b 2
+\b0
+. \
+\
+
+\b \qc 5
+\b0\
+\ql This is the first demo section (not counting the start section). You can go on to the end at \b 3
+\b0
+. \
+\
+
+}
diff --git a/expected/withdemo.tex b/expected/withdemo.tex
new file mode 100644
index 0000000..22ade67
--- /dev/null
+++ b/expected/withdemo.tex
@@ -0,0 +1,79 @@
+\documentclass[a5,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{Gamebook}
+\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
+ This gamebook contains a few sections tagged as demo, that will be included when building the example (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. Go on to \textbf{\autoref{section5}} or \textbf{\autoref{section4}} or \textbf{\autoref{section2}}.
+\vspace{1em}
+\phantomsection
+\refstepcounter{sectionnr}
+\label{section2}
+\subsection*{\begin{center} \textbf{2} \end{center}}
+
+ \noindent
+ This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Go on to \textbf{\autoref{section4}}.
+\vspace{1em}
+\phantomsection
+\refstepcounter{sectionnr}
+\label{section3}
+\subsection*{\begin{center} \textbf{3} \end{center}}
+
+ \noindent
+ This is the end. It is also included in the demo.
+\vspace{1em}
+\phantomsection
+\refstepcounter{sectionnr}
+\label{section4}
+\subsection*{\begin{center} \textbf{4} \end{center}}
+
+ \noindent
+ This is the second demo section. You can go on to the end at \textbf{\autoref{section3}} or alternative (not in demo) end at \textbf{\autoref{section2}}.
+\vspace{1em}
+\phantomsection
+\refstepcounter{sectionnr}
+\label{section5}
+\subsection*{\begin{center} \textbf{5} \end{center}}
+
+ \noindent
+ This is the first demo section (not counting the start section). You can go on to the end at \textbf{\autoref{section3}}.
+\vspace{1em}
+\end{document}
diff --git a/expected/withdemo.txt b/expected/withdemo.txt
new file mode 100644
index 0000000..8c64f26
--- /dev/null
+++ b/expected/withdemo.txt
@@ -0,0 +1,20 @@
+ Gamebook
+
+
+
+Turn to 1 to begin.
+1
+ This gamebook contains a few sections tagged as demo, that will be included when building the example (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. Go on to 5 or 4 or 2.
+
+2
+ This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Go on to 4.
+
+3
+ This is the end. It is also included in the demo.
+
+4
+ This is the second demo section. You can go on to the end at 3 or alternative (not in demo) end at 2.
+
+5
+ This is the first demo section (not counting the start section). You can go on to the end at 3.
+
diff --git a/expected/withoutdemo.debug b/expected/withoutdemo.debug
new file mode 100644
index 0000000..4d36fe7
--- /dev/null
+++ b/expected/withoutdemo.debug
@@ -0,0 +1,15 @@
+BEGIN DEBUG OUTPUT
+Book title: Gamebook
+Number of sections: 8
+
+
+Turn to 1 to begin.
+1 (start) - This gamebook contains a few sections tagged as demo, that will be included when building the example as withdemo.gamebook (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. This version is built without options and includes all sections. Go on to 7 or 5 or 8.
+2 (altend) - Alternative end. Not included in the demo.
+3 (demoinfo) - This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Nothing should lead to this section when building without the demo tag option. Go on to 5.
+4 (theend) - This is the end. It is also included in the demo.
+5 (demo2) - This is the second demo section. You can go on to the end at 4 or alternative (not in demo) end at 2.
+6 (notindemo2) - This section is not included in the demo. You can go on to 5 or 4 or 2.
+7 (demo1) - This is the first demo section (not counting the start section). You can go on to the end at 4.
+8 (notindemo1) - This section is not included in the demo. Turn to 6.
+END DEBUG OUTPUT
diff --git a/expected/withoutdemo.dot b/expected/withoutdemo.dot
new file mode 100644
index 0000000..c6aa4a3
--- /dev/null
+++ b/expected/withoutdemo.dot
@@ -0,0 +1,19 @@
+digraph gamebook {
+
+ 1->8
+
+1->5
+
+1->7
+3->5
+5->2
+
+5->4
+6->4
+
+6->5
+
+6->2
+7->4
+8->6
+}
diff --git a/expected/withoutdemo.html b/expected/withoutdemo.html
new file mode 100644
index 0000000..5714c53
--- /dev/null
+++ b/expected/withoutdemo.html
@@ -0,0 +1,129 @@
+
+
+
+
+
+ Gamebook
+
+
+
+
+
+
(hide instructions)
+
+
+
Resume saved game.
+
+
Turn to 1 to begin.
+
+
+
1
+
+ This gamebook contains a few sections tagged as demo, that will be included when building the example as withdemo.gamebook (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. This version is built without options and includes all sections. Go on to 7 or 5 or 8.
+
+
+
+
2
+
+ Alternative end. Not included in the demo.
+
+
+
+
3
+
+ This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Nothing should lead to this section when building without the demo tag option. Go on to 5.
+
+
+
+
4
+
+ This is the end. It is also included in the demo.
+
+
+
+
5
+
+ This is the second demo section. You can go on to the end at 4 or alternative (not in demo) end at 2.
+
+
+
+
6
+
+ This section is not included in the demo. You can go on to 5 or 4 or 2.
+
+
+
+
7
+
+ This is the first demo section (not counting the start section). You can go on to the end at 4.
+
+
+
+
8
+
+ This section is not included in the demo. Turn to 6.
+
+
+
+
+
+
+
+
+
+
+
(show instructions)
+
+
+
diff --git a/expected/withoutdemo.rtf b/expected/withoutdemo.rtf
new file mode 100644
index 0000000..2a8e251
--- /dev/null
+++ b/expected/withoutdemo.rtf
@@ -0,0 +1,77 @@
+{\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 Gamebook
+\b0\
+
+\b Turn to 1 to begin.
+\b0\
+\
+\b \qc 1
+\b0\
+\ql This gamebook contains a few sections tagged as demo, that will be included when building the example as withdemo.gamebook (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. This version is built without options and includes all sections. Go on to \b 7
+\b0
+ or \b 5
+\b0
+ or \b 8
+\b0
+. \
+\
+
+\b \qc 2
+\b0\
+\ql Alternative end. Not included in the demo. \
+\
+
+\b \qc 3
+\b0\
+\ql This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Nothing should lead to this section when building without the demo tag option. Go on to \b 5
+\b0
+. \
+\
+
+\b \qc 4
+\b0\
+\ql This is the end. It is also included in the demo. \
+\
+
+\b \qc 5
+\b0\
+\ql This is the second demo section. You can go on to the end at \b 4
+\b0
+ or alternative (not in demo) end at \b 2
+\b0
+. \
+\
+
+\b \qc 6
+\b0\
+\ql This section is not included in the demo. You can go on to \b 5
+\b0
+ or \b 4
+\b0
+ or \b 2
+\b0
+. \
+\
+
+\b \qc 7
+\b0\
+\ql This is the first demo section (not counting the start section). You can go on to the end at \b 4
+\b0
+. \
+\
+
+\b \qc 8
+\b0\
+\ql This section is not included in the demo. Turn to \b 6
+\b0
+. \
+\
+
+}
diff --git a/expected/withoutdemo.tex b/expected/withoutdemo.tex
new file mode 100644
index 0000000..30391f5
--- /dev/null
+++ b/expected/withoutdemo.tex
@@ -0,0 +1,103 @@
+\documentclass[a5,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{Gamebook}
+\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
+ This gamebook contains a few sections tagged as demo, that will be included when building the example as withdemo.gamebook (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. This version is built without options and includes all sections. Go on to \textbf{\autoref{section7}} or \textbf{\autoref{section5}} or \textbf{\autoref{section8}}.
+\vspace{1em}
+\phantomsection
+\refstepcounter{sectionnr}
+\label{section2}
+\subsection*{\begin{center} \textbf{2} \end{center}}
+
+ \noindent
+ Alternative end. Not included in the demo.
+\vspace{1em}
+\phantomsection
+\refstepcounter{sectionnr}
+\label{section3}
+\subsection*{\begin{center} \textbf{3} \end{center}}
+
+ \noindent
+ This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Nothing should lead to this section when building without the demo tag option. Go on to \textbf{\autoref{section5}}.
+\vspace{1em}
+\phantomsection
+\refstepcounter{sectionnr}
+\label{section4}
+\subsection*{\begin{center} \textbf{4} \end{center}}
+
+ \noindent
+ This is the end. It is also included in the demo.
+\vspace{1em}
+\phantomsection
+\refstepcounter{sectionnr}
+\label{section5}
+\subsection*{\begin{center} \textbf{5} \end{center}}
+
+ \noindent
+ This is the second demo section. You can go on to the end at \textbf{\autoref{section4}} or alternative (not in demo) end at \textbf{\autoref{section2}}.
+\vspace{1em}
+\phantomsection
+\refstepcounter{sectionnr}
+\label{section6}
+\subsection*{\begin{center} \textbf{6} \end{center}}
+
+ \noindent
+ This section is not included in the demo. You can go on to \textbf{\autoref{section5}} or \textbf{\autoref{section4}} or \textbf{\autoref{section2}}.
+\vspace{1em}
+\phantomsection
+\refstepcounter{sectionnr}
+\label{section7}
+\subsection*{\begin{center} \textbf{7} \end{center}}
+
+ \noindent
+ This is the first demo section (not counting the start section). You can go on to the end at \textbf{\autoref{section4}}.
+\vspace{1em}
+\phantomsection
+\refstepcounter{sectionnr}
+\label{section8}
+\subsection*{\begin{center} \textbf{8} \end{center}}
+
+ \noindent
+ This section is not included in the demo. Turn to \textbf{\autoref{section6}}.
+\vspace{1em}
+\end{document}
diff --git a/expected/withoutdemo.txt b/expected/withoutdemo.txt
new file mode 100644
index 0000000..cc1fc07
--- /dev/null
+++ b/expected/withoutdemo.txt
@@ -0,0 +1,29 @@
+ Gamebook
+
+
+
+Turn to 1 to begin.
+1
+ This gamebook contains a few sections tagged as demo, that will be included when building the example as withdemo.gamebook (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. This version is built without options and includes all sections. Go on to 7 or 5 or 8.
+
+2
+ Alternative end. Not included in the demo.
+
+3
+ This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Nothing should lead to this section when building without the demo tag option. Go on to 5.
+
+4
+ This is the end. It is also included in the demo.
+
+5
+ This is the second demo section. You can go on to the end at 4 or alternative (not in demo) end at 2.
+
+6
+ This section is not included in the demo. You can go on to 5 or 4 or 2.
+
+7
+ This is the first demo section (not counting the start section). You can go on to the end at 4.
+
+8
+ This section is not included in the demo. Turn to 6.
+
diff --git a/sections.py b/sections.py
index 610cfbe..616c35f 100644
--- a/sections.py
+++ b/sections.py
@@ -43,7 +43,8 @@ class IntroSection (Section):
repr(self.tags))
class ShuffledSections:
- def __init__(self, as_list, from_nr, from_name, nr_sections):
+ def __init__(self, as_list, from_nr, from_name, nr_sections,
+ skipped_names, missingto):
self.as_list = as_list
self.from_nr = from_nr
self.from_name = from_name
@@ -52,9 +53,11 @@ class ShuffledSections:
self.name_to_nr[n] = from_name[n].nr
for nr in nr_sections:
self.name_to_nr[nr_sections[nr]] = nr
+ for name in skipped_names:
+ self.name_to_nr[name] = self.name_to_nr[missingto]
STR_BOOK_CONFIG = set(['id', 'title', 'author', 'starttext', 'hideintrotext',
- 'showintrotext', 'resumetext'])
+ 'showintrotext', 'resumetext', 'missingto'])
INT_BOOK_CONFIG = set(['max'])
class Book:
@@ -65,6 +68,7 @@ class Book:
self.nr_sections = {}
self.codewords = set()
self.includetag = includetag
+ self.skipped_names = set()
self.config = {'max' : 0,
'title' : 'Gamebook',
'author' : '',
@@ -72,6 +76,7 @@ class Book:
'hideintrotext' : '(hide instructions)',
'showintrotext' : '(show instructions)',
'resumetext' : 'Resume saved game.',
+ 'missingto' : None,
'id' : bookid}
def configure(self, name, value):
@@ -84,6 +89,7 @@ class Book:
def add(self, section):
if self.includetag and not section.hastag(self.includetag):
+ self.skipped_names.add(section.name)
return
if section.name in self.from_name:
raise Exception('Duplicate section names (%s) not allowed.' %
@@ -132,4 +138,5 @@ class Book:
if section:
shuffled_from_name[section.name] = section
return ShuffledSections(as_list, from_nr, shuffled_from_name,
- self.nr_sections)
+ self.nr_sections, self.skipped_names,
+ self.config['missingto'])
diff --git a/todo.org b/todo.org
index d8c3535..4d04982 100644
--- a/todo.org
+++ b/todo.org
@@ -1,4 +1,4 @@
-* TODO [44/72] [61%]
+* TODO [45/72] [62%]
- [X] Debug output
- [X] DOT output
- [X] LaTeX output
@@ -49,7 +49,7 @@
- [X] Unit tests (finally...)
- [X] Save game (ie player) state
- [X] Load game (ie player) state
-- [ ] Flag to select what tag(s) to include (eg for demo/preview/short...)
+- [X] Flag to select what tag(s) to include (eg for demo/preview/short...)
Allow sections with same name as long as only one is included.
Add book config for what section to use for references to excluded sections
(eg links to outside of demo version can lead to section explaining that)