obsidian-typst icon indicating copy to clipboard operation
obsidian-typst copied to clipboard

Plugin only renders first page on PDF export

Open shemraz opened this issue 2 years ago • 7 comments

The plugin doesn't seem to be able to render multi-page documents. I'm rendering as SVG in the example, but it's the same with images!

Preamble

// typography
#set page(paper: "a4", fill: rgb("f7f9ff"), margin: 2.5cm, numbering: "1")
#set text(
	font: "Halant",
	size: 10pt,
	fill: rgb("5c6166")
)
#set par(justify: true, leading: 15pt)
#show heading: set text(
	font: "Montserrat",
	weight: "semibold"
	)
#show heading: set block(
	spacing: 15pt
	) 

// citations
#set cite(style: "chicago-notes", brackets: false)
#set bibliography(style: "chicago-author-date")
#show "“": "‘"
#show "”": "’"

Codeblock

= h1
== h2
#lorem(100)

== h2
#lorem(200)

== h2
#lorem(300)

= h1 
#lorem(100)

Intended result Test.pdf

Actual Result image

shemraz avatar Oct 10 '23 13:10 shemraz

As this plugin is intended to only render code blocks and math blocks, it only makes sense to render the first page. Once a custom editor has been added multiple pages could be supported.

fenjalien avatar Oct 17 '23 20:10 fenjalien

Ah, I see. Understandable! Is there a planned implementation for the custom editor? I would love to contribute but am unfamiliar with Rust. The work you've put into this plugin is much appreciated!

shemraz avatar Oct 18 '23 14:10 shemraz

An implementation is planned but its waiting on HTML export from typst as that would remove a lot of the headache. I think @SekoiaTree started looking into the impl. then switched to looking into the html export and then I lost track :)

fenjalien avatar Oct 18 '23 16:10 fenjalien

Haha yeah I've been relatively busy since sadly

SekoiaTree avatar Oct 18 '23 16:10 SekoiaTree

hi! so just to clarify, I have a bunch of math blocks interspersed with standard Obsidian text. when I export to PDF, my content is longer than 1 page, and so only the math blocks on the first page are rendered, the rest are not. this is currently expected behavior, right? thank you!

aczw avatar Feb 14 '24 22:02 aczw

@aczw I think your problem is closer to #29 than this one.

when I export to PDF, my content is longer than 1 page, and so only the math blocks on the first page are rendered, the rest are not. this is currently expected behavior, right?

In a way it is expected behaviour but it is still a problem that should be fixed. Its most likely because Obsidian expects the renderMath function to be blocking (when it returns it is completely done). However, the plugin overrides this and the function is async/nonblocking so it returns before it is "done rendering". I'm not entirely sure how to fix this and honestly I need to find a better way to override the default math blocks.

As a work around you try using pandoc to convert the markdown into Typst...

fenjalien avatar Feb 15 '24 10:02 fenjalien

ah that issue more closely describes what I'm experiencing. I'm not in a hurry to export my notes or anything, but I'll try using pandoc, thanks!

aczw avatar Feb 16 '24 18:02 aczw