1
0
Fork 0
mirror of https://github.com/Oreolek/gamebookformat.git synced 2024-06-26 03:41:04 +03:00

Added simple HTML output support.

This commit is contained in:
Pelle Nilsson 2013-05-29 00:01:17 +02:00
parent f01eb0a3f3
commit bdc101a6db
10 changed files with 46 additions and 7 deletions

3
.gitignore vendored
View file

@ -9,4 +9,5 @@ test.dot
*.pdf
test.rtf
*.png
*.out
*.out
test.html

View file

@ -28,6 +28,8 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
import os
import os.path
import sys
import json
@ -37,6 +39,7 @@ from output import OutputFormat
from latex import LatexFormat
from rtf import RtfFormat
from dot import DotFormat
from html import HtmlFormat
from debug import DebugFormat
USAGE = "usage: %prog [options] inputfile(s)... outputfile"
@ -44,6 +47,7 @@ USAGE = "usage: %prog [options] inputfile(s)... outputfile"
OUTPUT_FORMATS = [LatexFormat(),
RtfFormat(),
DotFormat(),
HtmlFormat(),
DebugFormat()]
def make_supported_formats_list_string():

6
html.py Normal file
View file

@ -0,0 +1,6 @@
from output import OutputFormat
class HtmlFormat (OutputFormat):
def __init__(self):
super(HtmlFormat, self).__init__('html',
'HTML+JS playable in browser')

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Gamebook Title Here</title>
<script>
// inline js to make it easier to distribute book?
</script>
</head>
<body>
<!-- TODO definitely need to add content here, but mostly book specific? -->

View file

@ -0,0 +1,2 @@
</body>
</html>

View file

@ -0,0 +1,5 @@
<div class="paragraph">
<span class="paragraphnumber" id="para%(nr)d">%(nr)d</span>
-
%(text)s
</div>

View file

@ -0,0 +1 @@
<a href="#para%(nr)d">%(nr)d</a>

View file

@ -35,9 +35,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
| Name | Extension | Description |
|------------------+-----------+-------------------------------------------------------------------------------------------------|
| LaTeX | .tex | Useful to generate PDFs using pdflatex. |
| LaTeX | .tex | Useful to generate PDFs using pdflatex or whatever LaTeX tools you prefer. |
| Rich Text Format | .rtf | Supported because the Windhammer Prize requires it. |
| Graphviz DOT | .dot | Use with the Graphviz dot tool to generate a flowchart graph of all paragraphs in the gamebook. |
| HTML | .html | Play gamebook in browser. javascript to make fully playable not yet implemented. |
| Debug Plain Text | .debug | Plain text debug output of gamebook contents. |
More to be added.

View file

@ -9,6 +9,10 @@ dot -Tpng test.dot > test.png && open test.png
./formatgamebook.py test.json test.tex
pdflatex test.tex && open test.pdf
#./formatgamebook.py test.json test.rtf
./formatgamebook.py test.json test.html
open test.html
./formatgamebook.py test.json test.rtf
open test.rtf

View file

@ -1,19 +1,23 @@
* TODO [3/12] [25%]
* TODO [5/15] [33%]
- [X] Debug output
- [X] DOT output
- [X] LaTeX output
- [ ] RTF output
- [ ] HTML+JS output
- [ ] Debug HTML+JS output
- [X] RTF output
- [X] HTML output
- [ ] Save paragraph-number mapping and reuse automatically
- [ ] Add support for custom begin/end document templates.
Fixed names and/or command-line options.
- [ ] Add paragraph links in LaTeX output.
- [ ] Debug HTML output
- [ ] Inventory (take, drop, check)
- [ ] Codewords/Sightings (set, check, clean)
- [ ] Skill checks? Or is this higher level? No?
- [ ] More formatting possibilities in paragraphs
Look at existing gamebooks to get ideas.
- [ ] Prettier LaTeX output
Look at how some existing gamebooks are formatted.
- [ ] Command-line flag to set max paragraph number to use
- [ ] Dummy paragraphs
- [ ] Combat? Or is this higher level?
- [ ] Document Gamebook JSON format.
- [ ] Higher level text-language for Gamebooks