Skip to content

Interpolating variables with _ in their name in Markdown strings errors. #43318

Open
@SebastianM-C

Description

@SebastianM-C
Contributor

Hi, I'm encountering the following issue when trying to interpolate a variable with a _ in name in Markdown strings

julia> using Markdown

julia> x_min = 2
2

julia> md"x_min=$x_min"
ERROR: UndefVarError: x not defined
Stacktrace:
 [1] top-level scope
   @ REPL[3]:1

julia> md"x_min=$(x_min)"
ERROR: syntax: invalid syntax (incomplete #<julia: "incomplete: premature end of input">)
Stacktrace:
 [1] top-level scope
   @ REPL[4]:1

I've seen this in 1.6 and also 1.7

julia> versioninfo()
Julia Version 1.7.0
Commit 3bf9d17731 (2021-11-30 12:12 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: AMD Ryzen 7 5800H with Radeon Graphics
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, znver3)

When I asked about this in slack, @jvaverka noted that

md"``x\_{min}=``$(x_min)"

can be used as a workaround and @KristofferC mentioned using the constructor directly instead of the string macro.

cc @toma-vlad

Activity

ForceBru

ForceBru commented on Jan 5, 2023

@ForceBru

Still present in Julia 1.8.2 and 1.9.0-beta2.

julia> using Markdown

julia> md"thing_ $(a_b=6)"
  thing_ 6

julia> md"thing_w $(a_b=6)"
ERROR: syntax: invalid syntax (incomplete #<julia: "incomplete: premature end of input">)
Stacktrace:
 [1] top-level scope
   @ REPL[10]:1

julia> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @simonbyrne@ForceBru@SebastianM-C

        Issue actions

          Interpolating variables with _ in their name in Markdown strings errors. · Issue #43318 · JuliaLang/julia