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

Allow the source highlighter to be enabled in the site plugin #160

Closed
mojavelinux opened this issue May 6, 2015 · 15 comments
Closed

Allow the source highlighter to be enabled in the site plugin #160

mojavelinux opened this issue May 6, 2015 · 15 comments
Assignees
Milestone

Comments

@mojavelinux
Copy link
Member

It should be possible to enable the source highlighter from the plugin configuration when using the site plugin.

This issue involves two parts:

  1. An option for enabling the source highlighter (similar to the main plugin)
  2. Ensure that the source highlighting works when enabled (any necessary styles are included)

As a workaround, you can enable the source highlighter by adding an explicit attribute in the document header.

@mojavelinux
Copy link
Member Author

@paranoiabla, you mentioned you got this working in light of recent changes to the plugin. Could you elaborate?

@ptahchiev
Copy link
Contributor

I'm using the :source-highlighter: coderay option in the header of each asciidoctor file. That seems to work. The drawback is that if you want to change it, you have to go through all the files and manually change the header.

@mojavelinux
Copy link
Member Author

Is it possible to pass configuration to a Maven site module? If so, then we could pass that on to AsciidoctorJ.

@abelsromero
Copy link
Member

Is it possible to pass configuration to a Maven site module?

According to documentation you can add a site descriptor (site.xml in src/site) to customize the layout and other things (ref). Inside it you can add a section for custom properties <custom> http://maven.apache.org/plugins/maven-site-plugin/examples/sitedescriptor.html#Custom_Properties.

This could be an option, the thing is if we should support all the options from process-asciidoc mojo.

Also, so far I've only found a couple of example of how to recover custom properties and they use, either apache velocity scripts to directly generate the HTML, or some velocity api whose usage is not clear to me (https://github.com/andriusvelykis/reflow-maven-skin/blob/master/reflow-velocity-tools/src/main/java/lt/velykis/maven/skins/reflow/SkinConfigTool.java).
So, what I'm trying to say is that maybe getting the custom section to 'AsciidoctorParser' class won't be task for faint-hearted 😃 Custom XML parsing is always an option, but I'm sure there must be a better way provided by the site-plugin tools.

@mojavelinux
Copy link
Member Author

One other possibility is to have a convention to set Maven properties with a special prefix to pass options to Asciidoctor.

<asciidoc-site-source-highlighter>coderay</asciidoc-site-source-highlighter>

or we could stuff them all into a single property.

<maven-site-asciidoc-attributes>source-highlighter=coderay toc=macro</maven-site-asciidoc-attributes>

We should be able to read global attributes from the Maven plugin. It's not super clean, but it seems simpler than the alternatives thus far.

@tcollignon
Copy link

Hello,

the possiblity of using maven properties seem good for me, with this you can use every parameter of the maven plugin

Thanks for all answer guys, I will test this before having best solution

@tcollignon
Copy link

With :source-highlighter: coderay it's better but not very beautiful. Did you add somme css style in maven resources ?
For example I have not found CodeRay highlight css class, this is my html maven site

<div>
<pre class="CodeRay highlight">
<tt>
<span class="tag">&lt;pool-init&gt;</span>20<span class="tag">&lt;/pool-init&gt;</span>
<span class="tag">&lt;pool-min&gt;</span>20<span class="tag">&lt;/pool-min&gt;</span>
<span class="tag">&lt;pool-max&gt;</span>20<span class="tag">&lt;/pool-max&gt;</span>
</tt>
</pre>
</div>

for this input :

[source,xml]
----
<pool-init>20</pool-init>
<pool-min>20</pool-min>
<pool-max>20</pool-max>
----

@mojavelinux
Copy link
Member Author

You have two options. You can either grab the CodeRay stylesheet from the Asciidoctor repository and stick that into the template of your site or you can inline the styles using a second AsciiDoc attribute:

:coderay-css: style

@tcollignon
Copy link

