How config asciidoc Source code highlighter?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How config asciidoc Source code highlighter?

kuuyee
How config asciidoc Source code highlighter?
Reply | Threaded
Open this post in threaded view
|

Re: How config asciidoc Source code highlighter?

mojavelinux
kuu yee,

If you want to do source highlighting via JavaScript (client-side), which I recommend, there's nothing you have to configure in the Awestruct AsciiDoc integration to make that happen. All you need to do is include highlight.js and a highlight.js stylesheet in the page template.

NOTE: Asciicoctor adds these headers when it produces HTML files, but remember that we are running Asciidoctor in embedded mode in Awestruct, so we don't get the HTML head and body tags.

You can see AsciiDoc with source code highlighting in action using highight.js on asciidoctor.org. Here's where I include the highlight.js assets:


You'll notice above that line I include instructions for how I built the highlight.js file. I recommend making a custom build since the project hasn't been released in a long time and has tons of new features that aren't in 1.7.3.

The alternative is to use CodeRay. If you want to use CodeRay, then you'd configure Asciidoctor in _config/site.yml using the new template engine configuration mechanism in Awestruct 0.5.0. Here's an example:

asciidoctor:
  :attributes: 
    source-highlighter: coderay
    coderay-css: style

If you want to style the tokens using CSS, then change coderay-css to class and include the CodeRay stylesheet in the header. In haml, that would be:

%style
  - ::CodeRay::Encoders[:html]::CSS.new(:default).stylesheet

Remember to add the coderay gem to your Gemfile.

I put this information on a wiki page. Feel free to revise.


-Dan


On Sat, Apr 13, 2013 at 4:55 AM, kuuyee <[hidden email]> wrote:
How config asciidoc Source code highlighter?



--
View this message in context: http://talk-archive.awestruct.org/How-config-asciidoc-Source-code-highlighter-tp234.html
Sent from the Awestruct Talk mailing list archive at Nabble.com.

---------------------------------------------------------------------
Archives: http://talk-archive.awestruct.org/
To unsubscribe, e-mail: [hidden email]




--
Dan Allen
Principal Software Engineer, Red Hat | Author of Seam in Action
Registered Linux User #231597

Reply | Threaded
Open this post in threaded view
|

Re: How config asciidoc Source code highlighter?

kuuyee
Dan Allen,

Thanks for your help, CodeRay is very good!