support scenes with empty titles

closes #5
This commit is contained in:
Rudis Muiznieks 2017-12-28 16:21:39 -06:00
parent 9869d8b7e3
commit 5794db26d6
No known key found for this signature in database
GPG key ID: 1C290B51E05090F8
5 changed files with 1024 additions and 7 deletions

1012
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{
"name": "ficdown.js",
"version": "0.9.0",
"version": "0.9.1",
"description": "A parser and player for Interactive Fiction written in Ficdown",
"dependencies": {},
"devDependencies": {

View file

@ -65,7 +65,7 @@ blockToScene = (block) ->
title = trimText block.name
key = normalize block.name
scene =
name: title
name: if title != '' then title else null
key: key
description: trimText block.lines.join "\n"
conditions: if conditions? then conditions else null

View file

@ -96,7 +96,8 @@ class Player
newScene = $.extend {}, @currentScene
newScene.description = @resolveDescription newScene.description
@disableOldLinks()
newContent = "###{newScene.name}\n\n"
newContent = ""
newContent += "###{newScene.name}\n\n" if newScene.name?
newContent += "#{action.description}\n\n" for action in actions
newContent += newScene.description
newHtml = @processHtml newScene.id, @converter.makeHtml newContent

View file

@ -18,6 +18,7 @@ This is a test scene.scene
- [This is an option.](/test-scene-2)
- [This is another option.](#test-condition)
- [Another scene.](/test-scene-3)
### Test Condition
@ -29,7 +30,11 @@ This is the scene that matches a condition.
## Test Scene 2
This is a second scene</textarea>
This is a second scene
## [Test Scene 3]("")
This scene has no title.</textarea>
<div><button onclick="doIt()">Do It</button></div>
<pre id="output">
@ -37,12 +42,11 @@ This is a second scene</textarea>
</div>
<script src="ficdown.js"></script>
<script>
function doIt(){
(function doIt(){
var storyText = document.getElementById('input').value;
var story = parseText(storyText);
document.getElementById('output').innerHTML = JSON.stringify(story,null,2);
}
doIt();
})()
</script>
</body>
</html>