How to use #sym.dash in a private module?

Hi all!
I am trying to call #sym.dash in a private module but I get no character (long dash is desired) as output (no error either). The same code runs no problem if it is in the typ document.

Should I import sym somehow explicitly when calling it from modules?
Is there a workaround to do the desired replacement?

let atoms = "C"
let re = regex("(" + atoms + ")-(" + atoms + ")")
  show re : it => {
    let (atom1, atom2) = it.text.match(re).captures
    [#atom1;#sym.dash;#atom2]
  }

This is text with C-B and C-C

Hello @AMendoza ,

It would really help if you could post your code snippets in code blocks as described in How to post in the Questions category :

If you try to copy and paste the code from your post yourself, you will see that it can’t compile. Could you please try to edit your post and format it accordingly?

2 Likes
#let atoms = "C"
#let re = regex("(" + atoms + ")-(" + atoms + ")")
#show re: it => {
  let (atom1, atom2) = it.text.match(re).captures
  atom1 + sym.dash + atom2
}

C-C

this works fine for me (an en dash shows up). you shouldn’t need to do any stuff with imports; sym is a global module and should be available anywhere. i doubt it, but perhaps you’re shadowing it with a local variable of the same name? in that case, you can try writing std.sym.dash (std is a global module that includes all of the other modules as children)

Thanks @cAtte , yes this works for me fine. The problem is when I put the let and show statements in a private module and try to style a document with it. Thanks for the suggestion on std.sym.dash, I tried it but it doesn´t work either

I saw the edit you did on my post. Thank you for pointing it out!

1 Like

I’m not quite sure what you mean by this breaking when you use a private module. Is the issue related to the show rules not working at all? See Making a Template – Typst Documentation in the tutorial

Perhaps this is a scoping issue. Or wrong template setup.

I suggest you follow and try:

And maybe show more of your code?