-
Notifications
You must be signed in to change notification settings - Fork 3
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
Some example in README don't match implementation #14
Comments
Here are some examples related to This is what one would expect per documentation
Error is
Now trying without underscore: docinfoprocessor { document ->
'<div>FOOBAR</div>'
} and the error is
The anove I would expect as the code at https://github.com/asciidoctor/asciidoctorj-groovy-dsl/blob/v1.0.0.Alpha2/src/main/groovy/org/asciidoctor/groovydsl/AsciidoctorExtensionHandler.groovy#L136 only supports But now reading that code I sould be able to pass a combination of options and the closure i.e. docinfo_processor( at_location : 'footer') { document ->
'<div>FOOBAR</div>'
} Error is this case is
Looking at the code - https://github.com/asciidoctor/asciidoctorj-groovy-dsl/blob/v1.0.0.Alpha2/src/main/groovy/org/asciidoctor/groovydsl/extensions/DelegatingDocinfoProcessor.groovy#L25 - the above should be possible to construct. |
Part of the problem is that the asciidoctor-gradle-plugin references an old version of the asciidoctorj-groovy-dsl in its current version, which unfortunately doesn't even match the test dependency. The current release though is 1.0.0.alpha2, I'll create a PR for that. The DocInfo example should generally work, I got it working like so: docinfo_processor( location : ':footer') { document ->
'<div>FOOBAR</div>'
} I can update the README to include this. The block_macro and inline_macro examples worked for me (with the correct versions) like this: asciidoctorj {
version = '1.5.5'
groovyDslVersion = '1.0.0.Alpha2'
}
asciidoctor {
extensions {
docinfo_processor( location : ':footer') { document ->
'<div>FOOBAR</div>'
}
block(name: 'BIG', contexts: [':paragraph']) {
parent, reader, attributes ->
def upperLines = reader.readLines()
.collect {it.toUpperCase()}
.inject('') {a, b -> a + '\n' + b}
createBlock(parent, 'paragraph', [upperLines], attributes, [:])
}
block('small') {
parent, reader, attributes ->
def lowerLines = reader.readLines()
.collect {it.toLowerCase()}
.inject('') {a, b -> a + '\n' + b}
createBlock(parent, 'paragraph', [lowerLines], attributes, [:])
}
block_macro('capitalize') {
parent, target, attributes ->
def capitalLines = target.toLowerCase()
.tokenize('_')
.collect { it.capitalize() }
.join(' ')
createBlock(parent, 'pass', [capitalLines], attributes)
}
inline_macro('man') {
parent, target, attributes ->
def options = ["type": ":link", "target": target + ".html"]
println "parent $parent"
createInline(parent, "anchor", target, attributes, options).convert()
}
}
} |
Actually the blockMacro example isn't fully correct. block_macro('capitalize') {
parent, target, attributes ->
def capitalLines = target.toLowerCase()
.tokenize('_')
.collect { it.capitalize() }
.join(' ')
createBlock(parent, 'pass', [capitalLines], attributes, [:])
} Note the additional parameter for the options in the call to createBlock(). |
This example isn't working either:
excert of my build.gradle:
It would be great to know, if the groovy dsl is still an active project or if it's better to use java api. |
The project is active, but not currently updated to the last AsciidoctorJ version and also there's an error in the documentation that affects your scenario. For the version update, I already have a PR ready with that and the fix in the documentation. But there are other things that I think would be nice to include, I'll open another for discussion. Feel free to join if there's anything you find is missing. |
inline_macro
, but to get things to work one has to callinlinemacro
instead.block_macro
does not work at all. Keeps coming back with an error sayingblockMacro
(not capitalization) not found. Was using the verson of the groocy-dsl that ships with the 1.5.3. version of the Gradle plugin for Asciidoctor.docinfoprocessor
does not document how to apply to head or footer.The text was updated successfully, but these errors were encountered: