Skip to content

Convert base64 inline image to typst #10460

@nekrozis

Description

@nekrozis

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions