mirror of
https://github.com/tmedwards/tweego.git
synced 2025-07-05 06:00:26 -04:00
RELEASE: v2.1.1
This commit is contained in:
commit
81d1d717d1
24 changed files with 46 additions and 42 deletions
2
LICENSE
2
LICENSE
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2014-2019, Thomas Michael Edwards <thomasmedwards@gmail.com>.
|
Copyright (c) 2014-2020, Thomas Michael Edwards <thomasmedwards@gmail.com>.
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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
|
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
|
tweego --twee2-compat -d -o twee_v3_file.twee twee2_file.twee
|
||||||
|
|
|
@ -46,7 +46,7 @@ The core properties used with all story formats include:
|
||||||
The properties used only with Twine 2-style story formats include:
|
The properties used only with Twine 2-style story formats include:
|
||||||
|
|
||||||
- <var>format</var>: (string) Optional. The name of the story format to compile against—e.g., `SugarCube`, `Harlowe`, `Chapbook`, `Snowman`.
|
- <var>format</var>: (string) Optional. The name of the story format to compile against—e.g., `SugarCube`, `Harlowe`, `Chapbook`, `Snowman`.
|
||||||
- <var>format-version</var>: (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 <var>format</var>, Tweego will attempt to use the greatest version that matches the specified major version—i.e., if <var>format-version</var> 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`.
|
- <var>format-version</var>: (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 <var>major.minor.patch</var> form—e.g., `2.30.0`. From the installed story formats matching the name specified in <var>format</var>, Tweego will attempt to use the greatest version that matches the specified <var>major</var> version—i.e., if <var>format-version</var> 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`.
|
||||||
|
|
||||||
<p role="note"><b>Note:</b>
|
<p role="note"><b>Note:</b>
|
||||||
The above is <em>not</em> 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, <var>tag-colors</var> and <var>zoom</var>. See the <a href="https://github.com/iftechfoundation/twine-specs/blob/master/twee-3-specification.md" target="_blank">twee-3-specification.md</a> for more information.
|
The above is <em>not</em> 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, <var>tag-colors</var> and <var>zoom</var>. See the <a href="https://github.com/iftechfoundation/twine-specs/blob/master/twee-3-specification.md" target="_blank">twee-3-specification.md</a> for more information.
|
||||||
|
@ -57,7 +57,7 @@ To compile against a specific version of a story format, use the format command
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p class="warning" role="note"><b>Warning:</b>
|
<p class="warning" role="note"><b>Warning:</b>
|
||||||
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.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
@ -67,7 +67,7 @@ JSON chunks are not JavaScript object literals, though they look much alike. Pr
|
||||||
{
|
{
|
||||||
"ifid": "D674C58C-DEFA-4F70-B7A2-27742230C0FC",
|
"ifid": "D674C58C-DEFA-4F70-B7A2-27742230C0FC",
|
||||||
"format": "SugarCube",
|
"format": "SugarCube",
|
||||||
"format-version": "2.29.0",
|
"format-version": "2.30.0",
|
||||||
"start": "My Starting Passage"
|
"start": "My Starting Passage"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
@ -12,7 +12,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
// external packages
|
// external packages
|
||||||
"github.com/radovskyb/watcher"
|
"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.
|
// Walk the specified pathnames, collecting regular files.
|
||||||
func getFilenames(pathnames []string, outFilename string) []string {
|
func getFilenames(pathnames []string, outFilename string) []string {
|
||||||
|
@ -55,7 +54,7 @@ func getFilenames(pathnames []string, outFilename string) []string {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if absolute == absOutFile {
|
if absolute == absOutFile {
|
||||||
return noOutToIn
|
return errNoOutToIn
|
||||||
}
|
}
|
||||||
relative, _ := filepath.Rel(workingDir, absolute) // Failure is okay.
|
relative, _ := filepath.Rel(workingDir, absolute) // Failure is okay.
|
||||||
if relative != "" {
|
if relative != "" {
|
||||||
|
@ -77,7 +76,7 @@ func getFilenames(pathnames []string, outFilename string) []string {
|
||||||
log.Print("warning: path -: Reading from standard input is unsupported.")
|
log.Print("warning: path -: Reading from standard input is unsupported.")
|
||||||
continue
|
continue
|
||||||
} else if err := filepath.Walk(pathname, fileWalker); err != nil {
|
} 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)
|
log.Fatalf("error: path %s: Output file cannot be an input source.", pathname)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("warning: path %s: %s", pathname, err.Error())
|
log.Printf("warning: path %s: %s", pathname, err.Error())
|
||||||
|
@ -133,12 +132,9 @@ func watchFilesystem(pathnames []string, outFilename string, buildCallback func(
|
||||||
var pathname string
|
var pathname string
|
||||||
switch event.Op {
|
switch event.Op {
|
||||||
case watcher.Move, watcher.Rename:
|
case watcher.Move, watcher.Rename:
|
||||||
// NOTE: Format of Move/Rename event `Path` field: "oldName -> newName".
|
pathname = fmt.Sprintf("%s -> %s", relPath(event.OldPath), relPath(event.Path))
|
||||||
// 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]))
|
|
||||||
if !build && !isDir {
|
if !build && !isDir {
|
||||||
build = knownFileType(names[0]) || knownFileType(names[1])
|
build = knownFileType(event.OldPath) || knownFileType(event.Path)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
pathname = relPath(event.Path)
|
pathname = relPath(event.Path)
|
||||||
|
|
|
@ -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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
2
html.go
2
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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
2
ifid.go
2
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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
2
io.go
2
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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
@ -98,8 +98,7 @@ func loadModuleFont(filename string) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
name = filepath.Base(filename)
|
family = strings.Split(filepath.Base(filename), ".")[0]
|
||||||
family = strings.Split(name, ".")[0]
|
|
||||||
idSlug = "style-module-" + slugify(family)
|
idSlug = "style-module-" + slugify(family)
|
||||||
ext = normalizedFileExt(filename)
|
ext = normalizedFileExt(filename)
|
||||||
mediaType = mediaTypeFromExt(ext)
|
mediaType = mediaTypeFromExt(ext)
|
||||||
|
|
|
@ -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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
3
sort.go
3
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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
@ -10,6 +10,7 @@ import (
|
||||||
"unicode"
|
"unicode"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// StringsInsensitively provides for case insensitively sorting slices of strings.
|
||||||
type StringsInsensitively []string
|
type StringsInsensitively []string
|
||||||
|
|
||||||
func (p StringsInsensitively) Len() int {
|
func (p StringsInsensitively) Len() int {
|
||||||
|
|
|
@ -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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
2
story.go
2
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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
tweego (a twee compiler in Go)
|
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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
4
usage.go
4
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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
@ -120,7 +120,7 @@ func usageVersion() {
|
||||||
fmt.Fprintf(os.Stderr, "\n%s, %s\n", tweegoName, tweegoVersion)
|
fmt.Fprintf(os.Stderr, "\n%s, %s\n", tweegoName, tweegoVersion)
|
||||||
fmt.Fprint(os.Stderr, `
|
fmt.Fprint(os.Stderr, `
|
||||||
Tweego (a Twee compiler in Go) [http://www.motoslave.net/tweego/]
|
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)
|
os.Exit(1)
|
||||||
|
|
2
user.go
2
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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
16
util.go
16
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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
@ -85,10 +85,18 @@ func normalizedFileExt(filename string) string {
|
||||||
return strings.ToLower(ext[1:])
|
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 {
|
func slugify(original string) string {
|
||||||
// TODO: Maybe expand this to include non-ASCII alphas?
|
// NOTE: The range of illegal characters consists of: C0 controls, space, exclamation,
|
||||||
invalidRe := regexp.MustCompile(`[^[:word:]-]`)
|
// double quote, number, dollar, percent, ampersand, single quote, left paren, right
|
||||||
return strings.ToLower(invalidRe.ReplaceAllLiteralString(original, "-"))
|
// 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 {
|
func stringSliceContains(haystack []string, needle string) bool {
|
||||||
|
|
|
@ -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
|
Use of this source code is governed by a Simplified BSD License which
|
||||||
can be found in the LICENSE file.
|
can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
@ -24,7 +24,7 @@ var (
|
||||||
tweegoVersion = versionInfo{
|
tweegoVersion = versionInfo{
|
||||||
major: 2,
|
major: 2,
|
||||||
minor: 1,
|
minor: 1,
|
||||||
patch: 0,
|
patch: 1,
|
||||||
pre: "",
|
pre: "",
|
||||||
}
|
}
|
||||||
// tweegoVersion holds the build ID.
|
// tweegoVersion holds the build ID.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue