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

How can I configure the gradle asciidoctor 2.0 plugin to use pygments.rb as higlighter? #326

Closed
lwolter opened this issue Apr 4, 2019 · 7 comments
Labels
2.x Issue related to the 2.x series
Milestone

Comments

@lwolter
Copy link

lwolter commented Apr 4, 2019

Unfortunately, I was not able to configure pygments.rb as a highlighter with the gradle asciidoctor plugin. For a small configuration example, I would be grateful.
With direct call of asciidoctor and assignment as call parameter I use pygments for a long time for the PDF creation.

@lwolter lwolter changed the title How can I configure the gradle asciidoctor 2.0 plugin to use pygments.rg as higlighter? How can I configure the gradle asciidoctor 2.0 plugin to use pygments.rb as higlighter? Apr 4, 2019
@mojavelinux
Copy link
Member

If possible, I would advise that you consider making the switch from Pygments to Rouge. Rouge is designed to be a drop-in replacement for Pygments, and now comes integrated directly in Asciidoctor. The benefit is that it requires no additional gems or system calls.

Having said that, I realize that if it's possible to continue using Pygments with the 2.0 version of the Gradle plugin, that should be documented. If it's not possible, that should be documented as well.

@ysb33r
Copy link
Member

ysb33r commented Apr 4, 2019

We never had an example of that in the plugin before. I will investigate whether pygments work.

@ysb33r ysb33r added the 2.x Issue related to the 2.x series label Apr 4, 2019
@ysb33r
Copy link
Member

ysb33r commented Apr 11, 2019

The following should work

plugins {
  id 'org.asciidoctor.jvm.pdf' version '2.0.0'
  id 'org.asciidoctor.jvm.gems' version '2.0.0'
}

repositories {
    jcenter()
    maven { url 'http://rubygems-proxy.torquebox.org/releases' }
}

dependencies {
  asciidoctorGems 'rubygems:pygments:1.2.1'
}

asciidoctorPdf {
  dependsOn asciidoctorGemsPrepare
  sourceDir 'docs'

  asciidoctorj {
    requires 'pygments'
    attributes 'source-highlighter' : 'pygments'
  }
}

Sometime Torquebox goes awry and then it is not possible to retrieve GEMs in a maven way when they are not in the Torquebox cache already.

P.S. The reason why we never had a test for this is that it requires python 2.x to be installed. Even if we used a Docker container for the testing it will add quite a bit of time to the existing test run time. (A full build with all the tests are close to 50min atm).

@ysb33r
Copy link
Member

ysb33r commented Apr 11, 2019

If you the option to switch to rouge then it will simplify

plugins {
  id 'org.asciidoctor.jvm.pdf' version '2.0.0'
}

repositories {
    jcenter()
}

asciidoctorPdf {
  sourceDir 'docs'

  asciidoctorj {
    attributes 'source-highlighter' : 'rouge'
  }
}

ysb33r added a commit to ysb33r/asciidoctor-gradle-plugin that referenced this issue Apr 11, 2019
ysb33r added a commit that referenced this issue Apr 11, 2019
Add example of using Pygments source highlighter (#326)
@ysb33r ysb33r mentioned this issue Apr 11, 2019
@ysb33r ysb33r added this to the 2.1.0 milestone Apr 11, 2019
@ysb33r
Copy link
Member

ysb33r commented Apr 11, 2019

I have also added an example to the appendix section of the README.

@lwolter
Copy link
Author

lwolter commented Apr 12, 2019

Sorry, unfortunately I get the following error messages:
`Execution failed for task ':asciidoctorGemsPrepare'.

Could not resolve all files for configuration ':asciidoctorGems'.
Could not resolve rubygems:pygments:1.2.1.
Required by:
project :
> Could not resolve rubygems:pygments:1.2.1.
> Could not get resource 'http://rubygems-proxy.torquebox.org/releases/rubygems/pygments/1.2.1/pygments-1.2.1.pom'.
> Could not GET 'http://rubygems-proxy.torquebox.org/releases/rubygems/pygments/1.2.1/pygments-1.2.1.pom'. Received status code 500 from server: Internal Server Error
`

@ysb33r
Copy link
Member

ysb33r commented Apr 12, 2019

That's an issue with torquebox as far as I am aware. Raised jruby/rubygems-servlets#18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Issue related to the 2.x series
Projects
None yet
Development

No branches or pull requests

4 participants