Skip to content

Commit

Permalink
Merge pull request #444 from robertpanzer/fix_443
Browse files Browse the repository at this point in the history
Fixes #443. Don't fail when registering a treeprocessor with an unusu…
  • Loading branch information
robertpanzer committed Apr 8, 2016
2 parents 86a7cb9 + 2be6bf7 commit 342dbc5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ public void treeprocessor(Treeprocessor treeprocessor) {
public void treeprocessor(Class<? extends Treeprocessor> treeProcessor) {
// this may change in future to external class to deal with dynamic
// imports
this.rubyRuntime
.evalScriptlet("java_import " + getImportLine(treeProcessor));
javaImport(rubyRuntime, treeProcessor);
this.asciidoctorModule.treeprocessor(RubyUtils.toRubyClass(rubyRuntime, treeProcessor));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,22 @@ public void shouldAllowLoadingByClass() {
registry.postprocessor(BoldifyPostProcessor.class);
}

@Test
public void shouldAllowTreeprocessorLoadingUsingInstance() {
final JavaExtensionRegistry registry = asciidoctor.javaExtensionRegistry();
registry.treeprocessor(new unusual.extension.UnusualTreeProcessor());
}

@Test
public void shouldAllowTreeprocessorLoadingByClassName() {
final JavaExtensionRegistry registry = asciidoctor.javaExtensionRegistry();
registry.treeprocessor(unusual.extension.UnusualTreeProcessor.class.getCanonicalName());
}

@Test
public void shouldAllowTreeprocessorLoadingByClass() {
final JavaExtensionRegistry registry = asciidoctor.javaExtensionRegistry();
registry.treeprocessor(unusual.extension.UnusualTreeProcessor.class);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package unusual.extension;

import org.asciidoctor.ast.Document;
import org.asciidoctor.extension.Postprocessor;
import org.asciidoctor.extension.Treeprocessor;

/**
* This processor is used only for checking we are able to load extensions from "unusual packages".
*
* @see org.asciidoctor.internal.WhenLoadingExtensionFromUnusualPackage
* @see <a href="https://github.com/asciidoctor/asciidoctorj/issues/250">Issue #250</a>
*/
public class UnusualTreeProcessor extends Treeprocessor {

@Override
public Document process(Document document) {
return document;
}
}

0 comments on commit 342dbc5

Please sign in to comment.