-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
Reworking format.jl #350
Reworking format.jl #350
Conversation
nice, thanks for your try. If so, I'm totally okay to merge this, while it would be super great if you could tell any problem you notice.
sounds good, might be good to start in another PR, tho ;) |
Yeah, in my initial tests this did seem to produce a valid EDIT: actually no. Also, given that the tests now fail it seems that the old behaviour was intended, though it's not clear what for. |
great,
so the loading of
yeah we have tons of old and very fragile (and annoying tbh) end2end tests, and I guess this PR can fail some of them, but don't care it. We can manually update them later (or even remove them). see #326 for the context if you want. |
fwiw, rebasing against master will make it easier to run tests locally (skip Plots.jl and Gadfly.jl integration tests, which would take long time to finish otherwise) |
Yeah, I also thought about that. Maybe it would make sense to make each get_template(::Nothing, tex::Bool = false) =
Mustache.template_from_file(normpath(TEMPLATE_DIR, tex ? "md2pdf.tpl" : "md2html.tpl")) that would allow us to remove this hardly extendable piece of code. |
well, we can do much more things using this, but this commit just introduces this type Co-Authored-By: null <[email protected]>
- and load minted package for TexMinted format Co-Authored-By: null <[email protected]>
yep, we can do that, see this README section in Mustache.jl, a template engine we use. I pushed some commits, and now |
okay, I updated this PR to #355 . |
No worries. So I'm restructuring the files right now and moving code back and forth. I really don't like the fact that we have these weird types that are all the same because they just contain a dictionary. This seems like an unnecessary bit of indirection. Since no part of Weave.jl is performance critical (and since the current approach isn't exactly type stable either) I propose that we do away with the dictionary in between and define untyped Somewhere (probably at the very beginning) we would then have to EDIT: all these asserts are only necessary for user passed types. But this is not the intended usage anyway, since then she would need to implement all the methods anyway? The more likely/intended case is that users pass a modified instance of one of the implemented types. @aviatesk if you disagree, please say so. If not, I will start working on that tomorrow. |
My thoughts on the following lines of code. (at
I think we could instead implement a
|
Oh, I found a proper issue that will make working with
|
ok, so I'm finally starting to understand what is happening here:
This means that if we want to make |
By now a lot of files have changed.
|
Things that remain to be done:
Things like https://github.com/mauro3/Unpack.jl could also shorten the code in some places. |
Thanks for your work on this, again. Most of your suggestions sound so nice. Before discussing details, I would like to ask if you would mind splitting this PR into separate PRs, one for general refactoring format/rendering logic, one for actually improving Tex output format ? |
Here are comments on refactoring parts:
I like it. Actually I had the exact same idea before (maybe a week ago) but at that time I withdraw it for some reason. I forgot the detail already but I guess at that time we did something like
sounds nice.
yeah, we can do smarter processing of rendering-related arguments/options according to output formats.
yeah, sounds good. |
hm, that is a very good point. |
So I created a new PR but since the branch of this PR lives in my own fork of Weave, |
- reorder/move things so that format-specific rendering methods are defined close to the format - separate common rendering methods from format specific methods - fix using location
- remove unused field defs - in theory extensible, once documented - fix test - start to change terminology, `format` -> `render`
ah, sorry, that is only possible if you can push a brach into this repository, so let's do tex stuff in another PR after this PR gets merged into master. |
I pushed two commits into this PR since I can't make another PR merging into this PR: each does:
So can you kindly review on this ? |
src/rendering/htmlformats.jl
Outdated
Base.@kwdef mutable struct JMarkdown2HTML <: HTMLFormat | ||
description = "Julia markdown to html" | ||
codestart = "\n" | ||
codeend = "\n" | ||
outputstart = "<pre class=\"output\">" | ||
outputend = "</pre>\n" | ||
fig_ext = ".png" | ||
mimetypes = ["image/png", "image/jpg", "image/svg+xml", | ||
"text/html", "text/markdown", "text/plain"] | ||
extension = "html" | ||
termstart = codestart | ||
termend = codeend | ||
out_width = nothing | ||
out_height = nothing | ||
fig_pos = nothing | ||
fig_env = nothing | ||
template = nothing | ||
stylesheet = nothing | ||
highlight_theme = nothing | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can do even more that this, like creating a macro that wraps Base.@kwdef
and automatically defines some fields like mimetypes
with default value if not specified, and do some assertion, etc, but we can do that later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's actually not too bad an idea! I like it
And, imho, this kind of refactoring PR should be merged soon as possible (otherwise we may start to feel really dull on this kind of stuff), so I think I will move to quickly merge this if you approve and we pass tests. |
8c86974
to
b294856
Compare
Ah, you started outsourcing the argument handling already. Nice! I like your changes. I think we can merge. |
- first, it's really dull to keep compatibility with LTS - and now we want to use `Base.@kwdef` for creating types with supertypes, and LTS can't have that for reasons
@JonasIsensee okay, I will move to merge this once CI passes. Looking forward to your another tex improvements PR on top of this ! (well, take your time, as always ;)) |
Hi,
addressing #345
This PR implements a super simple way to make exports for
tex
andtexminted
work.I'm not saying that this is the best way to do it but I just started this PR as a proof of concept.
It may be worth reorganizing the types around the
docformat
s to account for the similarities (such as shown here).