Skip to content
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

[question] pygments style #58

Closed
gares opened this issue Aug 12, 2021 · 4 comments
Closed

[question] pygments style #58

gares opened this issue Aug 12, 2021 · 4 comments

Comments

@gares
Copy link

gares commented Aug 12, 2021

This comment seems outdated, since the .css is not inlined even if you use the command line interface.

def highlight_html(coqstr):
    """Highlight a Coq string `coqstr`.

    Return a raw HTML string.  This function is just a convenience wrapper
    around Pygments' machinery, using a custom Coq lexer and a custom style.

    The generated code needs to be paired with a Pygments stylesheet, which can
    be generated by running the ``regen_tango_subtle_css.py`` script in the
    ``etc/`` folder of the Alectryon distribution.

    If you use Alectryon's command line interface directly, you won't have to
    jump through that last hoop: it renders and writes out the HTML for you,
    with the appropriate CSS inlined.  It might be instructive to consult the
    implementation of ``alectryon.cli.dump_html_standalone`` to see how the CLI
    does it."""

If it was inlined, I could add a command line option to select another style.

I'd like to pick another style, one close to the default vscode one.

One way would be to keep the css external, maybe rename it to remove "tango", and change the regen_tango_subtle_css.py to take an argument (the style), and the let me generate another style at deploy time.

Another option would be to make this comment true, and add a command line option to pick the style.

What is best?

cpitclaudel added a commit that referenced this issue Aug 19, 2021
Closes GH-58.

* alectryon/cli.py (gen_docutils): Skip embedded assets.
(copy_assets): Add support for dynamically-generated assets.
(dump_html_standalone): Don't embed pygments stylesheet.
(build_parser): Add a new --pygments-stylesheet option.
* alectryon/docutils.py (register_stylesheets): Support dynamic assets.
* alectryon/html.py (ASSETS): Change "tango_subtle" to "pygments".
* alectryon/latex.py (ASSETS): Same.

Suggested-by: @gares
@cpitclaudel
Copy link
Owner

I think Github lost my answer to this question, sorry. Trying again:

This comment seems outdated, since the .css is not inlined even if you use the command line interface.

It depends:

  • With --frontend coq, it is unconditionally inlined.
  • With --frontend coq+rst, it is inlined only if embed_stylesheets is non-nil.

If it was inlined, I could add a command line option to select another style.

We could still have a CLI option to select the style, even if it's external (I think this is also what you say below?)

One way would be to keep the css external, maybe rename it to remove "tango", and change the regen_tango_subtle_css.py to take an argument (the style), and the let me generate another style at deploy time.

Right.

Another option would be to make this comment true, and add a command line option to pick the style.

Right.

What is best?

I'm not sure :) Both? I've made a branch at /~https://github.com/cpitclaudel/alectryon/tree/gh-58-pygments ; please give it a try and let me know what you think. In brief:

  • You can pick a style with --pygments-style
  • It should inline correctly based on embed_stylesheet
  • The generated stylesheet is called pygments.css instead of tango_subtle
  • When building with Sphinx, it respects Sphinx's --pygments-style settings.

Hopefully that covers everything. Please let me know, and I'll merge soon.

@gares
Copy link
Author

gares commented Aug 20, 2021

great, I'll try asap

@gares
Copy link
Author

gares commented Aug 20, 2021

Works for me, thanks!

@cpitclaudel
Copy link
Owner

Thanks, merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants