Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typst reader idea of horizontal rule doesn't match typst writer idea of it #10441

Open
t184256 opened this issue Dec 6, 2024 · 7 comments
Open
Labels

Comments

@t184256
Copy link

t184256 commented Dec 6, 2024

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

,("line", \_ fields ->

@t184256 t184256 added the bug label Dec 6, 2024
@jgm
Copy link
Owner

jgm commented Dec 7, 2024

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
------------------------------------------------------------------------

@t184256
Copy link
Author

t184256 commented Dec 7, 2024

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.

@jgm
Copy link
Owner

jgm commented Dec 7, 2024

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.

@t184256
Copy link
Author

t184256 commented Dec 7, 2024

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?

@jgm
Copy link
Owner

jgm commented Dec 7, 2024

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.

@silby
Copy link
Contributor

silby commented Dec 7, 2024

There’s a typst feature request for a stock semantic macro for hr typst/typst#5318

@t184256
Copy link
Author

t184256 commented Dec 8, 2024

Well, if available, just using the definitive macro for horizontal rule would be the cleanest option of all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants