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

[BUG] Missing lang in includedir value for PDF. It is different than for html #556

Closed
ieugen opened this issue Jun 29, 2020 · 9 comments
Closed
Labels
3.x Issues related to the 3.x bug
Milestone

Comments

@ieugen
Copy link
Contributor

ieugen commented Jun 29, 2020

Hi,

I have my CV written in asciidoc and I want to build it with gradle and this gradle plugin.
I've noticed that the includedir value when generating PDF does not contain the lang attribute

My build file is here https://github.com/ieugen/ieugen.ro/blob/gradle-build/cv/build.gradle

plugins {
  id 'org.asciidoctor.jvm.convert' version '3.1.0'
  id 'org.asciidoctor.jvm.pdf' version '3.1.0'
}
asciidoctor {
  languages 'en', 'ro'
  sources {
      include 'index.adoc'
  }
}
asciidoctorj {
  modules {
      pdf {
        version '1.5.3'
      }
  }
  attributesForLang 'en',
    langName : 'English',
    'published-cv' : 'https://ieugen.ro/cv/en'

  attributesForLang 'ro',
    langName : 'Română',
    'published-cv' : 'https://ieugen.ro/cv/ro'
}

asciidoctorPdf { }

Running the command: ./gradlew clean asciidoctor asciidoctorPdf builds the HTML files ok but PDF's are with error:

> Task :cv:asciidoctorPdf
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/home/ieugen/.gradle/wrapper/dists/gradle-6.5-bin/6nifqtx7604sqp1q6g8wikw7p/gradle-6.5/lib/groovy-all-1.3-2.5.11.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
iun. 29, 2020 4:33:43 P.M. uri:classloader:/gems/asciidoctor-2.0.10/lib/asciidoctor/reader.rb preprocess_include_directive
SEVERE: index.adoc: line 36: include file not found: /home/ieugen/proiecte/ieugen.ro/cv/src/docs/asciidoc/{lang}/professional-experience/2016-02-administrator-at-netdava/index.adoc
include file not found: /home/ieugen/proiecte/ieugen.ro/cv/src/docs/asciidoc/{lang}/professional-experience/2016-02-administrator-at-netdava/index.adoc :: index.adoc :: /home/ieugen/proiecte/ieugen.ro/cv//home/ieugen/proiecte/ieugen.ro/cv/src/docs/asciidoc/en/professional-experience/index.adoc:36 (uri:classloader:/gems/asciidoctor-2.0.10/lib/asciidoctor/reader.rb:preprocess_include_directive)
iun. 29, 2020 4:33:44 P.M. uri:classloader:/gems/asciidoctor-2.0.10/lib/asciidoctor/reader.rb preprocess_include_directive
SEVERE: index.adoc: line 39: include file not found: /home/ieugen/proiecte/ieugen.ro/cv/src/docs/asciidoc/{lang}/professional-experience/2012-06-self-employed-at-pfa/index.adoc
include file not found: /home/ieugen/proiecte/ieugen.ro/cv/src/docs/asciidoc/{lang}/professional-experience/2012-06-self-employed-at-pfa/index.adoc :: index.adoc :: /home/ieugen/proiecte/ieugen.ro/cv//home/ieugen/proiecte/ieugen.ro/cv/src/docs/asciidoc/en/professional-experience/index.adoc:39 (uri:classloader:/gems/asciidoctor-2.0.10/lib/asciidoctor/reader.rb:preprocess_include_directive)
iun. 29, 2020 4:33:44 P.M. uri:classloader:/gems/asciidoctor-2.0.10/lib/asciidoctor/reader.rb preprocess_include_directive

@ieugen
Copy link
Contributor Author

ieugen commented Jun 29, 2020

index.pdf

@ysb33r ysb33r added this to the 3.3.0 milestone Jul 1, 2020
@ysb33r ysb33r added 3.x Issues related to the 3.x bug labels Jul 1, 2020
@ysb33r
Copy link
Member

ysb33r commented Jul 1, 2020

I'll try to have a look on the weekend.

@ieugen
Copy link
Contributor Author

ieugen commented Jul 1, 2020

Thank you. I tried ifdef but failed. lang is null apparently.

@ieugen
Copy link
Contributor Author

ieugen commented Jul 11, 2020

Hi, any update on this?

@ieugen
Copy link
Contributor Author

ieugen commented Aug 22, 2020

Hi,
Have you started on this?
I can't wait for this bug anymore so I'm willing to take a shot at it.
I would need some guidance so feel free to give some hints.
I'll make a PR once I have something.
I think a org.asciidoctor.gradle.jvm.MultiLanguageFunctionalSpec would be nice for pdf as well.

@ieugen
Copy link
Contributor Author

ieugen commented Aug 22, 2020

I think the cause of the bug is because asciidoctor {} block that configures the languages is part of the org.asciidoctor.jvm.convert plugin which does HTML conversion.

https://asciidoctor.github.io/asciidoctor-gradle-plugin/development-3.x/user-guide/#_the_new_asciidoctorj_plugin

I think the languages 'en', 'ro' should be set inside the base plugin since they are a cross cutting concern.

@ysb33r : Could you please confirm?
If this is the case I might be able to find a workaround by setting the options/attributes in the base / pdf plugin.

Also a bug fix in this case would be to move the locale code in the base plugin. WDYT?

@ieugen
Copy link
Contributor Author

ieugen commented Aug 22, 2020

It seems I fixed the problem by adding the languages to PDF plugin as well:

asciidoctorPdf {
  languages 'en', 'ro'
}

So this means that this is not a bug, just a miss-understanding on my part.
I expected the languages to be inherited from the convert plugin but that did not happen since all plugins inherit from base plugin.

I do think the language could/should be available in the base since all plugins will use something like this but I'm no expert on asciidoctor and this is just a week opinion.

@ysb33r
Copy link
Member

ysb33r commented Aug 24, 2020

Hi,
Have you started on this?
I can't wait for this bug anymore so I'm willing to take a shot at it.
I would need some guidance so feel free to give some hints.
I'll make a PR once I have something.
I think a org.asciidoctor.gradle.jvm.MultiLanguageFunctionalSpec would be nice for pdf as well.

Have a go at it. We would like to do a 3.3.0 release at soiem stage and it would be good if this is part of it.

It seems I fixed the problem by adding the languages to PDF plugin as well:

asciidoctorPdf {
  languages 'en', 'ro'
}

So this means that this is not a bug, just a miss-understanding on my part.
I expected the languages to be inherited from the convert plugin but that did not happen since all plugins inherit from base plugin.

I do think the language could/should be available in the base since all plugins will use something like this but I'm no expert on asciidoctor and this is just a week opinion.

From experience in using this I am also leaning over to the capability of defining it once for all tasks (as and when needed). The only way for this would be to add the functionliaty to both the asciidoctorj and asciidoctorjs extensions and then let the base tasks query the task extension for the values. This is nto a trivial fix, but it is not difficult either.

I have not looked at his code for a while, but it should be do-able as long as it the test refactoring is done first before actually changing the functionality.

ysb33r added a commit that referenced this issue Aug 24, 2020
@ieugen
Copy link
Contributor Author

ieugen commented Aug 25, 2020

After giving it some thought I think the solution is ok as it is right now.
Also by having it like this you get to choose a different set of languages for HTML and PDF.
If you need the same list, I think you can use a def langs = [ 'ro ', 'es', 'en' ] and assign that.
Moving it in the base plugin in this case will make the plugins more coupled.
Inheritance is the root of all evil :).
I'm closing this.

@ieugen ieugen closed this as completed Aug 25, 2020
lptr pushed a commit to gradle/asciidoctor-gradle-plugin that referenced this issue Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Issues related to the 3.x bug
Projects
None yet
Development

No branches or pull requests

2 participants