From 1bb4278938d92e78839eaf5dcaeffce50ac76617 Mon Sep 17 00:00:00 2001 From: "Thomas M. Edwards" Date: Mon, 23 Dec 2019 14:25:57 -0600 Subject: [PATCH] [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. --- README.md | 49 ++++++++++++++++++++++++-- config.go | 23 +++++------- docs/core/faq-and-tips.md | 4 +-- docs/core/getting-started.md | 6 ++-- docs/core/special-passages-and-tags.md | 2 +- docs/core/usage.md | 4 +++ docs/introduction.md | 2 +- escaping.go | 14 +++----- formats.go | 21 ++++++----- go.mod | 11 ++++++ ifid.go | 18 +++++++--- story.go | 3 ++ storyload.go | 26 +++++++------- tweego.go | 3 +- usage.go | 1 + 15 files changed, 123 insertions(+), 64 deletions(-) create mode 100644 go.mod diff --git a/README.md b/README.md index d6d482b..2b3247d 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,51 @@ See [Tweego's documentation](http://www.motoslave.net/tweego/docs/) for informat Tweego has a Trello board, [Tweego TODO](https://trello.com/b/l5xuRzFu). Feel free to comment. -## NOTICE +## INSTALLATION -This is the initial commit to this GitHub repository, which is a migration from the old Bitbucket repository. It is based on the v2.0.0 release and is not suitable for compilation as-is due to import path differences. The first release from this repository will address that problem. +You may either download one of the precompiled binaries from [Tweego's website](http://www.motoslave.net/tweego/), which are available in both 32- and 64-bit versions for multiple operating systems, or build Tweego from source (see **BUILDING FROM SOURCE** below). + +## BUILDING FROM SOURCE + +If you want to build Tweego from scratch, rather than grabbing one of the precompiled binaries off of its website, then these instructions are for you. + +Tweego is written in the Go programming language, so you'll need to install it, if you don't already have it. Additionally, to retrieve Go packages—like Tweego and its dependencies—from source control repositories, you'll need to install Git. + +1. [Download and install the Go programming language (want ≥v1.13)](http://golang.org/doc/install) +2. [Download and install the Git source control management tool](https://git-scm.com/) + +Once all the tooling is installed and set up, the next step is to fetch the Tweego source code. Open a shell to wherever you wish to store the code and run the following command: + +``` +git clone https://github.com/tmedwards/tweego.git +``` + +Next, change to the directory that the previous command created: + +``` +cd tweego +``` + +Next, fetch Tweego's dependencies via the following command: + +``` +go get +``` + +You should now have Tweego and all its dependencies downloaded, so you may now compile and install it to your `GOPATH` by running the following command: + +``` +go install +``` + +Assuming that completed with no errors, your compiled Tweego binary should be in your `GOPATH`'s `bin` directory. To run Tweego you'll need to either have added your `GOPATH` `bin` to your `PATH` environment variable—this was likely done for you automatically during the installation of Go—or copy the binary to an existing directory within your `PATH`. + +Alternatively. If you just want to compile Tweego, so that you can manually copy the binary to wherever you wish, use the following command instead: + +``` +go build +``` + +Assuming that completed with no errors, your compiled Tweego binary should be in the current directory—likely named either `tweego` or `tweego.exe` depending on your OS. + +Finally, see [Tweego's documentation](http://www.motoslave.net/tweego/docs/) for information on how to set it up and use it. diff --git a/config.go b/config.go index 747bfd6..55eb7f1 100644 --- a/config.go +++ b/config.go @@ -12,7 +12,7 @@ import ( "os" "path/filepath" // internal packages - "bitbucket.org/tmedwards/tweego/internal/option" + "github.com/tmedwards/tweego/internal/option" // external packages "github.com/paulrosania/go-charset/charset" ) @@ -44,11 +44,12 @@ type config struct { outMode outputMode // output mode formats storyFormatsMap // map of all enumerated story formats + logFiles bool // log input files + logStats bool // log story statistics testMode bool // enable test mode + trim bool // enable passage trimming twee2Compat bool // enable Twee2 header extension compatibility mode watchFiles bool // enable filesystem watching - logStats bool // log story statistics - logFiles bool // log input files } const ( @@ -56,6 +57,7 @@ const ( defaultOutFile = "-" // defaultOutMode = outModeHTML defaultStartName = "Start" + defaultTrimState = true ) // newConfig creates a new config instance @@ -97,20 +99,10 @@ func newConfig() *config { common: common{formatID: defaultFormatID, startName: defaultStartName}, outFile: defaultOutFile, outMode: defaultOutMode, + trim: defaultTrimState, } // Merge values from the environment variables. - // /* - // LEGACY - // */ - // for _, env := range []string{"TWEEGO_CHARSET", "TWEEGO_FORMAT"} { - // if _, exists := os.LookupEnv(env); exists { - // log.Printf("warning: Detected obsolete environment variable %q. Please remove it from your environment.", env) - // } - // } - // /* - // END LEGACY - // */ if env := os.Getenv("TWEEGO_PATH"); env != "" { formatDirs = append(formatDirs, filepath.SplitList(env)...) } @@ -144,6 +136,7 @@ func newConfig() *config { options.Add("logfiles", "--log-files") options.Add("logstats", "-l|--log-stats") options.Add("module", "-m=s+|--module=s+") + options.Add("no_trim", "--no-trim") options.Add("output", "-o=s|--output=s") options.Add("start", "-s=s|--start=s") options.Add("test", "-t|--test") @@ -180,6 +173,8 @@ func newConfig() *config { c.logStats = true case "module": c.modulePaths = append(c.modulePaths, val.([]string)...) + case "no_trim": + c.trim = false case "output": c.outFile = val.(string) case "start": diff --git a/docs/core/faq-and-tips.md b/docs/core/faq-and-tips.md index 9e92809..7f64c56 100644 --- a/docs/core/faq-and-tips.md +++ b/docs/core/faq-and-tips.md @@ -5,7 +5,7 @@ This is a collection of tips, from how to avoid pitfalls to best practices. -Suggestions for new entries may be submitted by [creating a new issue](https://bitbucket.org/tmedwards/tweego/issues?status=new&status=open) at Tweego's [code repository](https://bitbucket.org/tmedwards/tweego/). **NOTE:** Acceptance of submissions ***is not*** guaranteed. +Suggestions for new entries may be submitted by [creating a new issue](https://github.com/tmedwards/tweego/issues) at Tweego's [code repository](https://github.com/tmedwards/tweego). **NOTE:** Acceptance of submissions ***is not*** guaranteed.