diff --git a/.github/workflows/SpellCheck.yml b/.github/workflows/SpellCheck.yml new file mode 100644 index 0000000..3d62423 --- /dev/null +++ b/.github/workflows/SpellCheck.yml @@ -0,0 +1,13 @@ +name: Spell Check + +on: [pull_request] + +jobs: + typos-check: + name: Spell Check with Typos + runs-on: ubuntu-latest + steps: + - name: Checkout Actions Repository + uses: actions/checkout@v4 + - name: Check spelling + uses: crate-ci/typos@master \ No newline at end of file diff --git a/docs/src/index.md b/docs/src/index.md index 050e319..34b4af9 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -291,7 +291,7 @@ tpl = mt""" """ ``` -This can be used to generate a web page for `whos`-like values: +This can be used to generate a web page for `varinfo`-like values: ```julia _names = String[] diff --git a/src/parse.jl b/src/parse.jl index b474133..20178c8 100644 --- a/src/parse.jl +++ b/src/parse.jl @@ -18,7 +18,7 @@ called). ## Variable substitution. -Like basic string interpolation, variable subsitution can be performed using a non-prefixed tag: +Like basic string interpolation, variable substitution can be performed using a non-prefixed tag: ```jldoctest mustache julia> using Mustache @@ -34,7 +34,7 @@ julia> a(; scissors = "8< ... >8") "Cut: 8< ... >8" ``` -Both using a symbol, as the values to subsitute are passed through keyword arguments. The latter uses triple braces to inhibit the escaping of HTML entities. +Both using a symbol, as the values to substitute are passed through keyword arguments. The latter uses triple braces to inhibit the escaping of HTML entities. Tags can be given special meanings through prefixes. For example, to avoid the HTML escaping an `&` can be used: @@ -115,7 +115,7 @@ julia> a(; countdown = 5:-1:1) ## Partials -Partials allow subsitution. The use of the tag prefex `>` includes either a file or a string and renders it accordingly: +Partials allow substitution. The use of the tag prefix `>` includes either a file or a string and renders it accordingly: ```jldoctest mustache julia> a = mt"{{>:partial}}"; diff --git a/src/tokens.jl b/src/tokens.jl index 573cacc..9285a41 100644 --- a/src/tokens.jl +++ b/src/tokens.jl @@ -183,7 +183,7 @@ end -# stip whitespace at head of io stream +# strip whitespace at head of io stream WHITESPACE = (' ', '\t', '\r') function popfirst!_whitespace(io) @@ -227,7 +227,7 @@ end -## Make the intial set of tokens before nesting +## Make the initial set of tokens before nesting function make_tokens(template, tags) ltag, rtag = tags @@ -334,7 +334,7 @@ function make_tokens(template, tags) # we strip text_value back to \n or beginning text_token.value = replace(text_token.value, r" *$" => "") - # strip whitspace at outset of io and "\n" + # strip whitespace at outset of io and "\n" popfirst!_whitespace(io) if !end_of_road(io) diff --git a/src/utils.jl b/src/utils.jl index a825037..ade28a4 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -14,7 +14,7 @@ curlyRe = r"\s*\}" # & unescape a variable # = set delimiters {{=<% %>=}} will set delimiters to <% %> # ! comments -# | lamda "section" with *evaluated* value +# | lamdda "section" with *evaluated* value tagRe = r"^[#^/<>{&=!|]" function asRegex(txt) @@ -107,11 +107,6 @@ end get_this() = get(task_local_storage(), :__this__, This(())) -## hueristic to avoid loading DataFrames +## heuristic to avoid loading DataFrames ## Once `Tables.jl` support for DataFrames is available, this can be dropped is_dataframe(x) = !isa(x, Dict) && !isa(x, Module) &&!isa(x, Array) && occursin(r"DataFrame", string(typeof(x))) - -## hacky means to evaluate functions -macro gobal(v) - Expr(:global, Expr(:(=), :this, esc(v))) -end diff --git a/test/mustache_specs.jl b/test/mustache_specs.jl index d28eec9..89e662a 100644 --- a/test/mustache_specs.jl +++ b/test/mustache_specs.jl @@ -28,8 +28,8 @@ function write_spec_file(fname) println(io, """ using Mustache using Test -""") - +""") + x = D[fname] println(io, "@testset \" $fname \" begin\n") for (i,t) in enumerate(x["tests"]) @@ -45,20 +45,20 @@ using Test data[k] = v end end - + val = try Mustache.render(t["template"], data) catch err "Failed" end - + expected = t["expected"] expected_ = replace(expected, "\\" => "\\\\") expected_ = replace(expected_, r"\"" => "\\\"") expected_ = "\"\"\"" * expected_ * "\"\"\"" - - + + println(io, "\n\t## $desc") print(io, "tpl = \"\"\"") print(io, tpl) @@ -77,7 +77,7 @@ end # partials are different, as they refer to an external file -# tihs should clean up temp files, but we don't run as part of test suite +# this should clean up temp files, but we don't run as part of test suite # test 7 fails, but I think that one is wrong using Test function test_partials() @@ -85,7 +85,7 @@ function test_partials() for (i,t) in enumerate(D[spec]["tests"]) if haskey(t, "partials") println("""Test $spec / $i""") - + d = t["data"] partial = t["partials"] for (k,v) in partial @@ -93,11 +93,11 @@ function test_partials() write(io, v) close(io) end - + tpl = t["template"] expected = t["expected"] - out = Mustache.render(tpl, d) - + out = Mustache.render(tpl, d) + val = out == expected if val @test val @@ -110,7 +110,7 @@ function test_partials() println("""$(t["desc"]): FAILED:\n $out != $expected""") end end - + for (k,v) in partial rm(k) end @@ -118,6 +118,3 @@ function test_partials() end end end - - -