Skip to content

Commit

Permalink
fix #4
Browse files Browse the repository at this point in the history
  • Loading branch information
lichendust committed Dec 15, 2023
1 parent 0388151 commit 386f128
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
15 changes: 7 additions & 8 deletions source/command_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,8 @@ func convert_final_draft(config *Config) {
}

if has_text {
buffer.WriteString("\n{{header:")
buffer.WriteString("\nheader: ")
buffer.WriteString(write_chunks(paragraph.Chunks, false))
buffer.WriteString("}}")
}
}

Expand All @@ -205,9 +204,8 @@ func convert_final_draft(config *Config) {
}

if has_text {
buffer.WriteString("\n{{footer:")
buffer.WriteString("\nfooter: ")
buffer.WriteString(write_chunks(paragraph.Chunks, false))
buffer.WriteString("}}")
}
}
}
Expand Down Expand Up @@ -273,6 +271,8 @@ func convert_final_draft(config *Config) {
}
}

buffer.WriteRune('\n')

success := write_file(fix_path(config.output_file), []byte(buffer.String()))
if !success {
eprintln("failed to write", config.output_file)
Expand Down Expand Up @@ -312,16 +312,15 @@ func write_chunks(input []*XML_Chunk, force_uppercase bool) string {
opening = opening + x
closing = x + closing
}
// println("debug: missed a final draft thing", s)
}
}

if len(chunk.Label) != 0 {
switch chunk.Label {
case "Page #":
buffer.WriteString("%p")
buffer.WriteString("#PAGE")
case "Last Revised":
buffer.WriteString("{{timestamp}}")
buffer.WriteString("$date") // @todo
}
continue
}
Expand All @@ -332,4 +331,4 @@ func write_chunks(input []*XML_Chunk, force_uppercase bool) string {
}

return buffer.String()
}
}
4 changes: 2 additions & 2 deletions source/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ func syntax_parser(config *Config, data *Fountain, text string) {
}

if node.Type == CHARACTER {
if i < len(nodes) {
if i < len(nodes) - 1 {
if !is_character_train(nodes[i + 1].Type) {
node.Type = ACTION
continue
Expand Down Expand Up @@ -1124,4 +1124,4 @@ var LINE_TYPE_INDICES = [...]uint8{0, 10, 20, 26, 32, 44, 50, 55, 64, 78, 91, 10

func (i Line_Type) String() string {
return LINE_TYPE_NAMES[LINE_TYPE_INDICES[i]:LINE_TYPE_INDICES[i+1]]
}
}

0 comments on commit 386f128

Please sign in to comment.