Fixes Allow to render more than one time with one processor instance.
MODIFY
asciidoctorj-core/src/main/java/org/asciidoctor/extension/processorproxies/BlockMacroProcessorProxy.java
asciidoctorj-core/src/main/java/org/asciidoctor/extension/processorproxies/BlockMacroProcessorProxy.java
@@ -74,7 +74,7 @@ public class BlockMacroProcessorProxy extends AbstractMacroProcessorProxy<BlockM
RubyHashUtil.convertMapToRubyHashWithSymbols(getRuntime(), getProcessor().getConfig())},
Block.NULL_BLOCK);
// The extension config in the Java extension is just a view on the @config member of the Ruby part
- getProcessor().setConfig(new RubyHashMapDecorator((RubyHash)getInstanceVariable(MEMBER_NAME_CONFIG)));
+ getProcessor().updateConfig(new RubyHashMapDecorator((RubyHash)getInstanceVariable(MEMBER_NAME_CONFIG)));
} else {
// First create only the instance passing in the name
String macroName = RubyUtils.rubyToJava(getRuntime(), args[0], String.class);

MODIFY
asciidoctorj-core/src/main/java/org/asciidoctor/extension/processorproxies/DocinfoProcessorProxy.java
asciidoctorj-core/src/main/java/org/asciidoctor/extension/processorproxies/DocinfoProcessorProxy.java
@@ -72,7 +72,7 @@ public class DocinfoProcessorProxy extends AbstractProcessorProxy<DocinfoProcess
RubyHashUtil.convertMapToRubyHashWithSymbols(getRuntime(), getProcessor().getConfig())},
Block.NULL_BLOCK);
// The extension config in the Java extension is just a view on the @config member of the Ruby part
- getProcessor().setConfig(new RubyHashMapDecorator((RubyHash) getInstanceVariable(MEMBER_NAME_CONFIG)));
+ getProcessor().updateConfig(new RubyHashMapDecorator((RubyHash) getInstanceVariable(MEMBER_NAME_CONFIG)));
} else {
// First create only the instance passing in the block name
setProcessor(instantiateProcessor(new HashMap<String, Object>()));

MODIFY
asciidoctorj-core/src/main/java/org/asciidoctor/extension/processorproxies/IncludeProcessorProxy.java
asciidoctorj-core/src/main/java/org/asciidoctor/extension/processorproxies/IncludeProcessorProxy.java
@@ -77,7 +77,7 @@ public class IncludeProcessorProxy extends AbstractProcessorProxy<IncludeProcess
RubyHashUtil.convertMapToRubyHashWithSymbols(getRuntime(), getProcessor().getConfig())},
Block.NULL_BLOCK);
// The extension config in the Java extension is just a view on the @config member of the Ruby part
- getProcessor().setConfig(new RubyHashMapDecorator((RubyHash) getInstanceVariable(MEMBER_NAME_CONFIG)));
+ getProcessor().updateConfig(new RubyHashMapDecorator((RubyHash) getInstanceVariable(MEMBER_NAME_CONFIG)));
} else {
// First create only the instance passing in the block name
setProcessor(instantiateProcessor(new HashMap<String, Object>()));

MODIFY
asciidoctorj-core/src/main/java/org/asciidoctor/extension/processorproxies/InlineMacroProcessorProxy.java
asciidoctorj-core/src/main/java/org/asciidoctor/extension/processorproxies/InlineMacroProcessorProxy.java
@@ -86,7 +86,7 @@ public class InlineMacroProcessorProxy extends AbstractMacroProcessorProxy<Inlin
Block.NULL_BLOCK);
// The Ruby initialize method may have changed the config, therefore copy it back
// because the accessor is routed to the Java Processor.config
- getProcessor().setConfig(new RubyHashMapDecorator((RubyHash) getInstanceVariable(MEMBER_NAME_CONFIG)));
+ getProcessor().updateConfig(new RubyHashMapDecorator((RubyHash) getInstanceVariable(MEMBER_NAME_CONFIG)));
} else {
String macroName = RubyUtils.rubyToJava(getRuntime(), args[0], String.class);
// First create only the instance passing in the block name

MODIFY
asciidoctorj-core/src/main/java/org/asciidoctor/extension/processorproxies/PostprocessorProxy.java
asciidoctorj-core/src/main/java/org/asciidoctor/extension/processorproxies/PostprocessorProxy.java
@@ -71,7 +71,7 @@ public class PostprocessorProxy extends AbstractProcessorProxy<Postprocessor> {
RubyHashUtil.convertMapToRubyHashWithSymbols(getRuntime(), getProcessor().getConfig())},
Block.NULL_BLOCK);
// The extension config in the Java extension is just a view on the @config member of the Ruby part
- getProcessor().setConfig(new RubyHashMapDecorator((RubyHash) getInstanceVariable(MEMBER_NAME_CONFIG)));
+ getProcessor().updateConfig(new RubyHashMapDecorator((RubyHash) getInstanceVariable(MEMBER_NAME_CONFIG)));
} else {
// First create only the instance passing in the block name
setProcessor(instantiateProcessor(new HashMap<String, Object>()));

MODIFY
asciidoctorj-core/src/main/java/org/asciidoctor/extension/processorproxies/TreeprocessorProxy.java
asciidoctorj-core/src/main/java/org/asciidoctor/extension/processorproxies/TreeprocessorProxy.java
@@ -72,7 +72,7 @@ public class TreeprocessorProxy extends AbstractProcessorProxy<Treeprocessor> {
RubyHashUtil.convertMapToRubyHashWithSymbols(getRuntime(), getProcessor().getConfig())},
Block.NULL_BLOCK);
// The extension config in the Java extension is just a view on the @config member of the Ruby part
- getProcessor().setConfig(new RubyHashMapDecorator((RubyHash) getInstanceVariable(MEMBER_NAME_CONFIG)));
+ getProcessor().updateConfig(new RubyHashMapDecorator((RubyHash) getInstanceVariable(MEMBER_NAME_CONFIG)));
} else {
// First create only the instance passing in the block name
setProcessor(instantiateProcessor(new HashMap<String, Object>()));

MODIFY
asciidoctorj-core/src/test/java/org/asciidoctor/extension/WhenJavaExtensionIsRegistered.java
asciidoctorj-core/src/test/java/org/asciidoctor/extension/WhenJavaExtensionIsRegistered.java
@@ -838,6 +838,52 @@ public class WhenJavaExtensionIsRegistered {
}
}
+ @Test
+ public void a_include_processor_class_should_be_executed_twice()
+ throws IOException {
+
+ TestHttpServer.start(Collections.singletonMap("http://example.com/asciidoctorclass.rb", classpath.getResource("org/asciidoctor/internal/asciidoctorclass.rb")));
+
+ JavaExtensionRegistry javaExtensionRegistry = this.asciidoctor.javaExtensionRegistry();
+
+ javaExtensionRegistry.includeProcessor(UriIncludeProcessor.class);
+
+ for (int i = 0; i < 2; i++){
+ String content = asciidoctor.renderFile(
+ classpath.getResource("sample-with-uri-include.ad"),
+ options().toFile(false).get());
+
+ org.jsoup.nodes.Document doc = Jsoup.parse(content, "UTF-8");
+
+ Element contentElement = doc.getElementsByAttributeValue("class", "language-ruby").first();
+
+ assertThat(contentElement.text(), startsWith("module AsciidoctorJ"));
+ }
+ }
+
+ @Test
+ public void a_include_processor_instance_should_be_executed_twice()
+ throws IOException {
+
+ TestHttpServer.start(Collections.singletonMap("http://example.com/asciidoctorclass.rb", classpath.getResource("org/asciidoctor/internal/asciidoctorclass.rb")));
+
+ JavaExtensionRegistry javaExtensionRegistry = this.asciidoctor.javaExtensionRegistry();
+
+ javaExtensionRegistry.includeProcessor(new UriIncludeProcessor(new HashMap<String, Object>()));
+
+ for (int i = 0; i < 2; i++){
+ String content = asciidoctor.renderFile(
+ classpath.getResource("sample-with-uri-include.ad"),
+ options().toFile(false).get());
+
+ org.jsoup.nodes.Document doc = Jsoup.parse(content, "UTF-8");
+
+ Element contentElement = doc.getElementsByAttributeValue("class", "language-ruby").first();
+
+ assertThat(contentElement.text(), startsWith("module AsciidoctorJ"));
+ }
+ }
+
@Test
public void a_block_processor_should_be_executed_when_registered_listing_block_is_found_in_document() throws IOException {

Fixes #579. Allow to render more than one time with one processor instance.