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

Update how highlighting works #2715

Closed
mattr- opened this Issue Aug 9, 2014 · 7 comments

Comments

Projects
None yet
5 participants
@mattr-
Copy link
Member

mattr- commented Aug 9, 2014

Not sure where we want to keep potential 3.0 work, but wanted to capture this relevant bit of info from #2709 regarding some work that we need to do for highlighting.

In general our syntax highlighting needs a huge overhaul. We have Pygments and Rouge injected into places within Jekyll that would make Robert Louis Stevenson blush. It's an absolute mess. Most of our markdown converters find all the <pre> tags and use gsub (can you believe it?!) to provide some sort of highlighting. Few of the markdown libraries we use offer support for plugins, so we're a little dead in the water. We've been asked to match what GitHub is doing and we've bent over backwards to accomplish that. Unfortunately, it's left us in this present quandary.

I think the path going forward is to ask markdown libraries to give us some means to work with their internal AST's (or whatever it is they build) to manipulate the code and pre tags to our liking. I have a strong urge to rip out all syntax highlighting in everything but the {% highlight %} tag and ship highlighting when it's ready from the Markdown library side (i.e. kramdown, RDiscount, RedCarpet).

We may be able to use HTML Pipeline to port GitHub's Markdown approach, but we'll need a bit of assistance from them to put it all together in a useful way.

@parkr

This comment has been minimized.

Copy link
Member

parkr commented Aug 9, 2014

Thanks, @mattr-! Sometimes I say sane things.

@paulrobertlloyd

This comment has been minimized.

Copy link
Contributor

paulrobertlloyd commented Oct 13, 2014

Is this issue the reason why the following config doesn’t work when I use fenced code blocks?

markdown: kramdown
highlighter: pygments

It seems kramdown ignores this highlighting preference and uses coderay instead. I’ve tried using https://github.com/navarroj/krampygs, but this is a fragile hack that keeps breaking. Using liquid {% highlight %} tags causes problems with code contained within list items (i.e. already indented) — problems that don’t occur when using ‘native’ markdown.

How difficult is it to get kramdown + pygments + fenced code blocks playing nicely together?

@parkr

This comment has been minimized.

Copy link
Member

parkr commented Oct 13, 2014

Fenced code blocks in Kramdown use ~ instead of the backtick. http://kramdown.gettalong.org/syntax.html#fenced-code-blocks

@paulrobertlloyd

This comment has been minimized.

Copy link
Contributor

paulrobertlloyd commented Oct 13, 2014

Yup, I’m using ~, e.g.: https://raw.githubusercontent.com/paulrobertlloyd/paulrobertlloyd.com/master/source/journal/_posts/entries/2014-07-02-responsive_day_out.markdown

I actually found another plugin that tries to patch this issue, although I can’t get this one to work currently: https://github.com/mvdbos/kramdown-with-pygments

@envygeeks

This comment has been minimized.

Copy link
Contributor

envygeeks commented Aug 26, 2015

I have a question on this topic: Why don't we use something like ContentPipeline (my library) or HTMLPipeline (Github's) which would make rendering much cleaner for everybody? Mine normalizes everything from every client and gives you access to highlighting, I don't know whether HTMLPipeline does, but in general we could clean up the whole mess that is rendering by just offloading it onto an external plugin that is designed to do content.

@envygeeks

This comment has been minimized.

Copy link
Contributor

envygeeks commented Aug 26, 2015

BTW, I'd be willing to hand over the source to content-pipeline if you wanted to use that in Jekyll (we don't use it on many of my projects and it was explicitly designed for Jekyll pretty much...)

@parkr

This comment has been minimized.

Copy link
Member

parkr commented Aug 26, 2015

@envygeeks I dig the idea of using a Pipeline. We're already using HTMLPipeline for jekyll-mentions and jemoji. Does it depend on Nokogiri, though? My big worry is including C extensions again.

@parkr parkr modified the milestones: 3.2, 3.1 Jan 11, 2016

@jekyllbot jekyllbot added the stale label Jun 6, 2016

@jekyllbot jekyllbot closed this Jul 6, 2016

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