1
0
Fork 0
mirror of https://github.com/Oreolek/gamebookformat.git synced 2024-06-17 07:30:43 +03:00

Export option for HTML to make Twine 2 story files.

This commit is contained in:
Pelle Nilsson 2014-12-22 14:52:43 +01:00
parent 0cecd4cf63
commit 2176aef22f
39 changed files with 229 additions and 8 deletions

View file

@ -0,0 +1,20 @@
title = Gamebookformat Twine 2 Export Example
author = Pelle Nilsson
* 1 start
This is just an experiment exporting to the markup used in [b]Twine 2[/b] (see http://twinery.org).
A known problem is that new-lines are significant in Twine, while they are happily ignored by
gamebookformat. Have to add some hack to strip unintended whitespace from files when exporting
to Twine 2. Also the book has to start at section 1 because currently the startnode given in
the generated file is hardcoded to 1.
Many things like item management and counters are not yet implemented, but from a quick look
int the Twine 2 documentation it should be possible to add all that later.
Creating a Twine 2 document is done using html output format with the -o twine2 option.
Use the "Import From File" link in the Twine 2 web GUI to import the generated HTML file.
From here you can go to [[other]] or [[ending][the end]].
* other
This is another section, just to try references. You can go on to the end at [[ending]].
* ending
It ends here.

View file

@ -0,0 +1 @@
--option twine2

0
expected/twinetest.check Normal file
View file

5
expected/twinetest.dot Normal file
View file

@ -0,0 +1,5 @@
digraph gamebook {
Twine 21->3
1->2
3->2
}

View file

@ -0,0 +1,20 @@
title = Gamebookformat Twine 2 Export Example
author = Pelle Nilsson
* 1 start
This is just an experiment exporting to the markup used in [b]Twine 2[/b] (see http://twinery.org).
A known problem is that new-lines are significant in Twine, while they are happily ignored by
gamebookformat. Have to add some hack to strip unintended whitespace from files when exporting
to Twine 2. Also the book has to start at section 1 because currently the startnode given in
the generated file is hardcoded to 1.
Many things like item management and counters are not yet implemented, but from a quick look
int the Twine 2 documentation it should be possible to add all that later.
Creating a Twine 2 document is done using html output format with the -o twine2 option.
Use the "Import From File" link in the Twine 2 web GUI to import the generated HTML file.
From here you can go to [[other]] or [[ending][the end]].
* other
This is another section, just to try references. You can go on to the end at [[ending]].
* ending
It ends here.

View file

@ -0,0 +1 @@
--option twine2

9
expected/twinetest.html Normal file
View file

@ -0,0 +1,9 @@
<tw-storydata name="Gamebookformat Twine 2 Export Example" startnode="1" creator="Twine" creator-version="2.0" format="Harlowe" options="">
<style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style><script role="script" id="twine-user-script" type="text/twine-javascript"></script>
<tw-passagedata pid="1" name="1" tags="" position="10,10"> This is just an experiment exporting to the markup used in <b>Twine 2</b> (see http://twinery.org). A known problem is that new-lines are significant in Twine, while they are happily ignored by gamebookformat. Have to add some hack to strip unintended whitespace from files when exporting to Twine 2. Also the book has to start at section 1 because currently the startnode given in the generated file is hardcoded to 1. Many things like item management and counters are not yet implemented, but from a quick look int the Twine 2 documentation it should be possible to add all that later. Creating a Twine 2 document is done using html output format with the -o twine2 option. Use the "Import From File" link in the Twine 2 web GUI to import the generated HTML file. From here you can go to [[3]]
or [[the end->2]]
. </tw-passagedata>
<tw-passagedata pid="2" name="2" tags="" position="20,20"> It ends here.</tw-passagedata>
<tw-passagedata pid="3" name="3" tags="" position="30,30"> This is another section, just to try references. You can go on to the end at [[2]]
. </tw-passagedata>
</tw-storydata>

18
expected/twinetest.json Normal file
View file

@ -0,0 +1,18 @@
{
"title" : "Gamebookformat Twine 2 Export Example",
"nr_sections" : "3",
"sections" : {"IGNORE-debug-json-padding-IGNORE" : "", "start" : {
"nr" : 1,
"text" : ["" ," This is just an experiment exporting to the markup used in ", "Twine 2"
," (see http://twinery.org). A known problem is that new-lines are significant in Twine, while they are happily ignored by gamebookformat. Have to add some hack to strip unintended whitespace from files when exporting to Twine 2. Also the book has to start at section 1 because currently the startnode given in the generated file is hardcoded to 1. Many things like item management and counters are not yet implemented, but from a quick look int the Twine 2 documentation it should be possible to add all that later. Creating a Twine 2 document is done using html output format with the -o twine2 option. Use the \"Import From File\" link in the Twine 2 web GUI to import the generated HTML file. From here you can go to ",{"reference" : "3"}," or ",{"reference" : "2", "name" : "the end"},". "]
}
, "ending" : {
"nr" : 2,
"text" : ["" ," It ends here."]
}
, "other" : {
"nr" : 3,
"text" : ["" ," This is another section, just to try references. You can go on to the end at ",{"reference" : "2"},". "]
}
}}

36
expected/twinetest.rtf Normal file
View file

@ -0,0 +1,36 @@
{\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 Gamebookformat Twine 2 Export Example
\b0\
\b Turn to 1 to begin.
\b0\
\
\b \qc {\*\bkmkstart s1}1{\*\bkmkend s1}
\b0\
\ql This is just an experiment exporting to the markup used in Twine 2 (see http://twinery.org). A known problem is that new-lines are significant in Twine, while they are happily ignored by gamebookformat. Have to add some hack to strip unintended whitespace from files when exporting to Twine 2. Also the book has to start at section 1 because currently the startnode given in the generated file is hardcoded to 1. Many things like item management and counters are not yet implemented, but from a quick look int the Twine 2 documentation it should be possible to add all that later. Creating a Twine 2 document is done using html output format with the -o twine2 option. Use the "Import From File" link in the Twine 2 web GUI to import the generated HTML file. From here you can go to \b {\field{\*\fldinst REF s3 \\h }{\fldrslt 3}}
\b0
or \b {\field{\*\fldinst REF s2 \\h }{\fldrslt the end}}
\b0
. \
\
\b \qc {\*\bkmkstart s2}2{\*\bkmkend s2}
\b0\
\ql It ends here. \
\
\b \qc {\*\bkmkstart s3}3{\*\bkmkend s3}
\b0\
\ql This is another section, just to try references. You can go on to the end at \b {\field{\*\fldinst REF s2 \\h }{\fldrslt 2}}
\b0
. \
\
}

62
expected/twinetest.tex Normal file
View file

@ -0,0 +1,62 @@
\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{Gamebookformat Twine 2 Export Example}
\author{Pelle Nilsson}
\date{}
\newcounter{sectionnr}
\begin{document}
\maketitle
\clearpage
\thispagestyle{empty}
\pagestyle{empty}
Turn to 1 to begin.
\phantomsection
\refstepcounter{sectionnr}
\label{section1}
\subsection*{\begin{center} \textbf{1} \end{center}}
\noindent
This is just an experiment exporting to the markup used in Twine 2 (see http://twinery.org). A known problem is that new-lines are significant in Twine, while they are happily ignored by gamebookformat. Have to add some hack to strip unintended whitespace from files when exporting to Twine 2. Also the book has to start at section 1 because currently the startnode given in the generated file is hardcoded to 1. Many things like item management and counters are not yet implemented, but from a quick look int the Twine 2 documentation it should be possible to add all that later. Creating a Twine 2 document is done using html output format with the -o twine2 option. Use the "Import From File" link in the Twine 2 web GUI to import the generated HTML file. From here you can go to \textbf{\autoref{section3}} or the end (\textbf{\autoref{section2}})
.
\vspace{1em}
\phantomsection
\refstepcounter{sectionnr}
\label{section2}
\subsection*{\begin{center} \textbf{2} \end{center}}
\noindent
It ends here.
\vspace{1em}
\phantomsection
\refstepcounter{sectionnr}
\label{section3}
\subsection*{\begin{center} \textbf{3} \end{center}}
\noindent
This is another section, just to try references. You can go on to the end at \textbf{\autoref{section2}}.
\vspace{1em}
\end{document}

13
expected/twinetest.txt Normal file
View file

@ -0,0 +1,13 @@
Gamebookformat Twine 2 Export Example
Turn to 1 to begin.
1
This is just an experiment exporting to the markup used in Twine 2 (see http://twinery.org). A known problem is that new-lines are significant in Twine, while they are happily ignored by gamebookformat. Have to add some hack to strip unintended whitespace from files when exporting to Twine 2. Also the book has to start at section 1 because currently the startnode given in the generated file is hardcoded to 1. Many things like item management and counters are not yet implemented, but from a quick look int the Twine 2 documentation it should be possible to add all that later. Creating a Twine 2 document is done using html output format with the -o twine2 option. Use the "Import From File" link in the Twine 2 web GUI to import the generated HTML file. From here you can go to 3 or the end (2).
2
It ends here.
3
This is another section, just to try references. You can go on to the end at 2.

View file

@ -0,0 +1 @@
examples/twinetest.json: ending (death?) section found: ending

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

@ -0,0 +1 @@
<tw-storydata name="%(title)s" startnode="1" creator="Twine" creator-version="2.0" format="Harlowe" options="">

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

@ -0,0 +1 @@
</tw-storydata>

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

@ -0,0 +1 @@
[[%(name)s->%(nr)d]]

View file

@ -0,0 +1 @@
<tw-passagedata pid="%(nr)d" name="%(nr)d" tags="" position="%(nr)d0,%(nr)d0">%(text)s</tw-passagedata>

View file

@ -0,0 +1 @@
[[%(nr)d]]

View file

@ -0,0 +1 @@
<style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style><script role="script" id="twine-user-script" type="text/twine-javascript"></script>

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

@ -0,0 +1 @@
<b>%(inner)s</b>

View file

View file

@ -46,14 +46,15 @@ You can use *-o list* to generate a text file listing all sections and
their numbers, or *-o list -i todo* to only list sections tagged as
todo (or substitute whatever other tag(s) you are interested in).
| Name | Formats | Description |
|----------+---------+--------------------------------------|
| a4 | tex | A4 paper size documents (PDF). |
| a5 | tex | A5 paper size documents (PDF). |
| htmlbook | html | Generate [[https://github.com/oreillymedia/HTMLBook][HTMLBook]] compatible HTML. |
| letter | tex | Letter paper size documents (PDF). |
| list | txt | Only generate list of sections. |
| static | html | Remove script link from HTML output. |
| Name | Formats | Description |
|----------+---------+-------------------------------------------------|
| a4 | tex | A4 paper size documents (PDF). |
| a5 | tex | A5 paper size documents (PDF). |
| htmlbook | html | Generate [[https://github.com/oreillymedia/HTMLBook][HTMLBook]] compatible HTML. |
| letter | tex | Letter paper size documents (PDF). |
| list | txt | Only generate list of sections. |
| static | html | Remove script link from HTML output. |
| twine2 | html | Generate story that can be imported to [[http://twinery.org/2/#stories][Twine 2]] |
** Styles and Scripts
Generated *html* files use the included *gamebookformat.css* for
@ -109,6 +110,15 @@ to EPUB, so that should be a start. You probably want to
do some experimentation to find a way that creates results
you like.
** Twine 2 Export
There is experimental support to generate output for [[http://twinery.org/2/#stories][Twine 2]]. Use
output format *.html* with option *-o twine2*. Use the *Import From
File* link in the Twine 2 user interface to import the generated html
file. If everything works as it should you can then edit and play or
debug the story in Twine 2. Currently most formatting will
be ignored and there is no support for handling collections or
counters (yet?). Also there is a known cosmetic issue with newlines in
files causing ugly line-breaks and list-items.
** Check Gamebook
The included *checkgamebook.py* script can be used to run tests
on a book and warn about things that do not look right.