Wonderful ! asciidoctor is very powerfull!
The last things still remain is the <tt> block who looks ugly, maybe it's the apache fluido skin :
tt { background-color: #fee9cc; }

@mojavelinux
Copy link
Member Author

I'm not sure what's adding the <tt> element. That shouldn't be happening. Are you sure that isn't getting added by Maven somehow?

@mojavelinux
Copy link
Member Author

Aha. This may be something that's fixed by 3dc576f. Are you using the SNAPSHOT version? If not, this is a known issue because plexus messes with the output in a seriously nasty way right now.

@tcollignon
Copy link

Ohh I see, thank you, I will use a SNAPSHOT version until it will be releases.

@abelsromero
Copy link
Member

I've been testing the idea of passing Maven properties and this does not work. Basically the Doxia Parser does not recognize the @parameter notation in the attributes, which makes sense because AsciidoctorParser is not a plugin itself.

In the meantime I have sent a message to the user's mailing list, to see if they can offer some idea.

@ptahchiev
Copy link
Contributor

Just a quick question here - is it possible to pass the properties as part of the <systemPropertyVariables>?

@mojavelinux mojavelinux added this to the 1.5.3 milestone Dec 14, 2015
@mojavelinux mojavelinux self-assigned this Dec 14, 2015
mojavelinux added a commit to mojavelinux/asciidoctor-maven-plugin that referenced this issue Dec 14, 2015
…or#168 & asciidoctor#160 enable configuratino for site parser

- rewrite Maven Site parser to make more organized and extensible
- pass AsciiDoc configuration in Maven Site plugin to Asciidoctor API
- enhance Maven Site integration test
  - add custom template
  - add include
  - add source highlighting
  - make validation code compatible with Java 6
- enable integration tests on Travis
- remove unused legacy site module
mojavelinux added a commit to mojavelinux/asciidoctor-maven-plugin that referenced this issue Dec 14, 2015
…or#168 & asciidoctor#160 enable configuration for site parser

- rewrite Maven Site parser to make more organized and extensible
- pass AsciiDoc configuration in Maven Site plugin to Asciidoctor API
- enhance Maven Site integration test
  - add custom template
  - add include
  - add source highlighting
  - make validation code compatible with Java 6
- enable integration tests on Travis
- remove unused legacy site module
mojavelinux added a commit to mojavelinux/asciidoctor-maven-plugin that referenced this issue Dec 14, 2015
…or#168 & asciidoctor#160 enable configuration for site parser

- rewrite AsciidoctorParser (used by Maven Site Plugin) to make it more organized and extensible
- pass AsciiDoc configuration defined in Maven Site plugin to the Asciidoctor API
- enhance Maven Site integration test
  - add custom template
  - add include
  - add source highlighting
  - make validation code compatible with Java 6
- enable integration tests on Travis CI
- remove unused legacy site module
- fix license headers
- minor cleanups
mojavelinux added a commit to mojavelinux/asciidoctor-maven-plugin that referenced this issue Dec 14, 2015
…or#168 & asciidoctor#160 enable configuration for site parser

- rewrite AsciidoctorParser (used by Maven Site Plugin) to make it more organized and extensible
- pass AsciiDoc configuration defined in Maven Site plugin to the Asciidoctor API
- enhance Maven Site integration test
  - add custom template
  - add include
  - add source highlighting
  - make validation code compatible with Java 6
- enable integration tests on Travis CI
- remove unused legacy site module
- fix license headers
- minor cleanups
@mojavelinux
Copy link
Member Author

the Doxia Parser does not recognize the @parameter notation in the attributes

The secret was to use the @Requirement annotation, which allows you to inject components available in the component tree into the class. If we inject the MavenProject, as shown here:

@Requirement
protected MavenProject project;

then we can access the resolved configuration for the site plugin using the following call:

project.getGoalConfiguration("org.apache.maven.plugins", "maven-site-plugin", "site", "site");

With a little bit of work, it's possible to walk the DOM and extract the configuration we are interested in.

mojavelinux added a commit to mojavelinux/asciidoctor-maven-plugin that referenced this issue Dec 14, 2015
…or#168 & asciidoctor#160 enable configuration for site parser

- rewrite AsciidoctorParser (used by Maven Site Plugin) to make it more organized and extensible
- specify baseDir by default when invoking Asciidoctor API
- pass AsciiDoc configuration defined in Maven Site plugin to the Asciidoctor API
  - API options (e.g., templateDir)
  - Ruby options (e.g., requires)
  - AsciiDoc attributes (e.g., icons=font)
- enhance Maven Site integration test
  - add custom template
  - add include
  - add source highlighting
  - make validation code compatible with Java 6
- enable integration tests on Travis CI
- remove unused legacy site module
- fix license headers
- minor cleanups
mojavelinux added a commit to mojavelinux/asciidoctor-maven-plugin that referenced this issue Dec 14, 2015
…or#168 & asciidoctor#160 enable configuration for site parser

- rewrite AsciidoctorParser (used by Maven Site Plugin) to make it more organized and extensible
- specify baseDir by default when invoking Asciidoctor API
- pass AsciiDoc configuration defined in Maven Site plugin to the Asciidoctor API
  - API options (e.g., templateDir)
  - Ruby options (e.g., requires)
  - AsciiDoc attributes (e.g., icons=font)
- enhance Maven Site integration test
  - add custom template
  - add include
  - add source highlighting
  - make validation code compatible with Java 6
- enable integration tests on Travis CI and Appveyor
- remove unused legacy site module
- fix license headers
- minor cleanups
mojavelinux added a commit to mojavelinux/asciidoctor-maven-plugin that referenced this issue Dec 14, 2015
…or#168 & asciidoctor#160 enable configuration for site parser

- rewrite AsciidoctorParser (used by Maven Site Plugin) to make it more organized and extensible
- specify baseDir by default when invoking Asciidoctor API
- pass AsciiDoc configuration defined in Maven Site plugin to the Asciidoctor API
  - API options (e.g., templateDir)
  - Ruby options (e.g., requires)
  - AsciiDoc attributes (e.g., icons=font)
- enhance Maven Site integration test
  - add custom template
  - add include
  - add source highlighting
  - make validation code compatible with Java 6
- enable integration tests on Travis CI and Appveyor
- remove unused legacy site module
- fix license headers
- minor cleanups
mojavelinux added a commit that referenced this issue Dec 15, 2015
resolves #170, #180, #179, #168 & #160 enable configuration for site parser
abelsromero pushed a commit to abelsromero/asciidoctor-maven-plugin that referenced this issue Jan 8, 2016
…or#168 & asciidoctor#160 enable configuration for site parser

- rewrite AsciidoctorParser (used by Maven Site Plugin) to make it more organized and extensible
- specify baseDir by default when invoking Asciidoctor API
- pass AsciiDoc configuration defined in Maven Site plugin to the Asciidoctor API
  - API options (e.g., templateDir)
  - Ruby options (e.g., requires)
  - AsciiDoc attributes (e.g., icons=font)
- enhance Maven Site integration test
  - add custom template
  - add include
  - add source highlighting
  - make validation code compatible with Java 6
- enable integration tests on Travis CI and Appveyor
- remove unused legacy site module
- fix license headers
- minor cleanups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants