From 206d492f6d0b2ef24e4c5ef55cfcca479d44873a Mon Sep 17 00:00:00 2001 From: dmullis Date: Fri, 21 Jun 2024 23:39:31 -0700 Subject: [PATCH 1/6] Address complaints from `shellcheck` --- pre-push.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pre-push.sh b/pre-push.sh index d865ec3..e5f6f64 100755 --- a/pre-push.sh +++ b/pre-push.sh @@ -12,14 +12,14 @@ set -x usage () { set +x printf "%s\n\n" "$*" - printf "usage: %s [-w]\n" ${0##*/} - printf "\t%s\t%s\n" "" - printf "\t%s\t%s\n" "$*" + printf "usage: %s [-w]\n" "${0##*/}" + printf "\t%s\n" "" + printf "\t%s\n" "$*" exit 1 } TEST_ARGS= -while getopts hg:iw flag +while getopts h:w flag do case $flag in h) usage "";; @@ -36,7 +36,7 @@ GITHUB_REPOSITORY_OWNER=$USER CURRENT_BRANCH_NAME=$(git-branch --show-current) # If the current branch name contains the GitHub username of the owner of the upstream repo, # assume the intention is to prepare and push a pull request. -if [ $(expr $CURRENT_BRANCH_NAME : ".*$UPSTREAM_OWNER") != 0 ] +if [ $(expr "$CURRENT_BRANCH_NAME" : ".*$UPSTREAM_OWNER") != 0 ] then GITHUB_REPOSITORY_OWNER=$UPSTREAM_OWNER fi From 047f25c2515b4126862707a7ef831b4b3e618e83 Mon Sep 17 00:00:00 2001 From: dmullis Date: Mon, 17 Jun 2024 11:55:58 -0700 Subject: [PATCH 2/6] Expose issue https://github.com/blampe/goat/issues/25 --- README.md | 14 ++++---- examples/small-grids.svg | 78 +++++++++++++++++++++++++++++++++++++++- examples/small-grids.txt | 14 ++++---- 3 files changed, 91 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index d7eff71..16bda42 100644 --- a/README.md +++ b/README.md @@ -176,13 +176,13 @@ Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character, ### Small Grids ``` - ___ ___ .---+---+---+---+---. .---+---+---+---. .---. .---. - ___/ \___/ \ | | | | | | / \ / \ / \ / \ / | +---+ | - / \___/ \___/ +---+---+---+---+---+ +---+---+---+---+ +---+ +---+ - \___/ b \___/ \ | | | b | | | \ / \a/ \b/ \ / \ | +---+ | - / a \___/ \___/ +---+---+---+---+---+ +---+---+---+---+ +---+ b +---+ - \___/ \___/ \ | | a | | | | / \ / \ / \ / \ / | a +---+ | - \___/ \___/ '---+---+---+---+---' '---+---+---+---' '---' '---' + ___ ___ .---+---+---+---+---. .---+---+---+---. .---. .---. .---. .---. .-. .-. 0 + ___/ \___/ \ | | | | | | / \ / \ / \ / \ / | +---+ | | A | | B | | A | | B | 1 + / \___/ \___/ +---+---+---+---+---+ +---+---+---+---+ +---+ +---+ '---' '---' '-' '-' 2 + \___/ b \___/ \ | | | b | | | \ / \a/ \b/ \ / \ | +---+ | .---. .---. .-. .-. 3 + / a \___/ \___/ +---+---+---+---+---+ +---+---+---+---+ +---+ b +---+ | C | | D | | C | | D | 4 + \___/ \___/ \ | | a | | | | / \ / \ / \ / \ / | a +---+ | '---' '---' '-' '-' 5 + \___/ \___/ '---+---+---+---+---' '---+---+---+---' '---' '---' 0123456789012345678901234 6 ``` diff --git a/examples/small-grids.svg b/examples/small-grids.svg index d652a14..c2850bf 100644 --- a/examples/small-grids.svg +++ b/examples/small-grids.svg @@ -1,4 +1,4 @@ - + diff --git a/examples/small-grids.txt b/examples/small-grids.txt index 1e95734..7961b21 100644 --- a/examples/small-grids.txt +++ b/examples/small-grids.txt @@ -1,8 +1,8 @@ - ___ ___ .---+---+---+---+---. .---+---+---+---. .---. .---. - ___/ \___/ \ | | | | | | / \ / \ / \ / \ / | +---+ | - / \___/ \___/ +---+---+---+---+---+ +---+---+---+---+ +---+ +---+ - \___/ b \___/ \ | | | b | | | \ / \a/ \b/ \ / \ | +---+ | - / a \___/ \___/ +---+---+---+---+---+ +---+---+---+---+ +---+ b +---+ - \___/ \___/ \ | | a | | | | / \ / \ / \ / \ / | a +---+ | - \___/ \___/ '---+---+---+---+---' '---+---+---+---' '---' '---' + ___ ___ .---+---+---+---+---. .---+---+---+---. .---. .---. .---. .---. .-. .-. 0 + ___/ \___/ \ | | | | | | / \ / \ / \ / \ / | +---+ | | A | | B | | A | | B | 1 + / \___/ \___/ +---+---+---+---+---+ +---+---+---+---+ +---+ +---+ '---' '---' '-' '-' 2 + \___/ b \___/ \ | | | b | | | \ / \a/ \b/ \ / \ | +---+ | .---. .---. .-. .-. 3 + / a \___/ \___/ +---+---+---+---+---+ +---+---+---+---+ +---+ b +---+ | C | | D | | C | | D | 4 + \___/ \___/ \ | | a | | | | / \ / \ / \ / \ / | a +---+ | '---' '---' '-' '-' 5 + \___/ \___/ '---+---+---+---+---' '---+---+---+---' '---' '---' 0123456789012345678901234 6 From 121171bf3b7fc1b8a0ab03f8355c4b8a0d6eae71 Mon Sep 17 00:00:00 2001 From: dmullis Date: Mon, 17 Jun 2024 11:57:58 -0700 Subject: [PATCH 3/6] If browser is in dark-mode, ask for a dark background As shown in Firefox by examples/*.svg. --- examples/arrows.svg | 1 + examples/big-grids.svg | 1 + examples/big-shapes.svg | 1 + examples/circle.svg | 1 + examples/circuits.svg | 1 + examples/complicated.svg | 1 + examples/dot-grids.svg | 1 + examples/edge-cases.svg | 1 + examples/flow-chart.svg | 1 + examples/graphics.svg | 1 + examples/icons.svg | 1 + examples/large-nodes.svg | 1 + examples/line-decorations.svg | 1 + examples/line-ends.svg | 1 + examples/overlaps.svg | 1 + examples/regression.svg | 1 + examples/small-grids.svg | 1 + examples/small-nodes.svg | 1 + examples/small-shapes.svg | 1 + examples/tiny-grids.svg | 1 + examples/trees.svg | 1 + examples/unicode.svg | 1 + goat.svg | 1 + svg.go | 1 + trees.mid-blue.svg | 1 + 25 files changed, 25 insertions(+) diff --git a/examples/arrows.svg b/examples/arrows.svg index f0fcafa..69f9ce9 100644 --- a/examples/arrows.svg +++ b/examples/arrows.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/big-grids.svg b/examples/big-grids.svg index fb32bfd..4a07d1e 100644 --- a/examples/big-grids.svg +++ b/examples/big-grids.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/big-shapes.svg b/examples/big-shapes.svg index 4a54725..a7ed0d5 100644 --- a/examples/big-shapes.svg +++ b/examples/big-shapes.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/circle.svg b/examples/circle.svg index 54d61df..09ea07b 100644 --- a/examples/circle.svg +++ b/examples/circle.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/circuits.svg b/examples/circuits.svg index e1ccde2..9c9b0a8 100644 --- a/examples/circuits.svg +++ b/examples/circuits.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/complicated.svg b/examples/complicated.svg index 5ebca64..20b5498 100644 --- a/examples/complicated.svg +++ b/examples/complicated.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/dot-grids.svg b/examples/dot-grids.svg index 9648aaf..6c46cc7 100644 --- a/examples/dot-grids.svg +++ b/examples/dot-grids.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/edge-cases.svg b/examples/edge-cases.svg index df810d6..aa8370c 100644 --- a/examples/edge-cases.svg +++ b/examples/edge-cases.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/flow-chart.svg b/examples/flow-chart.svg index 4a84530..6f575e7 100644 --- a/examples/flow-chart.svg +++ b/examples/flow-chart.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/graphics.svg b/examples/graphics.svg index e2ee3ba..eb36223 100644 --- a/examples/graphics.svg +++ b/examples/graphics.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/icons.svg b/examples/icons.svg index dd32e66..97f002f 100644 --- a/examples/icons.svg +++ b/examples/icons.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/large-nodes.svg b/examples/large-nodes.svg index 7b7c174..592c524 100644 --- a/examples/large-nodes.svg +++ b/examples/large-nodes.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/line-decorations.svg b/examples/line-decorations.svg index 8275285..3172ecb 100644 --- a/examples/line-decorations.svg +++ b/examples/line-decorations.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/line-ends.svg b/examples/line-ends.svg index 5552eb6..85dd638 100644 --- a/examples/line-ends.svg +++ b/examples/line-ends.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/overlaps.svg b/examples/overlaps.svg index c28f1aa..2db48fc 100644 --- a/examples/overlaps.svg +++ b/examples/overlaps.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/regression.svg b/examples/regression.svg index 5d26ed7..f729e42 100644 --- a/examples/regression.svg +++ b/examples/regression.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/small-grids.svg b/examples/small-grids.svg index c2850bf..ceb2e73 100644 --- a/examples/small-grids.svg +++ b/examples/small-grids.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/small-nodes.svg b/examples/small-nodes.svg index 3ffda2d..6d2cadc 100644 --- a/examples/small-nodes.svg +++ b/examples/small-nodes.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/small-shapes.svg b/examples/small-shapes.svg index ef37944..9a6fe29 100644 --- a/examples/small-shapes.svg +++ b/examples/small-shapes.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/tiny-grids.svg b/examples/tiny-grids.svg index db3ef85..78cc486 100644 --- a/examples/tiny-grids.svg +++ b/examples/tiny-grids.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/trees.svg b/examples/trees.svg index f1d8101..c5c3a78 100644 --- a/examples/trees.svg +++ b/examples/trees.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/examples/unicode.svg b/examples/unicode.svg index 360b84f..a9619c4 100644 --- a/examples/unicode.svg +++ b/examples/unicode.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #FFFFFF; } } diff --git a/goat.svg b/goat.svg index ee43859..7fdc72a 100644 --- a/goat.svg +++ b/goat.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #EEF; } } diff --git a/svg.go b/svg.go index 7a416b3..559d377 100644 --- a/svg.go +++ b/svg.go @@ -21,6 +21,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: %s; } } diff --git a/trees.mid-blue.svg b/trees.mid-blue.svg index a98875e..118fef6 100644 --- a/trees.mid-blue.svg +++ b/trees.mid-blue.svg @@ -5,6 +5,7 @@ svg { } @media (prefers-color-scheme: dark) { svg { + color-scheme: dark; /* ask the browser for a dark background */ color: #2F81F7; } } From de13b04d6a5960ce81902c16854fa50b34d35463 Mon Sep 17 00:00:00 2001 From: dmullis Date: Mon, 17 Jun 2024 12:05:21 -0700 Subject: [PATCH 4/6] Clean up regression test --- examples_test.go | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/examples_test.go b/examples_test.go index daec3cc..1ac709a 100644 --- a/examples_test.go +++ b/examples_test.go @@ -14,7 +14,7 @@ import ( ) var ( - write = flag.Bool("write", false, "write examples to disk") + write = flag.Bool("write", false, "write examples to disk") // XX rename: more descriptive svgColorLightScheme = flag.String("svg-color-light-scheme", "#000000", `See help for cmd/goat`) svgColorDarkScheme = flag.String("svg-color-dark-scheme", "#FFFFFF", @@ -49,12 +49,12 @@ func TestExamples(t *testing.T) { } var buff *bytes.Buffer - + if write == nil { + t.Logf("Verifying output of current build against earlier .svg files in examples/.\n") + } + var failures int for _, name := range filenames { in := getIn(name) - if testing.Verbose() { - t.Logf("\tprocessing %s\n", name) - } var out io.WriteCloser if *write { out = getOut(name) @@ -88,17 +88,25 @@ func TestExamples(t *testing.T) { // source is fresher than the .svg? t.Log(buff.Len(), len(golden)) t.Logf("Content mismatch for %s", toSVGFilename(name)) - t.Logf("%s %s:\n\t%s\nConsider:\n\t%s", - "Option -write not set, and Error reading", - name, - err.Error(), - "$ go test -run TestExamples -v -args -write") - t.FailNow() + failures++ + } else { + if testing.Verbose() { + t.Logf("Verified contents of SVG file %s\n", + toSVGFilename(name)) + } } in.Close() out.Close() } } + if failures > 0 { + t.Logf(`Failed to verify contents of %d .svg files +Consider: + %s`, + failures, + "$ go test -run TestExamples -v -args -write") + t.FailNow() + } } func BenchmarkComplicated(b *testing.B) { @@ -132,6 +140,7 @@ func getOutString(filename string) (string, error) { if err != nil { return "", err } + // XX Why are there RETURN characters in contents of the .SVG files? b = bytes.ReplaceAll(b, []byte("\r\n"), []byte("\n")) return string(b), nil } From 262647691a80c464a9df84b6cc50e1e1c86ebce7 Mon Sep 17 00:00:00 2001 From: dmullis Date: Mon, 17 Jun 2024 12:58:33 -0700 Subject: [PATCH 5/6] Add more regression test/examples Surface examples/*.svg files in git-status. --- .gitignore | 4 +- examples/block-characters.svg | 55 + examples/block-characters.txt | 3 + examples/debug.svg | 73 ++ examples/debug.txt | 34 + examples/half-step-bugs.svg | 69 + examples/half-step-bugs.txt | 12 + examples/hollow-circle.svg | 150 +++ examples/hollow-circle.txt | 50 + examples/incompatibilities.svg | 355 ++++++ examples/incompatibilities.txt | 31 + examples/radius16circle.svg | 33 + examples/radius16circle.txt | 9 + examples/standard-width.svg | 1987 +++++++++++++++++++++++++++++ examples/standard-width.txt | 106 ++ examples/tiny-grids-irregular.svg | 125 ++ examples/tiny-grids-irregular.txt | 19 + 17 files changed, 3114 insertions(+), 1 deletion(-) create mode 100644 examples/block-characters.svg create mode 100644 examples/block-characters.txt create mode 100644 examples/debug.svg create mode 100644 examples/debug.txt create mode 100644 examples/half-step-bugs.svg create mode 100644 examples/half-step-bugs.txt create mode 100644 examples/hollow-circle.svg create mode 100644 examples/hollow-circle.txt create mode 100644 examples/incompatibilities.svg create mode 100644 examples/incompatibilities.txt create mode 100644 examples/radius16circle.svg create mode 100644 examples/radius16circle.txt create mode 100644 examples/standard-width.svg create mode 100644 examples/standard-width.txt create mode 100644 examples/tiny-grids-irregular.svg create mode 100644 examples/tiny-grids-irregular.txt diff --git a/.gitignore b/.gitignore index d9e18a4..5a81918 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,9 @@ .DS_Store vendor -examples/*.svg + +# Hiding the SVG output files introduces friction when adding a new TXT,SVG pair to the test suite. +# examples/*.svg cmd/tmpl-expand/tmpl-expand cmd/goat/goat diff --git a/examples/block-characters.svg b/examples/block-characters.svg new file mode 100644 index 0000000..56c67d0 --- /dev/null +++ b/examples/block-characters.svg @@ -0,0 +1,55 @@ + + + + +S +p +e +c +i +a +l +c +a +s +e +s +s +u +p +p +o +r +t +e +d +b +y +M +a +r +k +d +e +e +p +: + + diff --git a/examples/block-characters.txt b/examples/block-characters.txt new file mode 100644 index 0000000..27a2820 --- /dev/null +++ b/examples/block-characters.txt @@ -0,0 +1,3 @@ +Special cases supported by Markdeep: + +▉ ▓ ▒ ░ diff --git a/examples/debug.svg b/examples/debug.svg new file mode 100644 index 0000000..3184e56 --- /dev/null +++ b/examples/debug.svg @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +a +( +) +a +( +) +( +) +( +) + + diff --git a/examples/debug.txt b/examples/debug.txt new file mode 100644 index 0000000..d9bdf2a --- /dev/null +++ b/examples/debug.txt @@ -0,0 +1,34 @@ + + ( + + ( + + ) + + ( + + a() + + a() + + () + + () + + || + --))-- + || + + || + --((-- + || + + | | +--)-)-- + | | + + | | +--(-(-- + | | + +o- diff --git a/examples/half-step-bugs.svg b/examples/half-step-bugs.svg new file mode 100644 index 0000000..1b4a124 --- /dev/null +++ b/examples/half-step-bugs.svg @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + +d +o +u +b +l +e +- +d +r +a +w +g +a +p +a +t +a +b +u +t +t +i +n +g +l +i +n +e +e +n +d +s + + diff --git a/examples/half-step-bugs.txt b/examples/half-step-bugs.txt new file mode 100644 index 0000000..1c9abb9 --- /dev/null +++ b/examples/half-step-bugs.txt @@ -0,0 +1,12 @@ + + _ +|_| + +double-draw + + + _ +| | +|_| + +gap at abutting line ends diff --git a/examples/hollow-circle.svg b/examples/hollow-circle.svg new file mode 100644 index 0000000..8e2f285 --- /dev/null +++ b/examples/hollow-circle.svg @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +1 +2 +3 +4 +5 +6 +x +x +x +x +x +x +o +o +o +o +* +* +* +* + + diff --git a/examples/hollow-circle.txt b/examples/hollow-circle.txt new file mode 100644 index 0000000..f821866 --- /dev/null +++ b/examples/hollow-circle.txt @@ -0,0 +1,50 @@ +-o + * * o o + 0123456 + + + +->o o<- + +-> x x <- + xxxx + + <---> + <---> + + o<--->o + o<--->o + + + <--> + <--> + + o<-->o + o<-->o + + + <-> < > + <-> < > + + o<->o o< >o + o<->o o< >o + + + <> + <> + + o<>o + o<>o + + +oo +^^ +|| +vv +oo + +** -- +^^ +|| +vv +** -- diff --git a/examples/incompatibilities.svg b/examples/incompatibilities.svg new file mode 100644 index 0000000..31ceaa3 --- /dev/null +++ b/examples/incompatibilities.svg @@ -0,0 +1,355 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +I +n +p +u +t +T +X +T +p +a +t +t +e +r +n +s +s +u +p +p +o +r +t +e +d +b +y +M +a +r +k +D +e +e +p +, +b +u +t +n +o +t +b +y +G +o +a +t +. +H +o +l +l +o +w +c +i +r +c +l +e +s +R +e +n +d +e +r +e +d +t +o +S +V +G +a +s +a +" +h +o +l +l +o +w +" +c +i +r +c +l +e +, +t +r +a +n +s +p +a +r +e +n +t +t +o +b +a +c +k +g +r +o +u +n +d +. +G +o +a +t +- +s +p +e +c +i +f +i +c +a +l +t +e +r +n +a +t +i +v +e +r +e +n +d +e +r +i +n +g +o +p +t +i +o +n +s +a +r +e +a +v +a +i +l +a +b +l +e +o +n +t +h +e +c +o +m +m +a +n +d +l +i +n +e +. +A +l +t +e +r +n +a +t +i +v +e +T +X +T +p +a +t +t +e +r +n +s +t +o +i +n +d +i +c +a +t +e +d +o +u +b +l +e +- +w +i +d +t +h +c +i +r +c +l +e +s +: +G +o +a +t +a +n +d +M +a +r +k +D +e +e +p +M +a +r +k +D +e +e +p +o +n +l +y +M +a +r +k +D +e +e +p +o +n +l +y +P +a +r +a +l +l +e +l +a +r +c +s +. +. +) +) +M +a +r +k +D +e +e +p +o +n +l +y + + diff --git a/examples/incompatibilities.txt b/examples/incompatibilities.txt new file mode 100644 index 0000000..a5828bd --- /dev/null +++ b/examples/incompatibilities.txt @@ -0,0 +1,31 @@ +Input TXT patterns supported by MarkDeep, but not by Goat. + + +Hollow circles + + o + + Rendered to SVG as a "hollow" circle, transparent to background. + Goat-specific alternative rendering options are available on the command line. + + +Alternative TXT patterns to indicate double-width circles: + + .-. + | | Goat and MarkDeep + '-' + + +-+ + + + MarkDeep only + +-+ + + +-+ + | | MarkDeep only + +-+ + + +Parallel arcs + + _..---. + __)) )- MarkDeep only + ''---' diff --git a/examples/radius16circle.svg b/examples/radius16circle.svg new file mode 100644 index 0000000..1996512 --- /dev/null +++ b/examples/radius16circle.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + diff --git a/examples/radius16circle.txt b/examples/radius16circle.txt new file mode 100644 index 0000000..99747b9 --- /dev/null +++ b/examples/radius16circle.txt @@ -0,0 +1,9 @@ + -+ + + + + + + -+ + + +-+ + + + + +-+ diff --git a/examples/standard-width.svg b/examples/standard-width.svg new file mode 100644 index 0000000..4fbfc23 --- /dev/null +++ b/examples/standard-width.svg @@ -0,0 +1,1987 @@ + + + + + + + + + + + + + + + +U +N +I +C +O +D +E +c +h +a +r +a +c +t +e +r +s +X +X +X +X +F +o +l +d +a +l +l +t +h +i +s +i +n +t +o +e +x +a +m +p +l +e +s +/ +u +n +i +c +o +d +e +. +t +x +t +j +o +i +n +t +s +: +* +o +r +e +s +e +r +v +e +d +: +v +^ +) +( +o +r +d +i +n +a +r +y +, +A +S +C +I +I +: +a +b +c +d +e +f +g +h +i +j +k +l +m +n +o +p +q +r +s +t +u +v +w +x +y +z +A +B +C +D +E +F +G +H +I +J +K +L +M +N +O +P +Q +R +S +T +U +V +W +X +Y +Z +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0 +1 +2 +3 +4 +5 +o +r +d +i +n +a +r +y +, +U +n +i +c +o +d +e +: + + + + +· +¤ +¨ +´ +« +» +¯ +  +¦ +­ +× +÷ +ø +Ø +± +¡ + + + + + + + + + + + +B +O +X +D +R +A +W +I +N +G +S +L +I +G +H +T +. +. +. + + + + + + + + + + + + + + + + + + + + + + +B +O +X +D +R +A +W +I +N +G +S +L +I +G +H +T +D +O +U +B +L +E +. +. +. + + + + + + + + + + + + + + + + + + + + + + +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0 +N +o +n +- +s +t +a +n +d +a +r +d +d +i +m +e +n +s +i +o +n +s +i +n +f +o +n +t +s +: +L +i +b +e +r +a +t +i +o +n +M +o +n +o +N +o +t +o +M +o +n +o +R +e +g +u +l +a +r + + + + + + + + + + + +¹ +² +³ + + + + + + +α +β +γ +δ +ε +ζ +η +θ +ι +κ +λ +μ +ν +ξ +ο +π +ρ +ς +σ +τ +υ +φ +χ +ψ +ω +N +o +n +- +s +t +a +n +d +a +r +d +d +i +m +e +n +s +i +o +n +s +i +n +f +o +n +t +s +: +D +e +j +a +V +u +S +a +n +s +M +o +n +o +F +r +e +e +M +o +n +o +U +b +u +n +t +u +M +o +n +o +M +o +n +o +S +p +a +c +e + + + + + + + + + + + + + + + + + + + + + + +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0 +1 +2 +3 +4 +5 +N +o +n +- +s +t +a +n +d +a +r +d +w +e +i +g +h +t +u +n +u +s +a +b +l +e +? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0 +A +L +T +E +R +N +A +T +I +V +E +T +O +O +L +S +# +# +# +N +o +n +- +g +r +a +p +h +i +c +a +l +A +S +C +I +I +s +o +u +r +c +e +: +M +e +r +m +a +i +d +, +P +i +k +c +h +r +. +. +. +# +# +# +G +r +a +p +h +i +c +a +l +A +S +C +I +I +s +o +u +r +c +e +: +A +s +c +i +i +f +l +o +w +a +n +d +T +e +x +t +i +k +U +n +l +i +k +e +G +o +a +t +, +A +s +c +i +i +f +l +o +w +a +n +d +T +e +x +t +i +k +o +f +f +e +r +o +n +l +i +n +e +g +r +a +p +h +i +c +a +l +e +d +i +t +o +r +s +. +D +i +a +g +r +a +m +s +a +r +e +e +x +p +o +r +t +e +d +f +r +o +m +t +h +e +b +r +o +w +s +e +r +s +e +s +s +i +o +n +a +s +g +r +a +p +h +i +c +a +l +U +N +I +C +O +D +E +o +r +A +S +C +I +I +. +F +o +l +l +o +w +- +o +n +m +a +i +n +t +e +n +a +n +c +e +o +f +t +h +e +d +i +a +g +r +a +m +s +o +f +c +o +u +r +s +e +r +e +q +u +i +r +e +s +i +m +p +o +r +t +f +r +o +m +a +p +r +o +j +e +c +t +' +s +c +o +d +e +/ +d +o +c +a +r +c +h +i +v +e +. +A +s +c +i +i +f +l +o +w +a +c +c +o +m +p +l +i +s +h +e +s +t +h +i +s +b +y +C +t +l +- +V +" +p +a +s +t +e +" +. +T +e +x +t +i +k +h +o +w +e +v +e +r +h +a +s +n +o +i +m +p +o +r +t +m +e +t +h +o +d +. +( +h +t +t +p +s +: +/ +/ +g +i +t +h +u +b +. +c +o +m +/ +a +s +t +a +s +h +o +v +/ +t +i +x +i +/ +i +s +s +u +e +s +/ +1 +5 +) +G +o +a +t +b +u +t +n +o +t +A +s +c +i +i +f +l +o +w +n +o +r +T +e +x +t +i +k +c +o +n +t +a +i +n +s +u +p +p +o +r +t +f +o +r +: +1 +. +R +e +n +d +e +r +i +n +g +t +o +a +s +m +o +o +t +h +e +d +S +V +G +o +u +t +p +u +t +. +2 +. +D +i +a +g +o +n +a +l +l +i +n +e +s +. +3 +. +R +o +u +n +d +e +d +c +o +r +n +e +r +s +. +A +s +c +i +i +f +l +o +w +. +c +o +m +( +b +u +t +n +o +t +G +o +a +t +) +e +x +p +o +r +t +s +d +r +a +w +n +l +i +n +e +s +a +s +t +h +e +g +r +a +p +h +i +c +a +l +U +n +i +c +o +d +e +c +h +a +r +a +c +t +e +r +s +B +O +X +D +R +A +W +I +N +G +S +L +I +G +H +T +. +. +. +T +h +e +s +e +h +a +v +e +w +i +d +t +h +s +e +q +u +a +l +t +o +t +h +o +s +e +o +f +s +i +m +p +l +e +A +S +C +I +I +c +h +a +r +a +c +t +e +r +s +i +n +t +h +e +s +t +a +n +d +a +r +d +U +n +i +x +s +y +s +t +e +m +f +o +n +t +s +. +- +h +t +t +p +s +: +/ +/ +w +w +w +. +f +r +e +e +d +e +s +k +t +o +p +. +o +r +g +/ +w +i +k +i +/ +S +o +f +t +w +a +r +e +/ +f +o +n +t +c +o +n +f +i +g +/ +- +$ +a +p +t +s +h +o +w +f +o +n +t +c +o +n +f +i +g +U +n +f +o +r +t +u +n +a +t +e +l +y +, +A +s +c +i +i +f +l +o +w +e +x +p +o +r +t +s +c +e +r +t +a +i +n +a +r +r +o +w +h +e +a +d +s +a +s +U +n +i +c +o +d +e +c +h +a +r +a +c +t +e +r +s +e +. +g +. +" +B +L +A +C +K +U +P +- +P +O +I +N +T +I +N +G +T +R +I +A +N +G +L +E +" +h +a +v +i +n +g +n +o +n +- +s +t +a +n +d +a +r +d +w +i +d +t +h +i +n +t +h +e +p +o +p +u +l +a +r +G +N +U +/ +L +i +n +u +x +s +y +s +t +e +m +f +o +n +t +" +U +b +u +n +t +u +M +o +n +o +R +e +g +u +l +a +r +" +. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +s +d +o +k +p +o +a +s +j +k +f +p +o + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0 +" +B +O +X +D +R +A +W +I +N +G +S +L +I +G +H +T +D +O +U +B +L +E +. +. +. +" +a +l +s +o +h +a +v +e +s +t +a +n +d +a +r +d +w +i +d +t +h +s +( +n +o +t +u +s +e +d +b +y +A +s +c +i +i +f +l +o +w +) +. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +T +e +x +t +i +k +. +c +o +m +h +a +s +m +o +r +e +l +i +m +i +t +e +d +d +r +a +w +i +n +g +c +h +a +r +a +c +t +e +r +s +, +b +u +t +d +o +e +s +m +a +i +n +t +a +i +n +m +u +l +t +i +- +c +e +l +l +g +e +o +m +e +t +r +y +s +t +r +u +c +t +u +r +e +w +i +t +h +i +n +i +t +s +e +d +i +t +o +r +. + + diff --git a/examples/standard-width.txt b/examples/standard-width.txt new file mode 100644 index 0000000..5c982be --- /dev/null +++ b/examples/standard-width.txt @@ -0,0 +1,106 @@ +UNICODE characters XXXX Fold all this into examples/unicode.txt +--- + +joints: + .'+*o + +reserved: + -_ |v^><*+/\)( + +ordinary, ASCII: +abcdefghijklmnopqrstuvwxyz +ABCDEFGHIJKLMNOPQRSTUVWXYZ +0123456789012345 + +ordinary, Unicode: + +┌─┬┐·¤¨´«»¯ ¦­ +×÷øØ ±¡ +┘┘┘┘┘┘┘┘┘┘┘ BOX DRAWINGS LIGHT ... +│││││││││││ +║║║║║║║║║║║ BOX DRAWINGS LIGHT DOUBLE ... +╚╚╚╚╚╚╚╚╚╚╚ +═══════════ +01234567890 + + +Non-standard dimensions in fonts: + Liberation Mono + Noto Mono Regular +₀₁₂₃₄₅₆₇₈₉ +⁰¹²³⁴⁵⁶⁷⁸⁹ +αβγδεζηθικλμνξοπρςστυφχψω + + +Non-standard dimensions in fonts: + DejaVu Sans Mono + FreeMono + Ubuntu Mono + MonoSpace +⎔ +⬣ +✹ +╱ +╲╲╲╲╲╲╲╲╲ +╳╳╳╳╳╳╳╳╳ +0123456789012345 + +Non-standard weight -- unusable? +╴╴╴╴╴╴╴╴╴╴ +╶╶╶╶╶╶╶╶╶╶ +╵╵╵╵╵╵╵╵╵╵ +╱╱╱╱╱╱╱╱╱╱ +01234567890 + + +ALTERNATIVE TOOLS +--- +### Non-graphical ASCII source: Mermaid, Pikchr ... + +### Graphical ASCII source: Asciiflow and Textik +Unlike Goat, Asciiflow and Textik offer online graphical editors. +Diagrams are exported from the browser session as graphical UNICODE or ASCII. + +Follow-on maintenance of the diagrams of course requires import from a project's code/doc archive. +Asciiflow accomplishes this by Ctl-V "paste". +Textik however has no import method. (https://github.com/astashov/tixi/issues/15) + +Goat but not Asciiflow nor Textik contain support for: + 1. Rendering to a smoothed SVG output. + 2. Diagonal lines. + 3. Rounded corners. + +Asciiflow.com (but not Goat) exports drawn lines as the graphical Unicode +characters BOX DRAWINGS LIGHT ... + +These have widths equal to those of simple ASCII characters in the standard Unix system fonts. + - https://www.freedesktop.org/wiki/Software/fontconfig/ + - $ apt show fontconfig + +Unfortunately, Asciiflow exports certain arrowheads as Unicode characters e.g. "BLACK UP-POINTING + TRIANGLE" having non-standard width in the popular GNU/Linux system font "Ubuntu Mono Regular". + + ┌───────────────────────► + │ + │ + ┌─────┼──────────────┐ ▲ + │ │ │ │ + └─────┼──────────────┘ │ + │ │ + │ │ +┌──────────────────┐ │ +│ │ │ +│ sdokpoasjkfpo ├─────────────────────────────────────────┘ +└──────────────────┘ + +▲▲▲▲▲▲▲ +01234567890 + +"BOX DRAWINGS LIGHT DOUBLE ..." also have standard widths (not used by Asciiflow). + +║║║║║║║║║║║ +╚╚╚╚╚╚╚╚╚╚╚ +═══════════ + +Textik.com has more limited drawing characters, but does maintain multi-cell +geometry structure within its editor. diff --git a/examples/tiny-grids-irregular.svg b/examples/tiny-grids-irregular.svg new file mode 100644 index 0000000..cf77a4e --- /dev/null +++ b/examples/tiny-grids-irregular.svg @@ -0,0 +1,125 @@ + + + + + +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0 +1 +2 +3 +4 +5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0 +1 +2 +3 +4 +5 + + diff --git a/examples/tiny-grids-irregular.txt b/examples/tiny-grids-irregular.txt new file mode 100644 index 0000000..15e47da --- /dev/null +++ b/examples/tiny-grids-irregular.txt @@ -0,0 +1,19 @@ +0123456789012345 + ▉▉ ▉▉ ▉▉ | + ▉▉ ▉▉ | + ▉▉ ▉▉ ▉▉ | + ▉▉ ▉▉ | + ▉▉ ▉▉ ▉▉ | + | + ⬢ ⬡ ⬡ | + ⬢ ⬢ ⬡ ⬡ | + ⬢ ⬢ ⬢ ⬡ ⬡ | + ⬡ ⬡ ⬡ ⬡ | + ⬡ ⬡ ⬡ | + | + ⁚⁚⁚⁚⁚⁚⁚⁚⁚⁚ | + ⁚⁚⁚⁚⁚⁚⁚⁚⁚⁚ | + ⁚⁚⁚⁚⁚⁚⁚⁚⁚⁚ | + ⁚⁚⁚⁚⁚⁚⁚⁚⁚⁚ | + ⁚⁚⁚⁚⁚⁚⁚⁚⁚⁚ | +0123456789012345 From f0ab5ffbc9139db938f46e4e8676c90489ed8dde Mon Sep 17 00:00:00 2001 From: dmullis Date: Tue, 18 Jun 2024 21:38:15 -0700 Subject: [PATCH 6/6] Regression testing: Clarify source code and CLI text Bump required Go version to 1.21 for access to functions min() and max(). --- examples_test.go | 50 ++++++++++++++++++++++++++++++------------------ go.mod | 2 +- pre-push.sh | 2 ++ 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/examples_test.go b/examples_test.go index 1ac709a..c0a0cff 100644 --- a/examples_test.go +++ b/examples_test.go @@ -14,7 +14,8 @@ import ( ) var ( - write = flag.Bool("write", false, "write examples to disk") // XX rename: more descriptive + regenerate = flag.Bool("regenerate", + false, "regenerate reference SVG output files") svgColorLightScheme = flag.String("svg-color-light-scheme", "#000000", `See help for cmd/goat`) svgColorDarkScheme = flag.String("svg-color-dark-scheme", "#FFFFFF", @@ -49,14 +50,14 @@ func TestExamples(t *testing.T) { } var buff *bytes.Buffer - if write == nil { - t.Logf("Verifying output of current build against earlier .svg files in examples/.\n") + if regenerate == nil { + t.Logf("Verifying equality of current SVG with examples/ references.\n") } var failures int for _, name := range filenames { in := getIn(name) var out io.WriteCloser - if *write { + if *regenerate { out = getOut(name) } else { if buff == nil { @@ -83,15 +84,26 @@ func TestExamples(t *testing.T) { if err != nil { t.Log(err) } - if buff.String() != golden { - // XX Skip this if the modification timestamp of the .txt file - // source is fresher than the .svg? - t.Log(buff.Len(), len(golden)) - t.Logf("Content mismatch for %s", toSVGFilename(name)) + if newStr := buff.String(); newStr != golden { + // Skip complaint if the modification timestamp of the .txt file + // source is fresher than that of the .svg? + // => NO, Any .txt difference might be an editing mistake. + + t.Logf("Content mismatch for %s. Length was %d, expected %d", + toSVGFilename(name), buff.Len(), len(golden)) + for i:=0; iREADME.md $(git-ls-files examples | tac) + +printf "\nTo install in local GOPATH:\n\t%s\n" "go install ./cmd/goat"