Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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.

2 participants