quarkdown icon indicating copy to clipboard operation
quarkdown copied to clipboard

Infinite loop with embeded base64 image

Open dantodor opened this issue 7 months ago • 4 comments

I have a very simple qmd file for testing embeding images:

.figure caption:{Monthly Revenue Performance for 2024}
![Chart Description](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA.....

When trying to compile it (simple c command no other parameters), I get this:

../quarkdown/bin/quarkdown c r.qmd
Exception in thread "main" java.lang.StackOverflowError
	at java.base/java.util.regex.Pattern$CharProperty.match(Pattern.java:4106)
	at java.base/java.util.regex.Pattern$Branch.match(Pattern.java:4914)
	at java.base/java.util.regex.Pattern$GroupHead.match(Pattern.java:4969)
	at java.base/java.util.regex.Pattern$LazyLoop.match(Pattern.java:5146)
	at java.base/java.util.regex.Pattern$GroupTail.match(Pattern.java:5000)
	at java.base/java.util.regex.Pattern$BranchConn.match(Pattern.java:4878)
	at java.base/java.util.regex.Pattern$CharProperty.match(Pattern.java:4110)
	at java.base/java.util.regex.Pattern$Branch.match(Pattern.java:4914)
	at java.base/java.util.regex.Pattern$GroupHead.match(Pattern.java:4969)
	at java.base/java.util.regex.Pattern$LazyLoop.match(Pattern.java:5146)
	at java.base/java.util.regex.Pattern$GroupTail.match(Pattern.java:5000)
	at java.base/java.util.regex.Pattern$BranchConn.match(Pattern.java:4878)
	at java.base/java.util.regex.Pattern$CharProperty.match(Pattern.java:4110)
	at java.base/java.util.regex.Pattern$Branch.match(Pattern.java:4914)
......

Probably I can find my way around by just avoid embedding and writing the images to temporary files, but still.

PS Thanks for the great product!

dantodor avatar Jun 05 '25 01:06 dantodor

Just to note, if I rename the file to `.md', it is rendered correctly.

dantodor avatar Jun 05 '25 01:06 dantodor

This is surprisingly similar to the bug that just got fixed in parsing table headers. That was a regex problem. Yours looks similar.

tdunning avatar Jun 05 '25 06:06 tdunning

Agreed, by my knowledge of Kotlin is not good enough to issue a PR :)

dantodor avatar Jun 05 '25 06:06 dantodor

Hi @dantodor, I cannot reproduce the issue. Can you provide the full b64 string please?

PS: assigning a title already generates a figure without the need of .figure.

Please note: b64 'support' is purely coincidental, as it just slips to the HTML renderer. It won't work in case of different output targets.

iamgio avatar Jun 05 '25 07:06 iamgio

I'm sorry, I deleted the files, and they're generated automatically by an LLM, not easy reproducible. But if you say it won't work when generating PDFs, I'll stop here and go back to simple markdown, as there it's supported and I can generate both PDFs and HTMLs. Thanks for your answer!

dantodor avatar Jun 06 '25 05:06 dantodor

@dantodor it will still work when generating PDFs, as PDF generation is built on top of HTML rendering. Just saying, it won't work in case, for example, LaTeX is supported as a rendering target (#41).

iamgio avatar Jun 06 '25 07:06 iamgio