Open abelsromero opened 10 years ago
Pygments is not supported with AsciidoctorJ. We recommend that you use CodeRay instead.
We are exploring the possibility of switch to Rouge in Asciidoctor core, which is a Ruby port of Pygments. Since it's pure Ruby, Rouge will work with AsciidoctorJ.
Is there any update regarding the integration of rouge? I tried adding the rouge gems and it fails, which I guess is normal :P
If there're no current plans for it, we could close this issue.
I think the plan moving forward is to support rouge, but we can't do that until it's integrated into core. Until then, this issue should be labeled as "tracking" and scheduled on the milestone "future" (both which need to be created).
Label and milestone updated.
Impeccable answer, thanks.
Any chance of integrating this?
Rouge should now work (assuming you're using Asciidoctor 2) and is preferred.
Having said that, pygments.rb does now work with JRuby, so it could be loaded onto the classpath.
Thanks for that
Is there an example in github thats how to use with Asciidoctor 2? I am currently using 1.5.8
(looks like Asciidoctor 2 is a complete rewrite)
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.8'
classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-beta.4'
}
}
apply plugin: 'org.asciidoctor.convert'
apply plugin: 'java'
asciidoctor {
backends 'html5'
attributes 'build-gradle': file('build.gradle'),
'sourcedir': './snippets',
'endpoint-url': 'http://example.org',
'source-highlighter': 'coderay',
'imagesdir': './images',
'toc': '',
'icons': 'font',
'setanchors': '',
'idprefix': '',
'idseparator': '-',
'docinfo1': ''
}
Got it!.. Will go over this
https://github.com/asciidoctor/asciidoctor-gradle-examples/tree/master/asciidoc-to-pdf-example
Thanks
But, most of these use <2.0.0 :(
No one has stepped forward yet to update them. But yes, they are in need of updating.
You can set the version of Asciidoctor used. See https://github.com/asciidoctor/asciidoctor-maven-examples/blob/master/asciidoc-to-html-example/pom.xml#L16
Created a sample project with rouge highlighter with 2.3.0 version
I have couple of problems
rouge
highlighter (even in pdf)Appreciate if you can have a quick look at it
You're still using asciidoctorj 1.6.2. You need to be using asciidoctorj 2.1.0.
Line highlighting is not supported for rouge in Asciidoctor PDF. See https://github.com/asciidoctor/asciidoctor-pdf/issues/681
You can set the version of core using the version
property (next to pdf.version
).
The CSS is missing for the line highlighting in the HTML. If you view the source, you will see the .hll classes there.
Is this correct?
asciidoctorj {
version '2.1.0'
modules {
pdf.version '1.5.0-beta.4'
}
}
inside modules
(I guess it works either place)
The line highlighting support is something that Asciidoctor adds. Rouge doesn't actually have support for highlighting lines. That's why the CSS is missing from the theme. So you have to add it yourself using a docinfo file.
With this, I got color in html
plugins {
id 'org.asciidoctor.jvm.convert' version '2.3.0'
id 'org.asciidoctor.jvm.pdf' version '2.3.0'
}
repositories {
mavenLocal()
jcenter()
maven { url 'http://rubygems-proxy.torquebox.org/releases' }
mavenCentral()
}
apply plugin: 'java'
version '1.0.0-SNAPSHOT'
asciidoctorj {
version '2.1.0'
modules {
pdf.version '1.5.0-beta.4'
}
}
And can u help me with docinfo aswell
Do you have some link I can follow to make thatchange
Please note that I am quite noob when it comes to asciidoctor. Sorry for asking quite basic questions
I pushed a new version to the sample repo. In that I tried including source from external file
Html version picks the source relative to the .adoc
file properly, but not pdf version
Any idea why?
You are now asking questions about the Gradle plugin. Please either asking them in the Gradle plugin project https://github.com/asciidoctor/asciidoctor-gradle-plugin or in the gitter channel http://gitter.im/asciidoctor/asciidoctorj.
Thanks. Did not know it existed
Hi,
First, of all I'm not sure it is a bug since the readme says that only coderay and highlightjs are supported. However that, I've been testing the 4 possible options and only Pygments is now working due to the following error:
org.jruby.exceptions.RaiseException: (RuntimeError) asciidoctor: FAILED: required gem 'pygments.rb' is not installed. Processing aborted.
If it's not an error, and some extra configuration is required this could be added to the plugin's readme.
I've written a few tests to validate the cases: https://github.com/abelsromero/asciidoctor-maven-plugin/commit/a42215caf8f02a88fc03a6fa0f2b0e6bc7533ac2