Skip to content

Commit

Permalink
Merge branch 'multi-close'
Browse files Browse the repository at this point in the history
  • Loading branch information
tlienart committed Oct 30, 2018
2 parents aa45bf2 + a230d84 commit 1f3dd25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/jd_vars.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ function set_vars!(jd_vars::Dict{String, Pair{Any, Tuple}},
if !isempty(assignments)
for (key, assign) assignments
if haskey(jd_vars, key)
# at this point there may still be a comment in the assignment
# string e.g. if it came from @def title = "blah" <!-- ... -->
# so let's strip <!-- and everything after.
# NOTE This is agressive so if it happened that the user wanted # this in a string it would fail (but come on...)
idx = findfirst("<!--", assign)
!isnothing(idx) && (assign = assign[1:prevind(assign, idx[1])])
tmp = Meta.parse("__tmp__ = " * assign)
# try to evaluate the parsed assignment
try
Expand Down
10 changes: 10 additions & 0 deletions test/jd_paths_vars.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,13 @@ end
@test (@test_logs (:error, "I got an error (of type 'DomainError') trying to evaluate '__tmp__ = sqrt(-1)', fix the assignment.") JuDoc.set_vars!(d, ["a"=> "sqrt(-1)"])) == nothing
@test (@test_logs (:warn, "Doc var name 'blah' is unknown. Assignment ignored.") JuDoc.set_vars!(d, ["blah"=>"1"])) == nothing
end


@testset "Def+coms" begin # see #78
st = raw"""
@def title = "blah" <!-- comment -->
etc
"""
(m, jdv) = J.convert_md(st)
@test jdv["title"].first == "blah"
end

0 comments on commit 1f3dd25

Please sign in to comment.