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 SiteConfig to specify attributes for Asciidoctor.convert #8

Closed
jechlin opened this issue Jul 22, 2015 · 3 comments
Closed

allow SiteConfig to specify attributes for Asciidoctor.convert #8

jechlin opened this issue Jul 22, 2015 · 3 comments

Comments

@jechlin
Copy link

jechlin commented Jul 22, 2015

For instance I want to pass:

"icons" => "font"

to convert in tools/asciidoc-bridge/asciidoc_bridge.rb, and I may not want coderay highlighter.

Eg in SiteConfig I want to put:

asciidoc {
    opts = [
        "source-highlighter" : "highlightjs",
        icons : "font",
    ]
}

and have that passed through.

@jechlin
Copy link
Author

jechlin commented Jul 22, 2015

NB... had a crack at this myself:

com.sysgears.grain.markup.asciidoc.AsciiDoctorProcessor#process:

    public String process(String source) {
        def opts = config.asciidoc?.opts ?: [ "source-highlighter": "coderay" ]
        ruby.rpc.with {
            AsciidocBridge.convert(source, opts)
        }
    }

tools/asciidoc-bridge/asciidoc_bridge.rb:

  def convert(source, opts)
    begin
      return Asciidoctor.convert(source, :safe => 0, :attributes => opts)

but for some reason it's not working, even though I've added logging and it looks like the right things are being passed through.

When I say not working I mean it's not picking up icon:font, although when I hard-code in the .rb file it works. May be a conversion issue between LinkedHashMap and ruby hash? I know almost nothing about ruby.

dmitriypdv added a commit that referenced this issue Aug 3, 2015


Configured Asciidoctor processor to read and send document attributes from the site configuration to Asciidoctor convert method. Updated the RPC executor to pass a set of key -> value pairs with a Java Map.
Signed-off-by: Dmitriy Pavlenko <dmitriy.pavlenko@sysgears.com>
@dmitriypdv
Copy link
Member

Grain was updated to read Acsiidoctor custom document processing attributes from the SiteConfig -- the features.asciidoc.opts setting -- and pass them to the Asciidoctor.convert method. The attributes can be defined in the following way:

/SiteConfig.groovy:

features {
     asciidoc {
         opts = ['source-highlighter': 'coderay',
                 'icons': 'font']
    }
 }

You can find the example configuration in the theme template.

As Victor had mentioned in the mailing list, the RPC executor had to be modified in order to pass a map of string key-value pairs to asciidoc bridge in AsciidocBridge.convert(source, opts).

@jechlin
Copy link
Author

jechlin commented Aug 3, 2015

Awesome, thanks a lot.

On Mon, Aug 3, 2015 at 2:54 PM, Dmitriy Pavlenko notifications@github.com
wrote:

Grain was updated to read Acsiidoctor custom document processing
attributes from the SiteConfig -- the features.asciidoc.opts setting --
and pass them to the Asciidoctor.convert method. The attributes can be
defined in the following way:

/SiteConfig.groovy:

features {
asciidoc {
opts = ['source-highlighter': 'coderay',
'icons': 'font']
}
}

You can find the example configuration in the theme template
sysgears/grain-theme-template@7df608c
.

As Victor had mentioned in the mailing list
https://groups.google.com/forum/#!msg/grain-user/TT1YszsHLgg/frwURxNX0UUJ,
the RPC executor had to be modified in order to pass a map of string
key-value pairs to asciidoc bridge in AsciidocBridge.convert(source, opts)
.


Reply to this email directly or view it on GitHub
#8 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants