From ecef9e14eab578887b2fdabfa1e039c47202e6b3 Mon Sep 17 00:00:00 2001 From: "Thomas M. Edwards" Date: Mon, 24 Feb 2020 14:16:59 -0600 Subject: [PATCH 1/8] [Docs] Improvements. * Add enough of a description of story format versions that the later mention of "major version" makes sense. * Change a "should" to the correct "must" in the JSON chunk warning. * Add a reminder to the Twee2->Twee v3 tip about the standard Twee file extensions. --- docs/core/faq-and-tips.md | 2 +- docs/core/special-passages-and-tags.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/core/faq-and-tips.md b/docs/core/faq-and-tips.md index 31758f0..7b8770d 100644 --- a/docs/core/faq-and-tips.md +++ b/docs/core/faq-and-tips.md @@ -45,7 +45,7 @@ You may convert a Twee2 notation file to a Twee v3 notation file like so: tweego -d -o twee_v3_file.twee twee2_file.tw2 ``` -Or, if the Twee2 notation file has a standard Twee file extension, like so: +Or, if the Twee2 notation file has a standard Twee file extension (`.tw`, `.twee`), like so: ``` tweego --twee2-compat -d -o twee_v3_file.twee twee2_file.twee diff --git a/docs/core/special-passages-and-tags.md b/docs/core/special-passages-and-tags.md index 74918d6..1b8ae51 100644 --- a/docs/core/special-passages-and-tags.md +++ b/docs/core/special-passages-and-tags.md @@ -46,7 +46,7 @@ The core properties used with all story formats include: The properties used only with Twine 2-style story formats include: - format: (string) Optional. The name of the story format to compile against—e.g., `SugarCube`, `Harlowe`, `Chapbook`, `Snowman`. -- format-version: (string) Optional. The version of the story format to compile against—e.g., `2.29.0`. From the installed story formats matching the name specified in format, Tweego will attempt to use the greatest version that matches the specified major version—i.e., if format-version is `2.0.0` and you have the versions `1.0.0`, `2.0.0`, `2.5.0`, and `3.0.0` installed, Tweego will choose `2.5.0`. +- format-version: (string) Optional. The version of the story format to compile against. Story format versions follow the [Semantic Versioning specification](https://semver.org/), though generally use only the major.minor.patch form—e.g., `2.30.0`. From the installed story formats matching the name specified in format, Tweego will attempt to use the greatest version that matches the specified major version—i.e., if format-version is `2.0.0` and you have the versions `1.0.0`, `2.0.0`, `2.5.0`, and `3.0.0` installed, then Tweego will choose `2.5.0`.

Note: The above is not an exhaustive list of all Twine 2-style story format properties. There are others available that are only useful when actually interoperating with Twine 2—e.g, tag-colors and zoom. See the twee-3-specification.md for more information. @@ -57,7 +57,7 @@ To compile against a specific version of a story format, use the format command

Warning: -JSON chunks are not JavaScript object literals, though they look much alike. Property names must always be double quoted and you should not include a trailing comma after the last property. +JSON chunks are not JavaScript object literals, though they look much alike. Property names must always be double quoted and you must not include a trailing comma after the last property.

#### Example @@ -67,7 +67,7 @@ JSON chunks are not JavaScript object literals, though they look much alike. Pr { "ifid": "D674C58C-DEFA-4F70-B7A2-27742230C0FC", "format": "SugarCube", - "format-version": "2.29.0", + "format-version": "2.30.0", "start": "My Starting Passage" } ``` From 07de47c9bfd791a5b17d4028ac23a54fcb4464d1 Mon Sep 17 00:00:00 2001 From: "Thomas M. Edwards" Date: Mon, 24 Feb 2020 14:28:13 -0600 Subject: [PATCH 2/8] [Update] Copyright mambo. --- LICENSE | 2 +- config.go | 2 +- escaping.go | 2 +- filesystem.go | 2 +- formats.go | 2 +- html.go | 2 +- ifid.go | 2 +- io.go | 2 +- module.go | 2 +- passage.go | 2 +- passagedata.go | 2 +- sort.go | 2 +- statsitics.go | 2 +- story.go | 2 +- storydata.go | 2 +- storyload.go | 2 +- storyout.go | 2 +- tweego.go | 2 +- usage.go | 4 ++-- user.go | 2 +- util.go | 2 +- version.go | 2 +- 22 files changed, 23 insertions(+), 23 deletions(-) diff --git a/LICENSE b/LICENSE index 49778b8..9e1ad84 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014-2019, Thomas Michael Edwards . +Copyright (c) 2014-2020, Thomas Michael Edwards . All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/config.go b/config.go index 55eb7f1..319175b 100644 --- a/config.go +++ b/config.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/escaping.go b/escaping.go index 35b9cf9..ce05b17 100644 --- a/escaping.go +++ b/escaping.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/filesystem.go b/filesystem.go index 781ca59..40975c0 100644 --- a/filesystem.go +++ b/filesystem.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/formats.go b/formats.go index 55b5838..6b6a1c1 100644 --- a/formats.go +++ b/formats.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/html.go b/html.go index e0a7247..eebefd0 100644 --- a/html.go +++ b/html.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/ifid.go b/ifid.go index a2cbd9b..b16af68 100644 --- a/ifid.go +++ b/ifid.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/io.go b/io.go index 72db0ff..0505816 100644 --- a/io.go +++ b/io.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/module.go b/module.go index a04cec0..27e5ed1 100644 --- a/module.go +++ b/module.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/passage.go b/passage.go index 7d31fd5..d67eb0d 100644 --- a/passage.go +++ b/passage.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/passagedata.go b/passagedata.go index d05ef1e..30090f2 100644 --- a/passagedata.go +++ b/passagedata.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/sort.go b/sort.go index c714717..60c0881 100644 --- a/sort.go +++ b/sort.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/statsitics.go b/statsitics.go index cb2aaea..bdc0bb3 100644 --- a/statsitics.go +++ b/statsitics.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/story.go b/story.go index c62847d..82e0f6f 100644 --- a/story.go +++ b/story.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/storydata.go b/storydata.go index 0e81d12..37625cb 100644 --- a/storydata.go +++ b/storydata.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/storyload.go b/storyload.go index b5827ea..7f8a378 100644 --- a/storyload.go +++ b/storyload.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/storyout.go b/storyout.go index 8e60d3d..d3422c4 100644 --- a/storyout.go +++ b/storyout.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/tweego.go b/tweego.go index 7d9928f..49daf49 100644 --- a/tweego.go +++ b/tweego.go @@ -1,7 +1,7 @@ /* tweego (a twee compiler in Go) - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/usage.go b/usage.go index e91c6dc..0f9955b 100644 --- a/usage.go +++ b/usage.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ @@ -120,7 +120,7 @@ func usageVersion() { fmt.Fprintf(os.Stderr, "\n%s, %s\n", tweegoName, tweegoVersion) fmt.Fprint(os.Stderr, ` Tweego (a Twee compiler in Go) [http://www.motoslave.net/tweego/] -Copyright (c) 2014-2019 Thomas Michael Edwards. All rights reserved. +Copyright (c) 2014-2020 Thomas Michael Edwards. All rights reserved. `) os.Exit(1) diff --git a/user.go b/user.go index 65b6830..bead53a 100644 --- a/user.go +++ b/user.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/util.go b/util.go index 463c947..fac2b1a 100644 --- a/util.go +++ b/util.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ diff --git a/version.go b/version.go index 76fc557..ee08e68 100644 --- a/version.go +++ b/version.go @@ -1,5 +1,5 @@ /* - Copyright © 2014–2019 Thomas Michael Edwards. All rights reserved. + Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved. Use of this source code is governed by a Simplified BSD License which can be found in the LICENSE file. */ From 59bf950d9891587adebd931d53e3e7fa8c464047 Mon Sep 17 00:00:00 2001 From: "Thomas M. Edwards" Date: Mon, 24 Feb 2020 14:29:14 -0600 Subject: [PATCH 3/8] [Update] Remove redundant variable. --- module.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/module.go b/module.go index 27e5ed1..047faed 100644 --- a/module.go +++ b/module.go @@ -98,8 +98,7 @@ func loadModuleFont(filename string) ([]byte, error) { } var ( - name = filepath.Base(filename) - family = strings.Split(name, ".")[0] + family = strings.Split(filepath.Base(filename), ".")[0] idSlug = "style-module-" + slugify(family) ext = normalizedFileExt(filename) mediaType = mediaTypeFromExt(ext) From 0309c003e79443c4a7f698800408324da7a63787 Mon Sep 17 00:00:00 2001 From: "Thomas M. Edwards" Date: Mon, 24 Feb 2020 15:23:00 -0600 Subject: [PATCH 4/8] [Update] Improve `slugify()`'s set of invalid characters. --- util.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/util.go b/util.go index fac2b1a..310ec2e 100644 --- a/util.go +++ b/util.go @@ -85,9 +85,17 @@ func normalizedFileExt(filename string) string { return strings.ToLower(ext[1:]) } +// Returns a trimmed and encoded slug of the passed string that should be safe +// for use as a DOM ID or class name. func slugify(original string) string { - // TODO: Maybe expand this to include non-ASCII alphas? - invalidRe := regexp.MustCompile(`[^[:word:]-]`) + // NOTE: The range of illegal characters consists of: C0 controls, space, exclamation, + // double quote, number, dollar, percent, ampersand, single quote, left paren, right + // paren, asterisk, plus, comma, hyphen, period, forward slash, colon, semi-colon, + // less-than, equals, greater-than, question, at, left bracket, backslash, right + // bracket, caret, backquote/grave, left brace, pipe/vertical-bar, right brace, tilde, + // delete, C1 controls. + invalidRe := regexp.MustCompile(`[\x00-\x20!"#$%&'()*+,\-./:;<=>?@[\\\]^\x60{|}~\x7f-\x9f]+`) + return strings.ToLower(invalidRe.ReplaceAllLiteralString(original, "-")) } From 6e2090b23db2083b7102d04a8501581f0548fa64 Mon Sep 17 00:00:00 2001 From: "Thomas M. Edwards" Date: Mon, 24 Feb 2020 16:08:26 -0600 Subject: [PATCH 5/8] [Update] Golint appeasement. --- filesystem.go | 6 +++--- sort.go | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/filesystem.go b/filesystem.go index 40975c0..4717ee8 100644 --- a/filesystem.go +++ b/filesystem.go @@ -33,7 +33,7 @@ func init() { } } -var noOutToIn = fmt.Errorf("no output to input source") +var errNoOutToIn = fmt.Errorf("no output to input source") // Walk the specified pathnames, collecting regular files. func getFilenames(pathnames []string, outFilename string) []string { @@ -55,7 +55,7 @@ func getFilenames(pathnames []string, outFilename string) []string { return err } if absolute == absOutFile { - return noOutToIn + return errNoOutToIn } relative, _ := filepath.Rel(workingDir, absolute) // Failure is okay. if relative != "" { @@ -77,7 +77,7 @@ func getFilenames(pathnames []string, outFilename string) []string { log.Print("warning: path -: Reading from standard input is unsupported.") continue } else if err := filepath.Walk(pathname, fileWalker); err != nil { - if err == noOutToIn { + if err == errNoOutToIn { log.Fatalf("error: path %s: Output file cannot be an input source.", pathname) } else { log.Printf("warning: path %s: %s", pathname, err.Error()) diff --git a/sort.go b/sort.go index 60c0881..b947443 100644 --- a/sort.go +++ b/sort.go @@ -10,6 +10,7 @@ import ( "unicode" ) +// StringsInsensitively provides for case insensitively sorting slices of strings. type StringsInsensitively []string func (p StringsInsensitively) Len() int { From 2d91f1ce966dc016e7f1db32a2c3ec1da7a98eb2 Mon Sep 17 00:00:00 2001 From: "Thomas M. Edwards" Date: Mon, 24 Feb 2020 16:19:07 -0600 Subject: [PATCH 6/8] [Fix] Fixed usage of old `watcher` `Event` API. Resolves #7. * The `watcher` `Event` API changed from stuffing old/new path into a single field to having them as separate fields. Update the code to use the new API. --- filesystem.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/filesystem.go b/filesystem.go index 4717ee8..1535e26 100644 --- a/filesystem.go +++ b/filesystem.go @@ -12,7 +12,6 @@ import ( "log" "os" "path/filepath" - "strings" "time" // external packages "github.com/radovskyb/watcher" @@ -133,12 +132,9 @@ func watchFilesystem(pathnames []string, outFilename string, buildCallback func( var pathname string switch event.Op { case watcher.Move, watcher.Rename: - // NOTE: Format of Move/Rename event `Path` field: "oldName -> newName". - // TODO: Should probably error out if we can't split the event.Path value. - names := strings.Split(event.Path, " -> ") - pathname = fmt.Sprintf("%s -> %s", relPath(names[0]), relPath(names[1])) + pathname = fmt.Sprintf("%s -> %s", relPath(event.OldPath), relPath(event.Path)) if !build && !isDir { - build = knownFileType(names[0]) || knownFileType(names[1]) + build = knownFileType(event.OldPath) || knownFileType(event.Path) } default: pathname = relPath(event.Path) From ea69d813753a2a7439624650c31771416cfc1a13 Mon Sep 17 00:00:00 2001 From: "Thomas M. Edwards" Date: Tue, 25 Feb 2020 00:56:36 -0600 Subject: [PATCH 7/8] [Update] Update `slugify()` again. * Reduced the regexp by switching fully to ranges. * Switched replacement character to underscore. * Dropped lowercasing. --- util.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util.go b/util.go index 310ec2e..4bf56a5 100644 --- a/util.go +++ b/util.go @@ -94,9 +94,9 @@ func slugify(original string) string { // less-than, equals, greater-than, question, at, left bracket, backslash, right // bracket, caret, backquote/grave, left brace, pipe/vertical-bar, right brace, tilde, // delete, C1 controls. - invalidRe := regexp.MustCompile(`[\x00-\x20!"#$%&'()*+,\-./:;<=>?@[\\\]^\x60{|}~\x7f-\x9f]+`) + illegalRe := regexp.MustCompile(`[\x00-\x20!-/:-@[-^\x60{-\x9f]+`) - return strings.ToLower(invalidRe.ReplaceAllLiteralString(original, "-")) + return illegalRe.ReplaceAllLiteralString(original, "_") } func stringSliceContains(haystack []string, needle string) bool { From 0a0821918e88508d8e7d8fea122a8bfee995f71a Mon Sep 17 00:00:00 2001 From: "Thomas M. Edwards" Date: Tue, 25 Feb 2020 00:58:19 -0600 Subject: [PATCH 8/8] PREPPING: v2.1.1 --- version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.go b/version.go index ee08e68..7a95364 100644 --- a/version.go +++ b/version.go @@ -24,7 +24,7 @@ var ( tweegoVersion = versionInfo{ major: 2, minor: 1, - patch: 0, + patch: 1, pre: "", } // tweegoVersion holds the build ID.