typst reader idea of horizontal rule doesn't match typst writer idea of it
t184256 opened this issue · 8 comments
Explain the problem.
There's an asymmetry in handling horizontal rules in typst that prevents roundtrips from working.
Writer outputs #horizontalrule
that the default template defines, but the reader expects a #line
.
$ echo '#line()' | pandoc --from typst --to markdown
------------------------------------------------------------------------
$ echo '------------------------------------------------------------------------' | pandoc --from markdown --to typst
#horizontalrule
Pandoc version?
3.1 locally, 3.5 online.
Code pointer
pandoc/src/Text/Pandoc/Readers/Typst.hs
Line 348 in 5f35aa6
I don't think this is a bug.
The writer relies on a definition of horizontalrule
in the default template.
If you include this definition, the reader can handle it.
% pandoc -f typst -t markdown
#let horizontalrule = line(start: (25%,0%), end: (75%,0%))
#horizontalrule
------------------------------------------------------------------------
Hm, OK, that'd make it round-trip when standalone is in effect and the definition is available, but still precludes roundtripping without it? It'd be nice if it was less brittle and recognized the meaning of #horizontalrule directly, and not through an implementation detail of it only becomes available in standalone.
Well, #horizontalrule
is not part of typst itself. It's just a macro we define in our default template.
Someone else could define it differently and even make it do something entirely different. It wouldn't be appropriate, I think, to treat it as we treat primitive typst elements.
Of course, if we really cared about round-tripping we could simply emit a #line
command. But that would make it impossible for users to customize the appearance of the horizontal rules.
Of course, if we really cared about round-tripping we could simply emit a #line command. But that would make it impossible for users to customize the appearance of the horizontal rules.
Won't a #set line(<the overrides you want>)
before first use do the trick?
That's an idea. Then we could just emit #line
. But #line
is quite general-purpose, and I'd be reluctant to override defaults for it just for the horizontal rule element. Not sure what others think.
There’s a typst feature request for a stock semantic macro for hr typst/typst#5318
Well, if available, just using the definitive macro for horizontal rule would be the cleanest option of all.