jli  Linuxx86_641.10.3v1.10.30b4590a5507d3f3046e5bafc007cacbbfc9b310b^.HypertextLiteralK:͒["4d7B/opt/julia/packages/HypertextLiteral/WjWbW/src/HypertextLiteral.jl Au7{qmOIMK ATricks</opt/julia/packages/HypertextLiteral/WjWbW/src/primitives.jl A7/opt/julia/packages/HypertextLiteral/WjWbW/src/macro.jl A9/opt/julia/packages/HypertextLiteral/WjWbW/src/convert.jl A7/opt/julia/packages/HypertextLiteral/WjWbW/src/style.jl9A8/opt/julia/packages/HypertextLiteral/WjWbW/src/script.jl9A7/opt/julia/packages/HypertextLiteral/WjWbW/src/lexer.jl A9/opt/julia/packages/HypertextLiteral/WjWbW/src/rewrite.jl A CoremуJ5Basemу]J5MainmуJ5ArgToolsBń x(mуF K5 Artifactsmr-V3|mу K5Base64UlD*_mу> K5CRC32c\y.jmуj K5 FileWatchingXzsy`{,zmуh& K5LibdluVW59˗,mу-" K5LoggingT{VhUXM=mуrU" K5MmapP~:xg,Omу|' K5NetworkOptionsC0YW,mуʠ, K5SHAQ<$!<%mу1 K5 Serialization [)*k1mу-G K5Sockets1V$ bdސݗmуYBY K5UnicodeP>I>Nrmуeszo K5 LinearAlgebraSm7̏mуuux K5 OpenBLAS_jll[(Śb6EcQ FmуDux K5libblastrampoline_jllLSۆ }lxӠmу^} K5MarkdownZPn7z`smу/Ed~ K5Printfg^cX׸QDmу;h K5Random_ɢ?\Ymу? K5TarOi>աmу!t, K5DatesEY8pj2 mуX K5FuturebS;3{I xVMmуsD K5InteractiveUtilsWL ~@'ZmуVg K5LibGit2Z[&RPTv3EКRmу8J K5 LibGit2_jll YXg}]$mуD K5 MbedTLS_jllAX 3ȡ_mу- K5 LibSSH2_jlloTZk)߆` tag. ```jldoctest julia> v = "<1 Brown \\\"M&M's\\\"!"; julia> @htl "\$v" <1 Brown "M&M's"! julia> @htl "" ``` This escaping of Julia values to JavaScript values is done with `js` function, which is not exported by default. ```jldoctest julia> v = "<1 Brown \\\"M&M's\\\"!"; julia> @htl "
"
``` There is also a non-standard string literal, `@htl_str` that is not exported. It can be used with dynamically constructed templates. See also: [`@htl`](@ref), [`HypertextLiteral.@htl_str`](@ref) """ module HypertextLiteral @static if VERSION >= v"1.3" using Tricks: static_hasmethod end export @htl, @htl_str include("primitives.jl") # Wrap, Unwrap, EscapeProxy include("macro.jl") # @htl macro and `Result` object include("convert.jl") # runtime conversion of objects include("style.jl") # printing of content within a style tag include("script.jl") # printing of content within a script tag include("lexer.jl") # interpolate string to macro expression include("rewrite.jl") # macro optimizations called by interpolate end </opt/julia/packages/HypertextLiteral/WjWbW/src/primitives.jl """ Reprint(fn) - apply the lambda function when printed """ mutable struct Reprint content::Function end Base.print(io::IO, r::Reprint) = r.content(io) """ Render(data) - printed object shows its text/html """ struct Render{T} content::T end Base.print(io::IO, r::Render) = show(io, MIME"text/html"(), r.content) """ Bypass(data) - printed object passes though EscapeProxy unescaped """ mutable struct Bypass{T} content::T end Base.print(io::IO, x::Bypass) = print(io, x.content) abstract type IOProxy <: IO end """ EscapeProxy(io) - wrap an `io` to perform HTML escaping This is a transparent proxy that performs HTML escaping so that objects that are printed are properly converted into valid HTML values. As a special case, objects wrapped with `Bypass` are not escaped, and bypass the proxy. # Examples ```julia-repl julia> ep = EscapeProxy(stdout); julia> print(ep, "A&B") A&B julia> print(ep, Bypass("")) ``` """ struct EscapeProxy{T<:IO} <: IOProxy io::T end Base.print(ep::EscapeProxy, h::Reprint) = h.content(ep) Base.print(ep::EscapeProxy, w::Render) = show(ep.io, MIME"text/html"(), w.content) Base.print(ep::EscapeProxy, x::Bypass) = print(ep.io, x) function Base.write(ep::EscapeProxy, octet::UInt8) if octet == Int('&') write(ep.io, "&") elseif octet == Int('<') write(ep.io, "<") elseif octet == Int('"') write(ep.io, """) elseif octet == Int('\'') write(ep.io, "'") else write(ep.io, octet) end end function Base.unsafe_write(ep::EscapeProxy, input::Ptr{UInt8}, nbytes::UInt) written = 0 last = cursor = input final = input + nbytes while cursor < final ch = unsafe_load(cursor) if ch == Int('&') written += unsafe_write(ep.io, last, cursor - last) written += unsafe_write(ep.io, pointer("&"), 5) cursor += 1 last = cursor continue end if ch == Int('<') written += unsafe_write(ep.io, last, cursor - last) written += unsafe_write(ep.io, pointer("<"), 4) cursor += 1 last = cursor continue end if ch == Int('\'') written += unsafe_write(ep.io, last, cursor - last) written += unsafe_write(ep.io, pointer("'"), 6) cursor += 1 last = cursor continue end if ch == Int('"') written += unsafe_write(ep.io, last, cursor - last) written += unsafe_write(ep.io, pointer("""), 6) cursor += 1 last = cursor continue end cursor += 1 end if last < final written += unsafe_write(ep.io, last, final - last) end return written end # IO passthrough methods: Base.in(key_value::Pair, io::IOProxy) = in(key_value, io.io) Base.haskey(io::IOProxy, key) = haskey(io.io, key) Base.getindex(io::IOProxy, key) = getindex(io.io, key) Base.get(io::IOProxy, key, default) = get(io.io, key, default) Base.keys(io::IOProxy) = keys(io.io) Base.displaysize(io::IOProxy) = displaysize(io.io) 7/opt/julia/packages/HypertextLiteral/WjWbW/src/macro.jlF""" @htl string-expression Create a `Result` object with string interpolation (`\$`) that uses context-sensitive hypertext escaping. Before Julia 1.6, interpolated string literals, e.g. `\$("Strunk & White")`, are treated as errors since they cannot be reliably detected (see Julia issue #38501). """ macro htl(expr) if typeof(expr) == String return interpolate([expr]) end if !Meta.isexpr(expr, :string) throw(DomainError(expr, "a string literal is required")) end args = expr.args for part in expr.args if Meta.isexpr(part, :(=)) throw(DomainError(part, "assignments are not permitted in an interpolation")) end end if VERSION < v"1.6.0-DEV" # Find cases where we may have an interpolated string literal and # raise an exception (till Julia issue #38501 is addressed) if length(args) == 1 && args[1] isa String throw("interpolated string literals are not supported") end for idx in 2:length(args) if args[idx] isa String && args[idx-1] isa String throw("interpolated string literals are not supported") end end end return interpolate(expr.args) end """ @htl_str -> Result Create a `Result` object with string interpolation (`\$`) that uses context-sensitive hypertext escaping. Unlike the `@htl` macro, this string literal does not include escaping feature [1]. To include `\$` within user content one must write `$`. Observe that `"` and any other HTML ampersand escape sequence can be used as appropriate. In this syntax, interpolation is extended beyond regular Julia strings to handle three additional cases: tuples, named tuples (for attributes), and generators. See Julia #38734 for the feature request so that this could also work within the `@htl` macro syntax. [1] There are also a few edge cases, see `@raw_str` documentation and Julia #22926 for more detail. """ macro htl_str(expr::String) # Essentially this is an ad-hoc scanner of the string, splitting # it by `$` to find interpolated parts and delegating the hard work # to `Meta.parse`, treating everything else as a literal string. args = Any[] start = idx = 1 strlen = lastindex(expr) while true idx = findnext(isequal('$'), expr, start) if idx == nothing chunk = expr[start:strlen] push!(args, expr[start:strlen]) break end push!(args, expr[start:prevind(expr, idx)]) start = nextind(expr, idx) if length(expr) >= start && expr[start] == '$' push!(args, "\$") start += 1 continue end (nest, tail) = Meta.parse(expr, start; greedy=false) if nest == nothing throw("missing expression at $idx: $(expr[start:end])") end if !(expr[start] == '(' || nest isa Symbol) throw(DomainError(nest, "interpolations must be symbols or parenthesized")) end if Meta.isexpr(nest, :(=)) throw(DomainError(nest, "assignments are not permitted in an interpolation")) end if nest isa String # this is an interpolated string literal nest = Expr(:string, nest) end push!(args, nest) start = tail end return interpolate(args) end """ Result(fn) This object wraps a function produced by the `@htl` macro. This function prints a the evaluated to the given `io`. This object is also showable via `"text/html"` so it may be used in an HTML display context. """ struct Result content::Function Result(fn::Function) = new(fn) end Result(ob) = Result(io::IO -> print(io, ob)) function Result(xs...) Result() do io::IO for x in xs print(io, x) end end end Base.show(io::IO, h::Result) = h.content(EscapeProxy(io)) Base.show(io::IO, m::MIME"text/html", h::Result) = h.content(EscapeProxy(io)) Base.show(io::EscapeProxy, h::Result) = h.content(io) Base.show(io::EscapeProxy, m::MIME"text/html", h::Result) = h.content(io) 9/opt/julia/packages/HypertextLiteral/WjWbW/src/convert.jl""" print_value(io, value) This is the default translation of interpolated values within rawtext tags, such as `` occur in the output stream. # Examples ```julia-repl julia> gp = StyleTagProxy(stdout); julia> print(gp, "valid"); valid julia> print(gp, "") ERROR: "Content within a style tag must not contain ``" ``` """ mutable struct StyleTagProxy{T<:IO} <: IOProxy where {T} io::T index::Int StyleTagProxy(io::T) where T = new{T}(io::T, 0) end """ StyleTag(data) This object prints `data` unescaped within a ``") end elseif 12 == index return octet == Int('-') ? 13 : 0 elseif 13 == index if octet == Int('-') throw("Content within a style tag must not contain `