asciidoctor / asciidoctor-gradle-plugin

A Gradle plugin that uses Asciidoctor via JRuby to process AsciiDoc source files within the project.
https://asciidoctor.github.io/asciidoctor-gradle-plugin/
Apache License 2.0
285 stars 120 forks source link

HELP - How to config Gradle task asciidoctorPdf use asciidoctor-pdf 2.x not /gems/asciidoctor-pdf-1.5.3 #648

Closed life888888 closed 1 year ago

life888888 commented 1 year ago

How to config Gradle task asciidoctorPdf use asciidoctor-pdf 2.x not /gems/asciidoctor-pdf-1.5.3 ?

mrotteveel commented 1 year ago

You can use

asciidoctorj {
    modules {
        pdf {
            version '2.3.0'
        }
    }
}

See also https://asciidoctor.github.io/asciidoctor-gradle-plugin/development-3.x/user-guide/#asciidoctorj-modules

Be aware, this requires releases of the asciidoctorj-pdf library (project https://github.com/asciidoctor/asciidoctorj-pdf), not just the asciidoctor-pdf Gem

life888888 commented 1 year ago

Need change asciidoctorj version and pdf version together.

modules {
    asciidoctorj {
      version '2.5.6'
    }
    pdf { 
      version '2.3.0'
        }
    }

If not add asciidoctorj version '2.5.6' together, will get error.

Successfully started process 'command '/home/demo/.sdkman/candidates/java/8.0.332-tem/bin/java''
十月 16, 2022 12:45:31 上午 org.asciidoctor.jruby.internal.JRubyAsciidoctor convertFile
嚴重: (NoMethodError) undefined method `role=' for #<Asciidoctor::Block:0x42150b17>
Exception in thread "main" org.asciidoctor.gradle.remote.AsciidoctorRemoteExecutionException: Error running Asciidoctor whilst attempting to process /home/demo/Desktop/AsciidocExamples/asciidoctor-gradle-examples-master/asciidoc-to-pdf-example/src/docs/asciidoc/example-manual.adoc using backend pdf

Why I need asciidoctor-pdf 2.x ?

And now , I can add

       'pdf-fontsdir': '/home/demo/Desktop/notoserif-cjk-tc/fonts;GEM_FONTS_DIR;',
       'pdf-themesdir': '/home/demo/Desktop/notoserif-cjk-tc/themes',      
       'pdf-theme': 'default-ext-notoserif-cjk-tc',

and my default-ext-notoserif-cjk-tc-theme.yml is

# FOR Asciidoctor-PDF 2.x
extends: default-with-font-fallbacks
font:
  catalog:
    merge: true
    Noto Serif CJK TC:
      normal: notoserif-cjk-tc-normal.ttf
      bold: notoserif-cjk-tc-bold.ttf
      italic: notoserif-cjk-tc-italic.ttf
      bold_italic: notoserif-cjk-tc-bold_italic.ttf
  fallbacks: [M+ 1p Fallback, Noto Emoji, Noto Serif CJK TC]      
base_font_family: Noto Serif CJK TC

THANK YOU.