Skip to content

Monadic blockRender? #46

@mrkgnao

Description

@mrkgnao

I'd like to render LaTeX diagrams into images that are then inserted into the output. I have a function of the following form:

-- | Render some LaTeX content to an image whose filename is the 
-- hash of the content. Return the path to the image.
renderToFile :: Text -> IO FilePath
renderToFile latex = do
   ...
   pure savePath

I think the interface I would like is to interpret code-blocks with some particular infostring (e.g. render-latex) as LaTeX to be rendered into a PNG. If blockRenderM existed, I could just do

renderLatexExt :: Extension
renderLatexExt = blockRenderM $ \case
  CodeBlock (Just "render-latex") content 
    -> (\uri -> Image undefined uri Nothing) <$> renderToFile content
  x -> pure x

or something.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions