From 386f12829d0c8136d96e260814a0f3f2c2eef9f5 Mon Sep 17 00:00:00 2001 From: Harley Denham <45082543+qxoko@users.noreply.github.com> Date: Fri, 15 Dec 2023 12:16:21 +0000 Subject: [PATCH] fix #4 --- source/command_convert.go | 15 +++++++-------- source/parser.go | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/source/command_convert.go b/source/command_convert.go index d4a99d8..ca48cc9 100644 --- a/source/command_convert.go +++ b/source/command_convert.go @@ -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("}}") } } @@ -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("}}") } } } @@ -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) @@ -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 } @@ -332,4 +331,4 @@ func write_chunks(input []*XML_Chunk, force_uppercase bool) string { } return buffer.String() -} \ No newline at end of file +} diff --git a/source/parser.go b/source/parser.go index 403a30d..af863c3 100644 --- a/source/parser.go +++ b/source/parser.go @@ -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 @@ -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]] -} \ No newline at end of file +}