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

Syntax highlight using Pygments #225

Open
vbrilon opened this issue Dec 29, 2015 · 13 comments
Open

Syntax highlight using Pygments #225

vbrilon opened this issue Dec 29, 2015 · 13 comments

Comments

@vbrilon
Copy link

vbrilon commented Dec 29, 2015

I'd like to add support for Pygment code syntax highlighting -- but I am having trouble figuring out where in the plugin lifecycle this needs to happen. Any plugin documentation or examples you can point me to @koenbok please?

@ghost
Copy link

ghost commented Jan 29, 2016

would be really great to add pygments here 👍

@vbrilon
Copy link
Author

vbrilon commented Jan 29, 2016

@vyscond -- I made a pull request with my changes. It's a tiny piece of code, so should be easy to integrate it into your own setup. Grab it and let me know what you think.

@vbrilon
Copy link
Author

vbrilon commented Jan 29, 2016

The pull request is here: #227

@ghost
Copy link

ghost commented Jan 29, 2016

Got it. But i think you need to add pygments to dependencies. Right now you plugin kind assumes that we have pygments installed as a global package. Right?

@vbrilon
Copy link
Author

vbrilon commented Jan 29, 2016

Correct. I've not defined dependencies properly but the import statements are pretty clear :)

@dwightgunning
Copy link
Contributor

Is the intention to syntax highlight markdown?

I'm currently achieving this by adding the fenced-code-block extension to the markdown template tag (which detects and uses pygments when available):

   {% filter markdown:"fenced-code-blocks" %}
   ```python
   PAGE_URL = '{slug}/'
   PAGE_SAVE_AS = '{slug}/index.html'
   {% endfilter %}```

So there may not be any need for an additional cactus plugin.

@ghost
Copy link

ghost commented Feb 8, 2016

in this case you installed pygments globally?

@dwightgunning
Copy link
Contributor

I use a virtualenv for Cactus so I've got pygments installed in there. You could install it globally if you prefer.

The nice thing with the MD template tag and the (built in) fenced-code-blocks extension, there's no hard dependency on pygments.

@ghost
Copy link

ghost commented Feb 8, 2016

I think this "problem"/"request" is more related to people using the mac app.

@dwightgunning
Copy link
Contributor

@vyscond - oh right... in that case, yeah, install it globally or go hacking around inside the OS X application package.

We should start making use of 'labels'.... @krallin @koenbok - I'd be happy to help with that sort of housekeeping if it's possible to assign that role without giving out commit rights.

@ghost
Copy link

ghost commented Feb 9, 2016

I can't think about any terrible thing right now about including pygments as default dependency on both environments. May add a app option too turn/switch on/off the pygment render. I think...

@vbrilon
Copy link
Author

vbrilon commented Feb 9, 2016

@vyscond This request/issue is not specific to the mac app at all

@dwightgunning
Copy link
Contributor

@vyscond - I'd prefer to see it remain optional in the core cactus package. It's really an optional/extended feature. Once it's set as a dependency the matters of ongoing stability, compatibility, etc. become more critical.

As it currently stands, it's super simple to install pygments via pip and the python markdown engine will use it if it's available. If the markdown project deemed it essential for markdown authors, then we'd be picking it up via that dependency chain. Their approach seems to support my point above.

For the mac app, then it may be more logical to include pygments if the target audience are frequently writing markdown with code blocks. But that's a separate decision process anyways.

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