mirror of
https://github.com/tmedwards/tweego.git
synced 2025-07-04 21:50:33 -04:00
[New, Update] Messy commit.
* [Update] Add module paths to watch files. From the old Bitbucket repo, submitted by `MarkSill`. * [Fix] Trim erroneous whitespace surrounding the story title. From the old Bitbucket repo. * [Update, Devel, Docs] Changed import and doc paths to point to the GitHub repo and removed Mercurial references. * [Fix] Leading whitespace on passages is trimmed as intended. * [New, Docs] Added an option to disable passage trimming (`--no-trim`). * [Update] Update IFID commentary and cleanup. * [Update] Switched to another SemVer module due to a few issues with the old one. * [Update] Purged commented legacy & debug code.
This commit is contained in:
parent
57e1aa52ff
commit
1bb4278938
15 changed files with 123 additions and 64 deletions
18
ifid.go
18
ifid.go
|
@ -13,11 +13,15 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
// IFIDs are defined in The Treaty of Babel.
|
||||
// An IFID (Interactive Fiction IDentifier) uniquely identifies compiled
|
||||
// projects. Most IFIDs are simply the string form of a v4 random UUID.
|
||||
//
|
||||
// IFIDs, in general, are defined within The Treaty of Babel.
|
||||
// SEE: http://babel.ifarchive.org/
|
||||
//
|
||||
// Most IFIDs, and certainly those generated by Tweego, are simply the
|
||||
// string form of a v4 random UUID.
|
||||
// Twine ecosystem IFIDs are defined within both the Twee 3 Specification
|
||||
// and Twine 2 HTML Output Specification.
|
||||
// SEE: https://github.com/iftechfoundation/twine-specs/
|
||||
|
||||
// newIFID generates a new IFID (UUID v4).
|
||||
func newIFID() (string, error) {
|
||||
|
@ -35,8 +39,12 @@ func newIFID() (string, error) {
|
|||
// validateIFID validates ifid or returns an error.
|
||||
func validateIFID(ifid string) error {
|
||||
switch len(ifid) {
|
||||
case 36: // xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
case 36 + 9: // UUID://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx//
|
||||
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
case 36:
|
||||
// no-op
|
||||
|
||||
// UUID://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx//
|
||||
case 36 + 9:
|
||||
if strings.ToUpper(ifid[:7]) != "UUID://" || ifid[43:] != "//" {
|
||||
return fmt.Errorf("invalid IFID UUID://…// format")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue