-
Notifications
You must be signed in to change notification settings - Fork 5
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
Markdown output #85
Comments
Markdown output is definitely something that should be in the library 👍 However, I think implementing a Feeding Pollen.jl projects into different frontends is very much in the spirit of the library, by the way, I just haven't gotten to any others yet :) |
Cool, ok maybe it's not as difficult to write out the markdown manually, I thought we could save some effort there by using CommonMark but its AST is not a normal tree, so would be a bit annoying to set up.
Regarding that, I didn't quite understand when the different steps happen. There's |
Regarding the different stages:
|
So in which of those would saving to image files (from code execution) happen, and which one would be good for a compression pass and assembling a gallery page? |
Saving to image files should be done in the |
Something along these lines: struct MarkdownImages <: Rewriter
images::Dict
end
function Pollen.rewritedoc(rewriter::MarkdownImages, docid, doc)
cata(doc, SelectTag(:coderesult)) do node
val = only(children(node))[]
if showable(MIME("image/jpeg"), val)
id = Base.uuid5()
# Store the value
rewriter[id] = val
# Insert link
return withchildren(node, [Node(:img, src = "/static/$id.jpg")])
end
end
end
function Pollen.postbuild(rewriter::MarkdownImages, _, builder::FileBuilder)
for (id, val) in collect(rewriter.images)
FileIO.save(joinpath(builder.dir, "static/$id.jpg"), val)
# only need to save these once. if they change they will be readded
delete!(rewriter.images, id)
end
end
The only thing missing now is the Also, this rewriter will of course have to be inserted after the |
I've thought about using Pollen to rewrite a markdown source into another markdown source, for use with tools such as Docusaurus or MkDocs. Currently, markdown output is not implemented, but I think the shortest path to get it would be to make a CommonMark.jl AST out of the tree structure again to use its printing functionality.
My idea is to handle Makie's plot generation / code execution with Pollen.jl and then let other tools handle the static site generation. It's just too much work for most projects to exhaustively handle all that website stuff as I've seen working on the Makie docs, so I think it would be good to attempt that kind of split.
The text was updated successfully, but these errors were encountered: