resolves add method to change sourcemap option on Document at runtime
MODIFY
asciidoctorj-api/src/main/java/org/asciidoctor/ast/Document.java
asciidoctorj-api/src/main/java/org/asciidoctor/ast/Document.java
@@ -58,4 +58,19 @@ public interface Document extends StructuralNode {
* @return
*/
int getAndIncrementCounter(String name, int initialValue);
+
+ /**
+ * @return Whether the sourcemap is enabled.
+ */
+ boolean isSourcemap();
+
+ /**
+ * Toggles the sourcemap option.
+ *
+ * This method must be called before the document is parsed, such as
+ * from a Preprocessor extension. Otherwise, it has no effect.
+ *
+ * @param state The state in which to put the sourcemap (true = on, false = off).
+ */
+ void setSourcemap(boolean state);
}

MODIFY
asciidoctorj-core/src/main/java/org/asciidoctor/ast/impl/DocumentImpl.java
asciidoctorj-core/src/main/java/org/asciidoctor/ast/impl/DocumentImpl.java
@@ -64,4 +64,13 @@ public class DocumentImpl extends StructuralNodeImpl implements Document {
return getInt("counter", name, initialValue);
}
+ @Override
+ public boolean isSourcemap() {
+ return getBoolean("sourcemap");
+ }
+
+ @Override
+ public void setSourcemap(boolean state) {
+ setBoolean("sourcemap", state);
+ }
}

MODIFY
asciidoctorj-core/src/main/java/org/asciidoctor/internal/RubyObjectWrapper.java
asciidoctorj-core/src/main/java/org/asciidoctor/internal/RubyObjectWrapper.java
@@ -79,6 +79,10 @@ public class RubyObjectWrapper {
}
}
+ public void setBoolean(String propertyName, boolean value) {
+ setRubyProperty(propertyName, runtime.newBoolean(value));
+ }
+
public int getInt(String propertyName, Object... args) {
IRubyObject result = getRubyProperty(propertyName, args);
if (result instanceof RubyNil) {

resolves #508 add method to change sourcemap option on Document at runtime