-
Notifications
You must be signed in to change notification settings - Fork 351
Users can now add custom HTML before the closing head tag and the closing body tag #764
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
Conversation
Code blocks are now handled by the markdown modules, and ExDoc doesn't do any post-processing. The modules bundled with ExDoc were updated to reflect this. The goal of this change is to make it easier to use alternative Markdown implementations. This might break compatibility for people that are already usin Markdown extensions.
Docs still missing
@tmbb instead of changing existing tests, can you please add a new test for this feature? Our ex_doc tests tend to really grown in size with time and that makes it difficult to know what they are really testing. Thank you! |
Done |
❤️ 💚 💙 💛 💜 |
* `:before_closing_body_tag` - Literal HTML to be included just before the closing body tag (`</body>`) | ||
Useful to inject custom assets, such as Javascript. | ||
Only works with the HTML formatter. |
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.
@tmbb @josevalim Why? This should also work with EPUB documents, at the end, an EPUB file is just a bunch of .xhtml
files.
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.
Because I've only added this functionality to the HTML templates :) If you want it, I can add it to the EPUB ones.
I would hold before adding this to ePub because it is not guaranteed you
would like the exact same changes in both.
Maybe the flag should have html in its name?
--
*José Valimwww.plataformatec.com.br
<http://www.plataformatec.com.br/>Founder and Director of R&D*
|
@josevalim I hadn't thought of that. I can add an |
maybe |
@josevalim Good point!, but...
I don't think it is necessary and it will pollute the configuration, suppose that in the future we add something like IMHO the author is responsible to control this behavior, for example, if the author wants different styles for HTML and EPUB can do the following: <style type="text/css" media="screen">
...
</style>
<style type="text/css" media="amzn-kf8" [or "not amzn-kindle"]>
...
</style> The same can be applied with JS. wdyt? |
An the epub version would be |
@milmazz Do you trust CSS support of EPUB readers that much? I thought it was pretty bad. |
@tmbb EPUBv3 supports CSS2.1 + CSS3. More info: http://www.idpf.org/epub/30/spec/epub30-overview.html#sec-rendering |
Hm... I'm still not convinced. Having different keys is simpler, and costs nothing except fro two more keys in the config... I'm against pure CSS solutions for this. |
@tmbb I'm just saying that it's a common practice to create media-specific ( Also, we already provide some styles for the @media print {
// ...
} HTH |
Hm... Interesting... I didn't know CSS was so versatile. There are probably ways to generate PDFs from ExDoc too, right? |
@josevalim Could you weigh in on how this should be done? I'd like to have a new release of ex_doc with this new functionality so that I can use the improved ex_doc to document my own packages (I cant add the github master as a dependency) :) |
Why not make the options like |
@OvermindDL1 Maybe not a function, but a map. That way you can match the keys on the map, and if all matches fail you return the empty string. With a function the burden of having a clause for each option is on the user. |
You can always catch if there is a match/argument error and return an empty string then, but I personally thing it is better to be explicit than implicit. They may actually want a match error to remind them that they need to add some functionality to another format for example. it is not hard to add a |
You're right, a function is better than a map, unless we actually raise an error when the map key doesn't match to notify the user. |
@milmazz my concern is that CSS is not the only reason to customize this. What if you want to include some javascript that doesn't really make sense in a book? |
@josevalim I agree that it's better to have separate inclusions for EPUB and HTML. The questions are:
|
@josevalim Ok, considering your concern I think that the best approach in this scenario is the one suggested by @OvermindDL1, both options ( I prefer the approach mentioned before than adding more options in our configuration, suppose that we include support for another format, so then we have something like this:
wdyt? /cc @tmbb @OvermindDL1 |
In one option you have: docs: [
before_closing_head_tag: &before_closing_head_tag/1
]
def before_closing_head_tag(:html), do: "..."
def before_closing_head_tag(_), do: ""
def before_closing_body_tag(:html), do: "..."
def before_closing_body_tag(_), do: "" In the other you have: docs = [
before_closing_html_head_tag: "..."
before_closing_html_head_tag: "..."
before_closing_epub_head_tag: "..."
before_closing_epub_head_tag: "..."
] This version is simpler and might play well with formats that don't have a head or body tag. |
But it's probably just a matter of preference. |
Sure, seems like a matter of preference, but please consider that when you add a new option to ExDoc you need to change the HTH |
Let's go with the function. @tmbb can you please change it accordingly? Thank you! |
Yes, but probably only on monday. If my new "anti-highlightjs" hack works, could we have a release after support for other formats (in the form of a function) is merged? I'd like to be able to use my alternative code highlighter to document my own hex packages, and I can obly do it once there's been a release. |
Done #768. My anti Highlightjs hack works. I think we should have a new release. |
I think I've covered all test cases that make sense, but there is still much about ex_doc which I don't know in detail.