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

add an API to disable highlighting by file name #208

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

haldean
Copy link

@haldean haldean commented Mar 1, 2018

This adds an API that a uWSGI script can use to enable/disable highlighting on a per-file basis. I wanted this for my site because I don't like the syntax highlighting that Pygments uses for .txt files and README files, but it seems like it could be a generally-useful API.

I'm not a huge fan of the name of the highlight_enabled parameter, but I couldn't think of a better one. Happy to rename it if you can think of one!

This adds an API that a uWSGI script can use to enable/disable
highlighting on a per-file basis.
@jonashaag
Copy link
Owner

jonashaag commented Mar 1, 2018

Thanks for the patch!

What do you think about a small redesign:

  • a method Klaus.should_highlight(filename, data) -> bool that is passed the filename + the contents
  • in highlight_or_render, rename render_markup to enable_markup
  • add enable_highlight : bool to the highlight_or_render function (not as a function but a boolean)

Also, in your current implementation, highlight_enabled can also be used to disable markup rendering. If this is intended, then the name should be changed to reflect this behaviour. If not the logic should be changed accordingly.

As a last step we would have to add a new argument to make_app that allows you to give your own Klaus subclass, i.e. make_app(app_class=MyKlaus).

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

Successfully merging this pull request may close these issues.

None yet

2 participants