Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to avoid interpolating escaped $s (e.g htl" \$NOinterp ") to match Julia interpolation #30

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/macro.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ macro htl_str(expr::String)
args = Any[]
start = idx = 1
strlen = lastindex(expr)
DOLLAR_NOESCAPE = r"(^\$)|([^\\](\\\\)*\$)"
while true
idx = findnext(isequal('$'), expr, start)
if idx == nothing
chunk = expr[start:strlen]
if match(DOLLAR_NOESCAPE,expr[start:strlen]) === nothing
push!(args, expr[start:strlen])
break
end
idx = last(findnext(DOLLAR_NOESCAPE, expr, start)) # last char of match is "$"
push!(args, expr[start:prevind(expr, idx)])
start = nextind(expr, idx)
if length(expr) >= start && expr[start] == '$'
Expand All @@ -74,7 +74,7 @@ macro htl_str(expr::String)
continue
end
(nest, tail) = Meta.parse(expr, start; greedy=false)
if nest == nothing
if nest === nothing
throw("missing expression at $idx: $(expr[start:end])")
end
if !(expr[start] == '(' || nest isa Symbol)
Expand Down