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", "name": "ficdown.js",
"version": "0.9.0", "version": "0.9.1",
"description": "A parser and player for Interactive Fiction written in Ficdown", "description": "A parser and player for Interactive Fiction written in Ficdown",
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {

View file

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

View file

@ -96,7 +96,8 @@ class Player
newScene = $.extend {}, @currentScene newScene = $.extend {}, @currentScene
newScene.description = @resolveDescription newScene.description newScene.description = @resolveDescription newScene.description
@disableOldLinks() @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 += "#{action.description}\n\n" for action in actions
newContent += newScene.description newContent += newScene.description
newHtml = @processHtml newScene.id, @converter.makeHtml newContent 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 an option.](/test-scene-2)
- [This is another option.](#test-condition) - [This is another option.](#test-condition)
- [Another scene.](/test-scene-3)
### Test Condition ### Test Condition
@ -29,7 +30,11 @@ This is the scene that matches a condition.
## Test Scene 2 ## 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> <div><button onclick="doIt()">Do It</button></div>
<pre id="output"> <pre id="output">
@ -37,12 +42,11 @@ This is a second scene</textarea>
</div> </div>
<script src="ficdown.js"></script> <script src="ficdown.js"></script>
<script> <script>
function doIt(){ (function doIt(){
var storyText = document.getElementById('input').value; var storyText = document.getElementById('input').value;
var story = parseText(storyText); var story = parseText(storyText);
document.getElementById('output').innerHTML = JSON.stringify(story,null,2); document.getElementById('output').innerHTML = JSON.stringify(story,null,2);
} })()
doIt();
</script> </script>
</body> </body>
</html> </html>