-
Notifications
You must be signed in to change notification settings - Fork 25
Unwanted removal of spaces in Markup: breaking "Code only" & "Correctness" #296
Description
I am trying to write a custom inline numbered list. Due to the lack of special grammar, I wanted to minimize the syntax needed. This is my version of the code (MRE):
#let opt(..content) = {
let c = content.pos()
let num = it => numbering("A. ", it)
grid(
columns: c.len() * (1fr,),
..c.enumerate().map(((i, v)) => num(i + 1) + v)
)
}
#let opts(content) = {
let arr = content.children.filter(it => "text" in it.fields()).map(it => it.text)
opt(..arr)
}
1. #opts[randomness potential masterpiece success]
2. #opts[emergency maintenance review shade]
//instead of: 2. #opt[emergency][maintenance][review][shade]
However, after running the formatter, "extra" spaces are removed, and my markup became:
1. #opts[randomness potential masterpiece success]
2. #opts[emergency maintenance review shade]
This changes the semantics from a sequence (of texts interspersed by spaces) to a consecutive text, it not only BREAKS the indention of the source code, but also cause my custom function to STOP working.
I wonder why space removal is also applied to markups(The contents in brackets). I thought a formatter should have focused on "code only" as stated in the readme. I searched for relevant info in the doc, but it seems that only math mode can survive the formatting.
I am really confused about this current behavior. Is it intended? If it is, I hope for an new option that allows spacing in markup to be left untouched (and hopefully this option doesn't violate the "opinionated" goal). If not so, is there any workaround that I can do now? Or is there a better way to implement such custom function(e.g. #opts) so that my markup survive the formatting?
Extra screenshots are provided for your convenience as follows:

