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/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" } ``` 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..1535e26 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. */ @@ -12,7 +12,6 @@ import ( "log" "os" "path/filepath" - "strings" "time" // external packages "github.com/radovskyb/watcher" @@ -33,7 +32,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 +54,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 +76,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()) @@ -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) 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..047faed 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. */ @@ -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) 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..b947443 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. */ @@ -10,6 +10,7 @@ import ( "unicode" ) +// StringsInsensitively provides for case insensitively sorting slices of strings. type StringsInsensitively []string func (p StringsInsensitively) Len() int { 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..4bf56a5 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. */ @@ -85,10 +85,18 @@ 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:]-]`) - return strings.ToLower(invalidRe.ReplaceAllLiteralString(original, "-")) + // 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. + illegalRe := regexp.MustCompile(`[\x00-\x20!-/:-@[-^\x60{-\x9f]+`) + + return illegalRe.ReplaceAllLiteralString(original, "_") } func stringSliceContains(haystack []string, needle string) bool { diff --git a/version.go b/version.go index 76fc557..7a95364 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. */ @@ -24,7 +24,7 @@ var ( tweegoVersion = versionInfo{ major: 2, minor: 1, - patch: 0, + patch: 1, pre: "", } // tweegoVersion holds the build ID.