-
Notifications
You must be signed in to change notification settings - Fork 107
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
Provide a convenient way to add custom CSS styles #7
Comments
Should we add stylesheet from a path or have it in data folder so that we can copy it to output folder? |
|
I've function ready for this, should I push and create a PR? |
@danijar - are you ready for a PR on this feature? |
This sounds good. The PR should also change the Handout class to add the existing default styles this way if possible. The only question I have remaining here is how to handle HTML-only features if we plan to add support for LaTeX in the future. The original plan was to have all functions work for all backends except |
@danijar @sonwanesuresh95 @epogrebnyak Would it not be better to move every stylesheet and script file in output folder first and then iterate through them to generate the basic structure using _generate(). For example: and we can append them to |
That would mean all JS files that happen to be in the output directory will be included in the HTML head, right? |
Yes, this is correct. |
I thought quite a bit about the implementation of this now:
I suggest as API to add scripts and styles: def add_html(string=None, style=None, script=None, show=False):
if bool(string) = bool(style) + bool(script) != 1:
raise KeyError('Should provide exactly one of string, style, script arguments.')
if style:
self._add_file(style)
string = '<link rel="stylesheet" href="{}">'.format(style)
if script:
self._add_file(script)
string = '<script src="{}">'.format(script)
# Existing function body... What do you think? Happy to discuss. |
Adding custom CSS is possible in two ways:
We could add
doc.add_style(filename)
that copies the file into the output directory for the user.The text was updated successfully, but these errors were encountered: