How to disable typographical substitutions?

If #set text(lang: "...") is not used, lang defaults to en, which means, for example, that "straight" quotation marks are converted to “curly” ones. But is it possible to simply disable all the typographical substitutions, so that, for example, "straight" quotation marks will stay straight and three consequtive hyphens won’t be converted to em dash? Of course, I don’t mean to put the whole text inside the raw block.

I tried #set text(lang: "none"), but this produces an error.

#set text(lang: "none")

lorem "ipsum" dolor *sit* amet, foo --- bar.

Here, the word “sit” should be bold, but quotation marks and hyphens should be preserved as-is.

I don’t quite understand why turning * into bold wouldn’t be a “typographical substitution”. You claim you don’t want raw, but that’s basically what you’re describing.

Well, I tend to agree. Then the question can be asked differently: How to disable all the regional-specific typographical substitutions?

I don’t think there’s a simple way to turn this off completely, but this works for a subset of what you described:

#show smartquote: "\""
#show sym.dash: "--"
#show sym.dash.em: "---"

foo -- "bar" --- baz

Could it be implemented? "none" could probably be added as a language, but then the question is what that language’s behavior should be. Is *strong* regional or not? This would have to be decided on the Typst level. In the end it’s probably best if you make those decisions yourself, using a set of show rules like the ones shown.

1 Like

This returns us to my comment above in which I replied to @Enivex:

Enivex: I don’t quite understand why turning * into bold wouldn’t be a “typographical substitution”. You claim you don’t want raw, but that’s basically what you’re describing.

Me: Well, I tend to agree.

Now I see that my reply to him was not really correct. We can put literal em dash or literal curly quotation marks in raw Typst. But we cannot put literal bold text there. That is to say, the demarcation line can be put between:

  • things that we can represent in raw Typst using Unicode symbols. That is, if we use lang: "none", no need to convert --- to em dash because we can put literal em dash if we really need it somewhere. That is, if we use lang: "none", then --- should be preserved as-is.
  • and things that we cannot represent in raw Typst, such as bold ot italic text, for example. These things should be converted nevertheless.

That is, I don’t mean regional-specific substitutions. Sorry.

I think if we are talking specifically about substitutions, then smart quotes should be the only one that exists. There are some other regional-specific stuff that are used in different things:

But it isn’t really the kind of substitution you are talking about.

To disable smart quotes use this:

#set smartquote(enabled: false)
"some "inner" text"

image

Since different length dashes aren’t a regional substitution, there is nothing to add here. But if you really want to disable the default substitution behavior, you can use @SillyFreak’s solution:

#show sym.dash.en: "--"
#show sym.dash.em: "---"
a - -- --- b

image

About bold and italic. Since these functions have a dedicated syntax, you can’t insert verbatim symbols that represent the dedicated syntax. For them, you have to use escaping with a backslash (\):

\*not bold\*
\_not italic\_
my\@email // small bonus

image

2 Likes

You can also interpolate a string, though in this case, you’ll have to escape the quotes:

#"a \"b\" c -- d --- e"
1 Like

Hey @jsx97, I’ve updated your post title to fit our guidelines: How to post in the Questions category

Please make sure your title is a question you’d ask to a friend about Typst. :slight_smile:

1 Like

I don’t think it’s a string interpolation, it’s just a string (that can’t handle special markup syntax). It’s the same core concept as #show sym.dash.em: "---", but manual/must be used for each instance separately. The difference (from markup mode) however is that:

  • you don’t have to escape `*_@# symbols;
  • you have to escape double quotes.

I think in certain situations this might be a better solution (than escaping everything in markup).

1 Like