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

Convert base64 inline image to typst #10460

Closed
necrosisy opened this issue Dec 15, 2024 · 2 comments
Closed

Convert base64 inline image to typst #10460

necrosisy opened this issue Dec 15, 2024 · 2 comments
Labels

Comments

@necrosisy
Copy link

necrosisy commented Dec 15, 2024

When there are base64 inline images in the input markdown file, the output typst format cannot be processed correctly
While typst correctly supports inline images
typst/typst#1084

CommandLine Input

echo '![linkedin](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVBAMAAABbO
bilAAAALVBMVEUPf7kAAAAAd7X////A3e0QgLrQ5vGgzOOQxN+Au9pws9ZgqtEwkcPw9/sgiL5dr8kZAAAAAnRSTlPIAHWwkH4AAABXSURBVAjXYxBQggIFA
QYmJRhgYAASMAkGpTCzIDh7sfEiOHuz8SY4W8MDph5Vr7KxkrGPs3EpjG1rbGwOY4MAjG2pNBnOtlM6DGcbAUly2Ag3IPsL2b8A12UlWSTqjl8AAAAASUVOR
K5CYII=)' | pandoc -o out.typ

Which Output

cat out.typ

#figure(image("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVBAMAAABbObilAAAALVBMVEUPf7kAAAAAd7X////A3e0QgLrQ5vGgzOOQxN+Au9pws9ZgqtEwkcPw9/sgiL5dr8kZAAAAAnRSTlPIAHWwkH4AAABXSURBVAjXYxBQggIFAQYmJRhgYAASMAkGpTCzIDh7sfEiOHuz8SY4W8MDph5Vr7KxkrGPs3EpjG1rbGwOY4MAjG2pNBnOtlM6DGcbAUly2Ag3IPsL2b8A12UlWSTqjl8AAAAASUVORK5CYII="),
  caption: [
    linkedin
  ]
)

Try to Compile

typst compile out.typ --> error: failed to load file

The image function of typst cannot handle inline images correctly and requires additional steps

pandoc version

pandoc.exe 3.6
Features: +server +lua
Scripting engine: Lua 5.4
@necrosisy necrosisy added the bug label Dec 15, 2024
@jgm
Copy link
Owner

jgm commented Dec 15, 2024

What should the typst output be in this case?

@jgm
Copy link
Owner

jgm commented Dec 15, 2024

I guess this (tested):

#figure(image.decode("<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><image xlink:href=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVBAMAAABbO
bilAAAALVBMVEUPf7kAAAAAd7X////A3e0QgLrQ5vGgzOOQxN+Au9pws9ZgqtEwkcPw9/sgiL5dr8kZAAAAAnRSTlPIAHWwkH4AAABXSURBVAjXYxBQggIFA
QYmJRhgYAASMAkGpTCzIDh7sfEiOHuz8SY4W8MDph5Vr7KxkrGPs3EpjG1rbGwOY4MAjG2pNBnOtlM6DGcbAUly2Ag3IPsL2b8A12UlWSTqjl8AAAAASUVOR
K5CYII=\" /></svg>"), caption: [Linked in])

@jgm jgm closed this as completed in e096e06 Dec 18, 2024
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

2 participants