Skip to content

Commit

Permalink
try spell checker (#160)
Browse files Browse the repository at this point in the history
* try spell checker

* typos

* use varinfo, not whos
  • Loading branch information
jverzani committed Nov 2, 2023
1 parent 50b4f76 commit ba76e63
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 29 deletions.
13 changes: 13 additions & 0 deletions .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
2 changes: 1 addition & 1 deletion docs/src/index.md
Expand Up @@ -291,7 +291,7 @@ tpl = mt"""
</html>
"""
```
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[]
Expand Down
6 changes: 3 additions & 3 deletions src/parse.jl
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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}}";
Expand Down
6 changes: 3 additions & 3 deletions src/tokens.jl
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 2 additions & 7 deletions src/utils.jl
Expand Up @@ -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)
Expand Down Expand Up @@ -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
27 changes: 12 additions & 15 deletions test/mustache_specs.jl
Expand Up @@ -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"])
Expand All @@ -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)
Expand All @@ -77,27 +77,27 @@ 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()
for spec in specs
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
io = open(k, "w")
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
Expand All @@ -110,14 +110,11 @@ function test_partials()
println("""$(t["desc"]): FAILED:\n $out != $expected""")
end
end

for (k,v) in partial
rm(k)
end
end
end
end
end



0 comments on commit ba76e63

Please sign in to comment.