This repository was archived by the owner on Feb 22, 2022. It is now read-only.
Commit f8876c7 1 parent c517587 commit f8876c7 Copy full SHA for f8876c7
File tree 4 files changed +11
-10
lines changed
4 files changed +11
-10
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " ficdown.js" ,
3
- "version" : " 2.0.1 " ,
3
+ "version" : " 2.0.2 " ,
4
4
"description" : " A parser and player for Interactive Fiction written in Ficdown" ,
5
5
"scripts" : {
6
6
"build" : " rm -rf ./build && tsc" ,
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ export class Parser {
57
57
if ( ! storyHref ) throw new ParseError ( 'no link to first scene' , storyBlock . lineNumber ) ;
58
58
59
59
const story : Story = {
60
- name : storyName . text ,
60
+ name : storyName . title != null ? storyName . title : storyName . text ,
61
61
description : Util . trimText ( storyBlock . lines . map ( l => l . text ) . join ( "\n" ) ) ,
62
62
firstScene : storyHref . target ,
63
63
scenes : { } ,
@@ -87,7 +87,7 @@ export class Parser {
87
87
let key : string ;
88
88
let conditions : BoolHash | undefined = undefined ;
89
89
if ( sceneName ) {
90
- name = sceneName . title
90
+ name = sceneName . title != null
91
91
? Util . trimText ( sceneName . title )
92
92
: Util . trimText ( sceneName . text ) ;
93
93
key = Util . normalize ( sceneName . text ) ;
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ export class Player {
42
42
43
43
public play ( ) : void {
44
44
this . container . html (
45
- this . converter . render ( `# ${ this . story . name } \n\n${ this . story . description } \n\n[${ this . startText } ](/${ this . story . firstScene } )` ) ) ;
45
+ this . converter . render ( `${ this . story . name ? `# ${ this . story . name } \n\n` : '' } ${ this . story . description } \n\n[${ this . startText } ](/${ this . story . firstScene } )` ) ) ;
46
46
this . wireLinks ( ) ;
47
47
}
48
48
@@ -65,10 +65,11 @@ export class Player {
65
65
if ( this . story . scenes [ match . target ] ) {
66
66
for ( let scene of this . story . scenes [ match . target ] ) {
67
67
if ( Util . conditionsMet ( this . playerState , scene . conditions ) ) {
68
- if ( ! matchedScene
69
- || ! scene . conditions
70
- || ! matchedScene . conditions
71
- || Object . keys ( scene . conditions ) . length > Object . keys ( matchedScene . conditions ) . length ) {
68
+ const sceneConds = scene . conditions
69
+ ? Object . keys ( scene . conditions ) . length : 0 ;
70
+ const matchConds = matchedScene && matchedScene . conditions
71
+ ? Object . keys ( matchedScene . conditions ) . length : 0 ;
72
+ if ( ! matchedScene || sceneConds > matchConds ) {
72
73
matchedScene = scene ;
73
74
}
74
75
}
Original file line number Diff line number Diff line change @@ -16,13 +16,13 @@ export class Util {
16
16
} ;
17
17
18
18
private static matchToAnchor ( match : RegExpExecArray ) : Anchor {
19
- const result : Anchor = {
19
+ const result = {
20
20
anchor : match [ 1 ] ,
21
21
text : match [ 2 ] ,
22
22
href : match [ 3 ] ,
23
23
title : match [ 6 ] ,
24
24
} ;
25
- if ( result . href . indexOf ( '"' ) === 0 ) {
25
+ if ( result . href . indexOf ( '"' ) === 0 || result . href . indexOf ( "'" ) === 0 ) {
26
26
result . title = result . href . substring ( 1 , result . href . length - 1 ) ;
27
27
result . href = '' ;
28
28
}
You can’t perform that action at this time.
0 commit comments