diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index 1dc7f942d..9b7761b3e 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -37,6 +37,7 @@ Improvement::
* Return Document AST when using convert or convertFile with appropriate options (#1171) (@abelsromero)
* Expose Links in the catalog (#1183) (@abelsromero)
* BREAKING: Remove deprecated methods in Options, OptionsBuilder, Attributes & AttributesBuilder (#1199) (@abelsromero)
+* BREAKING: Remove deprecated Asciidoctor interface (#1201) (@abelsromero)
Bug Fixes::
diff --git a/asciidoctorj-api/src/main/java/org/asciidoctor/Asciidoctor.java b/asciidoctorj-api/src/main/java/org/asciidoctor/Asciidoctor.java
index 6a8cbe671..ce0051c5d 100644
--- a/asciidoctorj-api/src/main/java/org/asciidoctor/Asciidoctor.java
+++ b/asciidoctorj-api/src/main/java/org/asciidoctor/Asciidoctor.java
@@ -1,7 +1,6 @@
package org.asciidoctor;
import org.asciidoctor.ast.Document;
-import org.asciidoctor.ast.DocumentHeader;
import org.asciidoctor.converter.AbstractConverter;
import org.asciidoctor.converter.JavaConverterRegistry;
import org.asciidoctor.extension.ExtensionGroup;
@@ -30,36 +29,6 @@
*/
public interface Asciidoctor extends AutoCloseable {
- /**
- * Parse the AsciiDoc source input into a Document {@link Document} and
- * convert it to the specified backend format.
- *
- * Accepts input as String object.
- * @deprecated User {@link #convert(String, Options)} instead.
- *
- * @param content the AsciiDoc source as String.
- * @param options a Map of options to control processing (default: {}).
- * @return the rendered output String is returned
- */
- @Deprecated
- String convert(String content, Map options);
-
- /**
- * Parse the AsciiDoc source input into a Document {@link Document} and
- * convert it to the specified backend format.
- *
- * Accepts input as String object.
- * @deprecated Use {@link #convert(String, Options, Class)} instead.
- *
- * @param content the AsciiDoc source as String.
- * @param options a Map of options to control processing (default: {}).
- * @param expectedResult the expected return type. Usually {@link String} for HTML based formats.
- * In this case {@link #convert(String, Map)} is the same.
- * @return the rendered output String is returned
- */
- @Deprecated
- T convert(String content, Map options, Class expectedResult);
-
/**
* Parse the AsciiDoc source input into a Document {@link Document} and
* convert it to the specified backend format.
@@ -90,52 +59,6 @@ public interface Asciidoctor extends AutoCloseable {
*/
T convert(String content, Options options, Class expectedResult);
- /**
- * Parse the AsciiDoc source input into a Document {@link Document} and
- * convert it to the specified backend format.
- *
- * Accepts input as String object.
- * @deprecated Use {@link #convert(String, Options)} instead.
- *
- * @param content the AsciiDoc source as String.
- * @param options a Map of options to control processing (default: {}).
- * @return the rendered output String is returned
- */
- @Deprecated
- String convert(String content, OptionsBuilder options);
-
- /**
- * Parse the AsciiDoc source input into a Document {@link Document} and
- * convert it to the specified backend format.
- *
- * Accepts input as String object.
- * @deprecated Use {@link #convert(String, Options, Class)} instead.
- *
- * @param content the AsciiDoc source as String.
- * @param options a Map of options to control processing (default: {}).
- * @param expectedResult the expected return type. Usually {@link String} for HTML based formats.
- * In this case {@link #convert(String, OptionsBuilder)} is the same.
- * @return the rendered output String is returned
- */
- @Deprecated
- T convert(String content, OptionsBuilder options, Class expectedResult);
-
- /**
- * Parse the document read from reader sending the converted result to
- * writer.
- * @deprecated Use {@link #convert(Reader, Writer, Options)} instead.
- *
- * @param contentReader where asciidoc content is read.
- * @param rendererWriter where rendered content is written. Writer is flushed, but not
- * closed.
- * @param options a Map of options to control processing (default: {}).
- * @throws IOException if an error occurs while writing rendered content, this
- * exception is thrown.
- */
- @Deprecated
- void convert(Reader contentReader, Writer rendererWriter,
- Map options) throws IOException;
-
/**
* Parse the document read from reader sending the converted result to
* writer.
@@ -150,77 +73,6 @@ void convert(Reader contentReader, Writer rendererWriter,
void convert(Reader contentReader, Writer rendererWriter, Options options)
throws IOException;
- /**
- * Parse the document read from reader sending the converted result to
- * writer.
- * @deprecated Use {@link #convert(Reader, Writer, Options)} instead.
- *
- * @param contentReader where asciidoc content is read.
- * @param rendererWriter where rendered content is written. Writer is flushed, but not
- * closed.
- * @param options a Map of options to control processing (default: {}).
- * @throws IOException if an error occurs while writing rendered content, this
- * exception is thrown.
- */
- @Deprecated
- void convert(Reader contentReader, Writer rendererWriter,
- OptionsBuilder options) throws IOException;
-
- /**
- * Parse the AsciiDoc source input into a Document {@link Document} and
- * convert it to the specified backend format.
- *
- * Accepts input as File.
- *
- * If the :in_place option is true, and the input is a File, the output is
- * written to a file adjacent to the input file, having an extension that
- * corresponds to the backend format. Otherwise, if the :to_file option is
- * specified, the file is written to that file. If :to_file is not an
- * absolute path, it is resolved relative to :to_dir, if given, otherwise
- * the Document#base_dir. If the target directory does not exist, it will
- * not be created unless the :mkdirs option is set to true. If the file
- * cannot be written because the target directory does not exist, or because
- * it falls outside of the Document#base_dir in safe mode, an IOError is
- * raised.
- * @deprecated Use {@link #convertFile(File, Options)} instead.
- *
- * @param file an input Asciidoctor file.
- * @param options a Map of options to control processing (default: {}).
- * @return returns nothing if the rendered output String is written to a
- * file.
- */
- @Deprecated
- String convertFile(File file, Map options);
-
- /**
- * Parse the AsciiDoc source input into a Document {@link Document} and
- * convert it to the specified backend format.
- *
- * Accepts input as File.
- *
- * If the :in_place option is true, and the input is a File, the output is
- * written to a file adjacent to the input file, having an extension that
- * corresponds to the backend format. Otherwise, if the :to_file option is
- * specified, the file is written to that file. If :to_file is not an
- * absolute path, it is resolved relative to :to_dir, if given, otherwise
- * the Document#base_dir. If the target directory does not exist, it will
- * not be created unless the :mkdirs option is set to true. If the file
- * cannot be written because the target directory does not exist, or because
- * it falls outside of the Document#base_dir in safe mode, an IOError is
- * raised.
- * @deprecated User {@link #convertFile(File, Options, Class)} instead.
- *
- * @param file an input Asciidoctor file.
- * @param options a Map of options to control processing (default: {}).
- * @param expectedResult the expected return type. Usually {@link String} for HTML based formats.
- * In this case {@link #convertFile(File, Map)} is the same.
- * @return returns nothing if the rendered output is written to a
- * file.
- */
- @Deprecated
- T convertFile(File file, Map options, Class expectedResult);
-
-
/**
* Parse the AsciiDoc source input into a Document {@link Document} and
* convert it to the specified backend format.
@@ -265,79 +117,12 @@ void convert(Reader contentReader, Writer rendererWriter,
* @param file an input Asciidoctor file.
* @param options options to control processing (default: empty).
* @param expectedResult the expected return type. Usually {@link String} for HTML based formats.
- * In this case {@link #convertFile(File, Map)} is the same.
+ * In this case {@link #convertFile(File, Options)} is the same.
* @return returns nothing if the rendered output is written to a
* file.
*/
T convertFile(File file, Options options, Class expectedResult);
- /**
- * Parse the AsciiDoc source input into a Document {@link Document} and
- * convert it to the specified backend format.
- *
- * Accepts input as File.
- *
- * If the :in_place option is true, and the input is a File, the output is
- * written to a file adjacent to the input file, having an extension that
- * corresponds to the backend format. Otherwise, if the :to_file option is
- * specified, the file is written to that file. If :to_file is not an
- * absolute path, it is resolved relative to :to_dir, if given, otherwise
- * the Document#base_dir. If the target directory does not exist, it will
- * not be created unless the :mkdirs option is set to true. If the file
- * cannot be written because the target directory does not exist, or because
- * it falls outside of the Document#base_dir in safe mode, an IOError is
- * raised.
- * @deprecated Use {@link #convertFile(File, Options)} instead.
- *
- * @param file an input Asciidoctor file.
- * @param options a Map of options to control processing (default: {}).
- * @return returns nothing if the rendered output String is written to a
- * file.
- */
- @Deprecated
- String convertFile(File file, OptionsBuilder options);
-
- /**
- * Parse the AsciiDoc source input into a Document {@link Document} and
- * convert it to the specified backend format.
- *
- * Accepts input as File.
- *
- * If the :in_place option is true, and the input is a File, the output is
- * written to a file adjacent to the input file, having an extension that
- * corresponds to the backend format. Otherwise, if the :to_file option is
- * specified, the file is written to that file. If :to_file is not an
- * absolute path, it is resolved relative to :to_dir, if given, otherwise
- * the Document#base_dir. If the target directory does not exist, it will
- * not be created unless the :mkdirs option is set to true. If the file
- * cannot be written because the target directory does not exist, or because
- * it falls outside of the Document#base_dir in safe mode, an IOError is
- * raised.
- * @deprecated User {@link #convertFile(File, Options, Class)} instead.
- *
- * @param file an input Asciidoctor file.
- * @param options a Map of options to control processing (default: {}).
- * @param expectedResult the expected return type. Usually {@link String} for HTML based formats.
- * In this case {@link #convertFile(File, Map)} is the same.
- * @return returns nothing if the rendered output is written to a
- * file.
- */
- @Deprecated
- T convertFile(File file, OptionsBuilder options, Class expectedResult);
-
- /**
- * Convert all AsciiDoc files found in directoryWalker.
- * See {@code AsciiDocDirectoryWalker} for reference strategy.
- * @deprecated Use {@link #convertDirectory(Iterable, Options)} instead.
- *
- * @param directoryWalker strategy used to retrieve all files to be rendered.
- * @param options a Map of options to control processing (default: {}).
- * @return returns an array of 0 positions if the rendered output is written
- * to a file.
- */
- @Deprecated
- String[] convertDirectory(Iterable directoryWalker, Map options);
-
/**
* Convert all AsciiDoc files found in directoryWalker.
* See {@code AsciiDocDirectoryWalker} for reference strategy.
@@ -349,31 +134,6 @@ void convert(Reader contentReader, Writer rendererWriter,
*/
String[] convertDirectory(Iterable directoryWalker, Options options);
- /**
- * Convert all AsciiDoc files found in directoryWalker.
- * See {@code AsciiDocDirectoryWalker} for reference strategy.
- * @deprecated Use {@link #convertDirectory(Iterable, Options)} instead.
- *
- * @param directoryWalker strategy used to retrieve all files to be rendered.
- * @param options a Map of options to control processing (default: {}).
- * @return returns an array of 0 positions if the rendered output is written
- * to a file.
- */
- @Deprecated
- String[] convertDirectory(Iterable directoryWalker, OptionsBuilder options);
-
- /**
- * Convert all files from a collection.
- * @deprecated Use {@link #convertFiles(Collection, Options)} instead.
- *
- * @param files to be converted.
- * @param options a Map of options to control processing (default: {}).
- * @return returns an array of 0 positions if the rendered output is written
- * to a file.
- */
- @Deprecated
- String[] convertFiles(Collection files, Map options);
-
/**
* Convert all files from a collection.
*
@@ -384,18 +144,6 @@ void convert(Reader contentReader, Writer rendererWriter,
*/
String[] convertFiles(Collection asciidoctorFiles, Options options);
- /**
- * Convert all files from a collection.
- * @deprecated Use {@link #convertFiles(Collection, Options)} instead.
- *
- * @param files to be converted.
- * @param options a Map of options to control processing (default: {}).
- * @return returns an array of 0 positions if the rendered output is written
- * to a file.
- */
- @Deprecated
- String[] convertFiles(Collection files, OptionsBuilder options);
-
/**
* Loads the given Ruby gem(s) by name.
*
@@ -410,40 +158,6 @@ void convert(Reader contentReader, Writer rendererWriter,
*/
void requireLibraries(Collection requiredLibraries);
- /**
- * Reads only header parameters instead of all document.
- *
- * @deprecated Use {@link #loadFile(File, Map)} instead.
- *
- * @param file to read the attributes.
- * @return header.
- */
- @Deprecated
- DocumentHeader readDocumentHeader(File file);
-
- /**
- * Reads only header parameters instead of all document.
- *
- * @deprecated Use {@link #load(String, Map)} instead.
- *
- * @param content where converted content is written. Writer is flushed, but not
- * closed.
- * @return header.
- */
- @Deprecated
- DocumentHeader readDocumentHeader(String content);
-
- /**
- * Reads only header parameters instead of all document.
- *
- * @deprecated Use {@link #loadFile(File, Map)} instead.
- *
- * @param contentReader where asciidoc content is read.
- * @return header.
- */
- @Deprecated
- DocumentHeader readDocumentHeader(Reader contentReader);
-
/**
* Creates an extension registry ready to be used for registering Java extensions.
*
@@ -550,17 +264,6 @@ public static Asciidoctor create() {
}
}
- /**
- * Loads AsciiDoc content and returns the Document object.
- * @deprecated Use {@link #load(String, Options)} instead.
- *
- * @param content to be parsed.
- * @param options a Map of options to control processing (default: {}).
- * @return Document of given content.
- */
- @Deprecated
- Document load(String content, Map options);
-
/**
* Loads AsciiDoc content and returns the Document object.
*
@@ -569,17 +272,6 @@ public static Asciidoctor create() {
* @return Document of given content.
*/
Document load(String content, Options options);
-
- /**
- * Loads AsciiDoc content from file and returns the Document object.
- * @deprecated Use {@link #loadFile(File, Options)} instead.
- *
- * @param file to be parsed.
- * @param options a Map of options to control processing (default: {}).
- * @return Document of given content.
- */
- @Deprecated
- Document loadFile(File file, Map options);
/**
* Loads AsciiDoc content from file and returns the Document object.
diff --git a/asciidoctorj-api/src/main/java/org/asciidoctor/Attributes.java b/asciidoctorj-api/src/main/java/org/asciidoctor/Attributes.java
index f0424e4a9..125a28473 100644
--- a/asciidoctorj-api/src/main/java/org/asciidoctor/Attributes.java
+++ b/asciidoctorj-api/src/main/java/org/asciidoctor/Attributes.java
@@ -61,7 +61,7 @@ public class Attributes {
public static final String HIDE_URI_SCHEME = "hide-uri-scheme";
public static final String COMPAT_MODE = "compat-mode";
- private Map attributes = new LinkedHashMap<>();
+ private final Map attributes = new LinkedHashMap<>();
Attributes() {
}
diff --git a/asciidoctorj-api/src/main/java/org/asciidoctor/Options.java b/asciidoctorj-api/src/main/java/org/asciidoctor/Options.java
index 5797a7f15..70e045cc9 100644
--- a/asciidoctorj-api/src/main/java/org/asciidoctor/Options.java
+++ b/asciidoctorj-api/src/main/java/org/asciidoctor/Options.java
@@ -33,7 +33,7 @@ public class Options {
public static final String PARSE = "parse";
public static final String PARSE_HEADER_ONLY = "parse_header_only";
- private Map options = new HashMap<>();
+ private final Map options = new HashMap<>();
Options() {
}
diff --git a/asciidoctorj-api/src/main/java/org/asciidoctor/ast/DocumentHeader.java b/asciidoctorj-api/src/main/java/org/asciidoctor/ast/DocumentHeader.java
deleted file mode 100644
index 0538111c8..000000000
--- a/asciidoctorj-api/src/main/java/org/asciidoctor/ast/DocumentHeader.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.asciidoctor.ast;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Document header information holder.
- *
- */
-@Deprecated
-public interface DocumentHeader {
-
- /**
- * @deprecated Use {@link Document#getAuthors()} instead.
- */
- @Deprecated
- List getAuthors();
-
- /**
- * @deprecated Use {@link Document#getStructuredDoctitle()} instead.
- */
- @Deprecated
- Title getDocumentTitle();
-
- /**
- * @deprecated Use {@link Document#getDoctitle()} instead.
- */
- @Deprecated
- String getPageTitle();
-
- /**
- * @deprecated Use {@link Document#getAuthors()} instead.
- */
- @Deprecated
- Author getAuthor();
-
- /**
- * @deprecated Use {@link Document#getRevisionInfo()} instead.
- */
- @Deprecated
- RevisionInfo getRevisionInfo();
-
- /**
- * @deprecated Use {@link Document#getAttributes()} instead.
- */
- @Deprecated
- Map getAttributes();
-}
diff --git a/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/ast/impl/DocumentHeaderImpl.java b/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/ast/impl/DocumentHeaderImpl.java
deleted file mode 100644
index 2934058aa..000000000
--- a/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/ast/impl/DocumentHeaderImpl.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.asciidoctor.jruby.ast.impl;
-
-import org.asciidoctor.ast.Author;
-import org.asciidoctor.ast.DocumentHeader;
-import org.asciidoctor.ast.RevisionInfo;
-import org.asciidoctor.ast.Title;
-import org.asciidoctor.jruby.internal.CaseInsensitiveMap;
-
-import java.util.List;
-import java.util.Map;
-
-public class DocumentHeaderImpl implements DocumentHeader {
-
- private Title documentTitle;
- private String pageTitle;
- private List authors;
- private RevisionInfo revisionInfo;
-
- private Map attributes;
-
- private DocumentHeaderImpl() {
- super();
- }
-
- public List getAuthors() {
- return this.authors;
- }
-
- public Title getDocumentTitle() {
- return documentTitle;
- }
-
- public String getPageTitle() {
- return pageTitle;
- }
-
- public Author getAuthor() {
- return authors == null || authors.size() == 0 ? null : authors.get(0);
- }
-
- public RevisionInfo getRevisionInfo() {
- return revisionInfo;
- }
-
- public Map getAttributes() {
- return attributes;
- }
-
- public static DocumentHeaderImpl createDocumentHeader(Title documentTitle, String pageTitle,
- List authors, Map attributes) {
-
- DocumentHeaderImpl documentHeader = new DocumentHeaderImpl();
-
- documentHeader.documentTitle = documentTitle;
- documentHeader.pageTitle = pageTitle;
- documentHeader.attributes = new CaseInsensitiveMap<>(attributes);
- documentHeader.authors = authors;
- documentHeader.revisionInfo = getRevisionInfo(attributes);
-
- return documentHeader;
- }
-
- private static RevisionInfo getRevisionInfo(Map attributes) {
- return RevisionInfoImpl.getInstance(attributes);
- }
-
-}
diff --git a/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/internal/JRubyAsciidoctor.java b/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/internal/JRubyAsciidoctor.java
index d3a384b2a..d672c1e62 100644
--- a/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/internal/JRubyAsciidoctor.java
+++ b/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/internal/JRubyAsciidoctor.java
@@ -2,15 +2,12 @@
import org.asciidoctor.Attributes;
import org.asciidoctor.Options;
-import org.asciidoctor.OptionsBuilder;
import org.asciidoctor.ast.Document;
-import org.asciidoctor.ast.DocumentHeader;
import org.asciidoctor.converter.JavaConverterRegistry;
import org.asciidoctor.extension.ExtensionGroup;
import org.asciidoctor.extension.JavaExtensionRegistry;
import org.asciidoctor.extension.RubyExtensionRegistry;
import org.asciidoctor.jruby.AsciidoctorJRuby;
-import org.asciidoctor.jruby.ast.impl.DocumentHeaderImpl;
import org.asciidoctor.jruby.ast.impl.NodeConverter;
import org.asciidoctor.jruby.converter.internal.ConverterRegistryExecutor;
import org.asciidoctor.jruby.extension.internal.ExtensionRegistryExecutor;
@@ -161,50 +158,7 @@ public Ruby getRubyRuntime() {
return rubyRuntime;
}
- private DocumentHeader toDocumentHeader(Document document) {
-
- Document documentImpl = (Document) NodeConverter.createASTNode(document);
-
- return DocumentHeaderImpl.createDocumentHeader(
- documentImpl.getStructuredDoctitle(),
- documentImpl.getDoctitle(),
- documentImpl.getAuthors(),
- document.getAttributes());
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public DocumentHeader readDocumentHeader(File file) {
-
- RubyHash rubyHash = getParseHeaderOnlyOption();
-
- Document document = (Document) NodeConverter.createASTNode(getAsciidoctorModule().callMethod("load_file", rubyRuntime.newString(file.getAbsolutePath()), rubyHash));
-
- return toDocumentHeader(document);
- }
-
- @Override
- public DocumentHeader readDocumentHeader(String content) {
-
- RubyHash rubyHash = getParseHeaderOnlyOption();
-
- Document document = (Document) NodeConverter.createASTNode(getAsciidoctorModule().callMethod("load", rubyRuntime.newString(content), rubyHash));
- return toDocumentHeader(document);
- }
-
- @Override
- public DocumentHeader readDocumentHeader(Reader contentReader) {
- String content = IOUtils.readFull(contentReader);
- return this.readDocumentHeader(content);
- }
-
- private RubyHash getParseHeaderOnlyOption() {
- Map options = new HashMap<>();
- options.put("parse_header_only", true);
- return RubyHashUtil.convertMapToRubyHashWithSymbols(rubyRuntime, options);
- }
-
- private List convertAllFiles(Map options, final Iterable asciidoctorFiles) {
+ private List convertAllFiles(Options options, final Iterable asciidoctorFiles) {
List asciidoctorContent = new ArrayList<>();
for (File asciidoctorFile : asciidoctorFiles) {
String renderedFile = convertFile(asciidoctorFile, options);
@@ -272,11 +226,6 @@ private RubyModule getAsciidoctorModule() {
return rubyRuntime.getModule("Asciidoctor");
}
- @Override
- public String convert(String content, Map options) {
- return convert(content, options, String.class);
- }
-
public T convert(String content, Map options, Class expectedResult) {
this.rubyGemsPreloader.preloadRequiredLibraries(options);
@@ -330,39 +279,14 @@ public T convert(String content, Options options, Class expectedResult) {
return convert(content, options.map(), expectedResult);
}
- @Override
- public String convert(String content, OptionsBuilder options) {
- return convert(content, options, String.class);
- }
-
- @Override
- public T convert(String content, OptionsBuilder options, Class expectedResult) {
- return convert(content, options.build(), expectedResult);
- }
-
- @Override
- public void convert(Reader contentReader, Writer rendererWriter, Map options) throws IOException {
- String content = IOUtils.readFull(contentReader);
- String renderedContent = convert(content, options);
- IOUtils.writeFull(rendererWriter, renderedContent);
- }
-
@Override
public void convert(Reader contentReader, Writer rendererWriter, Options options) throws IOException {
- this.convert(contentReader, rendererWriter, options.map());
- }
-
- @Override
- public void convert(Reader contentReader, Writer rendererWriter, OptionsBuilder options) throws IOException {
- this.convert(contentReader, rendererWriter, options.build());
- }
-
- @Override
- public String convertFile(File file, Map options) {
- return convertFile(file, options, String.class);
+ final String content = IOUtils.readFull(contentReader);
+ final String renderedContent = convert(content, options);
+ IOUtils.writeFull(rendererWriter, renderedContent);
}
- @Override
+ // @Override
public T convertFile(File file, Map options, Class expectedResult) {
this.rubyGemsPreloader.preloadRequiredLibraries(options);
@@ -419,53 +343,16 @@ public T convertFile(File file, Options options, Class expectedResult) {
return convertFile(file, options.map(), expectedResult);
}
- @Override
- public String convertFile(File file, OptionsBuilder options) {
- return convertFile(file, options.build(), String.class);
- }
-
- @Override
- public T convertFile(File file, OptionsBuilder options, Class expectedResult) {
- return convertFile(file, options.build(), expectedResult);
- }
-
- @Override
- public String[] convertDirectory(Iterable directoryWalker, Map options) {
- List asciidoctorContent = convertAllFiles(options, directoryWalker);
- return asciidoctorContent.toArray(new String[0]);
- }
-
@Override
public String[] convertDirectory(Iterable directoryWalker, Options options) {
- return convertDirectory(directoryWalker, options.map());
- }
-
- @Override
- public String[] convertDirectory(Iterable directoryWalker, OptionsBuilder options) {
- return convertDirectory(directoryWalker, options.build());
- }
-
- @Override
- public String[] convertFiles(Collection files, Map options) {
- List asciidoctorContent = convertAllFiles(options, files);
+ List asciidoctorContent = convertAllFiles(options, directoryWalker);
return asciidoctorContent.toArray(new String[0]);
}
@Override
public String[] convertFiles(Collection asciidoctorFiles, Options options) {
- return convertFiles(asciidoctorFiles, options.map());
- }
-
- @Override
- public String[] convertFiles(Collection files, OptionsBuilder options) {
- return convertFiles(files, options.build());
- }
-
- @Override
- public Document load(String content, Map options) {
- RubyHash rubyHash = RubyHashUtil.convertMapToRubyHashWithSymbols(rubyRuntime, options);
- return (Document) NodeConverter.createASTNode(getAsciidoctorModule().callMethod("load",
- rubyRuntime.newString(content), rubyHash));
+ List asciidoctorContent = convertAllFiles(options, asciidoctorFiles);
+ return asciidoctorContent.toArray(new String[0]);
}
@Override
@@ -475,18 +362,9 @@ public Document load(String content, Options options) {
Optional.ofNullable(content).map(rubyRuntime::newString).orElse(null), rubyHash));
}
- @Override
- public Document loadFile(File file, Map options) {
- RubyHash rubyHash = RubyHashUtil.convertMapToRubyHashWithSymbols(rubyRuntime, options);
-
- return (Document) NodeConverter.createASTNode(getAsciidoctorModule().callMethod("load_file",
- rubyRuntime.newString(file.getAbsolutePath()), rubyHash));
- }
-
@Override
public Document loadFile(File file, Options options) {
RubyHash rubyHash = RubyHashUtil.convertMapToRubyHashWithSymbols(rubyRuntime, options.map());
-
return (Document) NodeConverter.createASTNode(getAsciidoctorModule().callMethod("load_file",
rubyRuntime.newString(file.getAbsolutePath()), rubyHash));
}
diff --git a/asciidoctorj-core/src/test/groovy/org/asciidoctor/WhenADocumentContainsNumberedSections.groovy b/asciidoctorj-core/src/test/groovy/org/asciidoctor/WhenADocumentContainsNumberedSections.groovy
index 93ac9d681..6a8c80d07 100644
--- a/asciidoctorj-core/src/test/groovy/org/asciidoctor/WhenADocumentContainsNumberedSections.groovy
+++ b/asciidoctorj-core/src/test/groovy/org/asciidoctor/WhenADocumentContainsNumberedSections.groovy
@@ -1,8 +1,11 @@
package org.asciidoctor
+
import org.asciidoctor.ast.Section
import spock.lang.Specification
+import static org.asciidoctor.util.OptionsTestHelper.emptyOptions
+
class WhenADocumentContainsNumberedSections extends Specification {
private Asciidoctor asciidoctor = Asciidoctor.Factory.create()
@@ -18,7 +21,7 @@ class WhenADocumentContainsNumberedSections extends Specification {
'''.stripIndent()
when:
- def document = asciidoctor.load source, [:]
+ def document = asciidoctor.load(source, emptyOptions())
then:
final appendix = (Section) document.blocks[0]
@@ -36,7 +39,7 @@ class WhenADocumentContainsNumberedSections extends Specification {
'''.stripIndent()
when:
- def document = asciidoctor.load source, [:]
+ def document = asciidoctor.load(source, emptyOptions())
then:
final section = (Section) document.blocks[0]
@@ -58,7 +61,7 @@ class WhenADocumentContainsNumberedSections extends Specification {
'''.stripIndent()
when:
- def document = asciidoctor.load source, [:]
+ def document = asciidoctor.load(source, emptyOptions())
then:
final part = (Section) document.blocks[0]
diff --git a/asciidoctorj-core/src/test/groovy/org/asciidoctor/WhenSubstitutionsAreUsed.groovy b/asciidoctorj-core/src/test/groovy/org/asciidoctor/WhenSubstitutionsAreUsed.groovy
index 999c59666..7c0db8f47 100644
--- a/asciidoctorj-core/src/test/groovy/org/asciidoctor/WhenSubstitutionsAreUsed.groovy
+++ b/asciidoctorj-core/src/test/groovy/org/asciidoctor/WhenSubstitutionsAreUsed.groovy
@@ -11,6 +11,7 @@ import static org.asciidoctor.ast.StructuralNode.SUBSTITUTION_ATTRIBUTES
import static org.asciidoctor.ast.StructuralNode.SUBSTITUTION_REPLACEMENTS
import static org.asciidoctor.ast.StructuralNode.SUBSTITUTION_MACROS
import static org.asciidoctor.ast.StructuralNode.SUBSTITUTION_POST_REPLACEMENTS
+import static org.asciidoctor.util.OptionsTestHelper.emptyOptions
class WhenSubstitutionsAreUsed extends Specification {
@@ -33,7 +34,7 @@ System.out.println("Hello World");
'''
when:
- Document doc = asciidoctor.load(document, Map.of())
+ Document doc = asciidoctor.load(document, emptyOptions())
Block paragraph = doc.blocks[0].blocks[0]
Block source = doc.blocks[0].blocks[1]
@@ -58,11 +59,11 @@ Second test paragraph {foo}
when:
asciidoctor.javaExtensionRegistry().treeprocessor(TestTreeprocessor)
- Document doc = asciidoctor.load(document, Map.of())
+ Document doc = asciidoctor.load(document, emptyOptions())
Block firstparagraph = doc.blocks[0].blocks[0]
Block secondparagraph = doc.blocks[0].blocks[1]
- String html = asciidoctor.convert(document, Map.of())
+ String html = asciidoctor.convert(document, emptyOptions())
then:
firstparagraph.substitutions == [SUBSTITUTION_SPECIAL_CHARACTERS, SUBSTITUTION_QUOTES, SUBSTITUTION_ATTRIBUTES, SUBSTITUTION_REPLACEMENTS, SUBSTITUTION_MACROS, SUBSTITUTION_POST_REPLACEMENTS]
@@ -93,11 +94,11 @@ System.out.println("{foo}");
when:
asciidoctor.javaExtensionRegistry().treeprocessor(TestTreeprocessor)
- Document doc = asciidoctor.load(document, Map.of())
+ Document doc = asciidoctor.load(document, emptyOptions())
Block firstparagraph = doc.blocks[0].blocks[0]
Block secondparagraph = doc.blocks[0].blocks[1]
- String html = asciidoctor.convert(document, Options.builder())
+ String html = asciidoctor.convert(document, emptyOptions())
then:
firstparagraph.substitutions == [SUBSTITUTION_SPECIAL_CHARACTERS, SUBSTITUTION_QUOTES, SUBSTITUTION_ATTRIBUTES, SUBSTITUTION_REPLACEMENTS, SUBSTITUTION_MACROS, SUBSTITUTION_POST_REPLACEMENTS]
@@ -139,10 +140,10 @@ First test paragraph *{foo}
when:
asciidoctor.javaExtensionRegistry().treeprocessor(PrependSubstitutionTestTreeprocessor)
- Document doc = asciidoctor.load(document, Map.of())
+ Document doc = asciidoctor.load(document, emptyOptions())
Block firstparagraph = doc.blocks[0].blocks[0]
- String html = asciidoctor.convert(document, Map.of())
+ String html = asciidoctor.convert(document, emptyOptions())
then:
firstparagraph.substitutions == [SUBSTITUTION_ATTRIBUTES, SUBSTITUTION_SPECIAL_CHARACTERS, SUBSTITUTION_QUOTES, SUBSTITUTION_ATTRIBUTES, SUBSTITUTION_REPLACEMENTS, SUBSTITUTION_MACROS, SUBSTITUTION_POST_REPLACEMENTS]
@@ -177,7 +178,7 @@ First test paragraph *{foo}
when:
asciidoctor.javaExtensionRegistry().treeprocessor(SetSubstitutionTestTreeprocessor)
- Document doc = asciidoctor.load(document, Options.builder().build())
+ Document doc = asciidoctor.load(document, emptyOptions())
Block firstparagraph = doc.blocks[0].blocks[0]
String html = asciidoctor.convert(document, Options.builder().build())
diff --git a/asciidoctorj-core/src/test/groovy/org/asciidoctor/WhenTheSourceShouldBeAccessed.groovy b/asciidoctorj-core/src/test/groovy/org/asciidoctor/WhenTheSourceShouldBeAccessed.groovy
index 94cf07f1a..af3642df7 100644
--- a/asciidoctorj-core/src/test/groovy/org/asciidoctor/WhenTheSourceShouldBeAccessed.groovy
+++ b/asciidoctorj-core/src/test/groovy/org/asciidoctor/WhenTheSourceShouldBeAccessed.groovy
@@ -12,6 +12,8 @@ import org.asciidoctor.extension.Treeprocessor
import org.jsoup.Jsoup
import spock.lang.Specification
+import static org.asciidoctor.util.OptionsTestHelper.emptyOptions
+
/**
* Tests that the unsubstituted text can be retrieved from nodes
*/
@@ -37,7 +39,7 @@ This paragraph should show {foo}
'''
when:
- Document doc = asciidoctor.load(document, Map.of())
+ Document doc = asciidoctor.load(document, emptyOptions())
Block block = doc.blocks[0].blocks[0]
then:
@@ -60,7 +62,7 @@ This paragraph should show {foo}
'''
when:
- Document doc = asciidoctor.load(document, Map.of())
+ Document doc = asciidoctor.load(document, emptyOptions())
List list = doc.blocks[0].blocks[0]
ListItem listItem = list.items[0]
@@ -90,7 +92,7 @@ That::
'''
when:
- Document doc = asciidoctor.load(document, Map.of())
+ Document doc = asciidoctor.load(document, emptyOptions())
DescriptionList list = doc.blocks[0].blocks[0]
DescriptionListEntry listItem = list.items[0]
@@ -117,7 +119,7 @@ and should continue here'''
'''
when:
- Document doc = asciidoctor.load(document, Map.of())
+ Document doc = asciidoctor.load(document, emptyOptions())
Table table = doc.blocks[0].blocks[0]
Cell cell = table.body[0].cells[0]
diff --git a/asciidoctorj-core/src/test/groovy/org/asciidoctor/extension/WhenAJavaExtensionIsRegisteredWithAnnotations.groovy b/asciidoctorj-core/src/test/groovy/org/asciidoctor/extension/WhenAJavaExtensionIsRegisteredWithAnnotations.groovy
index 45445b323..474bd0ed2 100644
--- a/asciidoctorj-core/src/test/groovy/org/asciidoctor/extension/WhenAJavaExtensionIsRegisteredWithAnnotations.groovy
+++ b/asciidoctorj-core/src/test/groovy/org/asciidoctor/extension/WhenAJavaExtensionIsRegisteredWithAnnotations.groovy
@@ -2,6 +2,7 @@ package org.asciidoctor.extension
import org.asciidoctor.Asciidoctor
import org.asciidoctor.Options
+import org.asciidoctor.OptionsBuilder
import org.asciidoctor.SafeMode
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
@@ -86,7 +87,7 @@ And even more infos on manpage:git[7].
def "a docinfoprocessor should be configurable via the Location annotation"() {
when:
asciidoctor.javaExtensionRegistry().docinfoProcessor(AnnotatedDocinfoProcessor)
- String result = asciidoctor.convert(DOCUMENT, Options.builder().standalone(true).safe(SafeMode.SERVER))
+ String result = asciidoctor.convert(DOCUMENT, options())
then:
Document doc = Jsoup.parse(result, UTF8)
@@ -97,7 +98,7 @@ And even more infos on manpage:git[7].
def "a docinfoprocessor instance should be configurable via the Location annotation"() {
when:
asciidoctor.javaExtensionRegistry().docinfoProcessor(new AnnotatedDocinfoProcessor())
- String result = asciidoctor.convert(DOCUMENT, Options.builder().standalone(true).safe(SafeMode.SERVER).build())
+ String result = asciidoctor.convert(DOCUMENT, options())
then:
Document doc = Jsoup.parse(result, UTF8)
@@ -109,7 +110,7 @@ And even more infos on manpage:git[7].
def "a docinfoprocessor instance can override the annotation from footer to header"() {
when:
asciidoctor.javaExtensionRegistry().docinfoProcessor(new AnnotatedDocinfoProcessor(LocationType.HEADER))
- String result = asciidoctor.convert(DOCUMENT, Options.builder().standalone(true).safe(SafeMode.SERVER).build())
+ String result = asciidoctor.convert(DOCUMENT, options())
then:
Document doc = Jsoup.parse(result, UTF8)
@@ -119,7 +120,7 @@ And even more infos on manpage:git[7].
def "a docinfoprocessor instance can override the annotation from footer to footer"() {
when:
asciidoctor.javaExtensionRegistry().docinfoProcessor(new AnnotatedDocinfoProcessor(LocationType.FOOTER))
- String result = asciidoctor.convert(DOCUMENT, Options.builder().standalone(true).safe(SafeMode.SERVER).build())
+ String result = asciidoctor.convert(DOCUMENT, options())
then:
Document doc = Jsoup.parse(result, UTF8)
@@ -131,7 +132,7 @@ And even more infos on manpage:git[7].
when:
asciidoctor.javaExtensionRegistry().blockMacro(AnnotatedBlockMacroProcessor)
- String result = asciidoctor.convert(BLOCK_MACRO_DOCUMENT, Options.builder().standalone(false).build())
+ String result = asciidoctor.convert(BLOCK_MACRO_DOCUMENT, disableStandaloneOption())
then:
result.contains(AnnotatedBlockMacroProcessor.RESULT)
@@ -143,7 +144,7 @@ And even more infos on manpage:git[7].
when:
asciidoctor.javaExtensionRegistry().block(AnnotatedBlockProcessor)
- String result = asciidoctor.convert(BLOCK_DOCUMENT, Options.builder().standalone(false).build())
+ String result = asciidoctor.convert(BLOCK_DOCUMENT, disableStandaloneOption())
then:
result.contains(DO_NOT_TOUCH_THIS)
@@ -157,7 +158,7 @@ And even more infos on manpage:git[7].
when:
asciidoctor.javaExtensionRegistry().block(new AnnotatedBlockProcessor('dummy', 'yell2'))
- String result = asciidoctor.convert(BLOCK_DOCUMENT_2, Options.builder().standalone(false).build())
+ String result = asciidoctor.convert(BLOCK_DOCUMENT_2, disableStandaloneOption())
then:
result.contains(DO_NOT_TOUCH_THIS)
@@ -168,7 +169,7 @@ And even more infos on manpage:git[7].
def "when registering an InlineMacroProcessor class with long format it should be configurable via annotations"() {
when:
asciidoctor.javaExtensionRegistry().inlineMacro(AnnotatedLongInlineMacroProcessor)
- String result = asciidoctor.convert(INLINE_MACRO_DOCUMENT, Options.builder().standalone(false).build())
+ String result = asciidoctor.convert(INLINE_MACRO_DOCUMENT, disableStandaloneOption())
then:
Document doc = Jsoup.parse(result, UTF8)
@@ -179,7 +180,7 @@ And even more infos on manpage:git[7].
def "when registering an InlineMacroProcessor class with regexp it should be configurable via annotations"() {
when:
asciidoctor.javaExtensionRegistry().inlineMacro(AnnotatedRegexpInlineMacroProcessor)
- String result = asciidoctor.convert(INLINE_MACRO_REGEXP_DOCUMENT, Options.builder().standalone(false).build())
+ String result = asciidoctor.convert(INLINE_MACRO_REGEXP_DOCUMENT, disableStandaloneOption())
then:
Document doc = Jsoup.parse(result, UTF8)
@@ -187,4 +188,15 @@ And even more infos on manpage:git[7].
link.attr(HREF) == 'git.html'
}
+ private OptionsBuilder standaloneBuilder(boolean enable) {
+ Options.builder().standalone(enable)
+ }
+
+ private Options disableStandaloneOption() {
+ standaloneBuilder(false).build()
+ }
+
+ private Options options() {
+ standaloneBuilder(true).safe(SafeMode.SERVER).build()
+ }
}
diff --git a/asciidoctorj-core/src/test/groovy/org/asciidoctor/extension/WhenAPreprocessorIsRegistered.groovy b/asciidoctorj-core/src/test/groovy/org/asciidoctor/extension/WhenAPreprocessorIsRegistered.groovy
index c816048c0..f97d72d82 100644
--- a/asciidoctorj-core/src/test/groovy/org/asciidoctor/extension/WhenAPreprocessorIsRegistered.groovy
+++ b/asciidoctorj-core/src/test/groovy/org/asciidoctor/extension/WhenAPreprocessorIsRegistered.groovy
@@ -1,12 +1,13 @@
package org.asciidoctor.extension
import org.asciidoctor.Asciidoctor
-import org.asciidoctor.Options
import org.asciidoctor.ast.Document
import spock.lang.Specification
import java.util.concurrent.atomic.AtomicBoolean
+import static org.asciidoctor.util.OptionsTestHelper.emptyOptions
+
class WhenAPreprocessorIsRegistered extends Specification {
private Asciidoctor asciidoctor = Asciidoctor.Factory.create()
@@ -46,7 +47,7 @@ $secondLine"""
})
when:
- asciidoctor.convert(document, Map.of())
+ asciidoctor.convert(document, emptyOptions())
then:
preprocessorCalled.get()
@@ -79,7 +80,7 @@ $secondLine"""
})
when:
- asciidoctor.convert(document, Map.of())
+ asciidoctor.convert(document, emptyOptions())
then:
preprocessorCalled.get()
@@ -103,7 +104,7 @@ $secondLine"""
})
when:
- asciidoctor.convert(document, Options.builder())
+ asciidoctor.convert(document, emptyOptions())
then:
preprocessorCalled.get()
@@ -134,7 +135,7 @@ $secondLine"""
})
when:
- asciidoctor.convert(document, Options.builder())
+ asciidoctor.convert(document, emptyOptions())
then:
preprocessorCalled.get()
@@ -168,7 +169,7 @@ $secondLine"""
})
when:
- asciidoctor.convert(document, Map.of())
+ asciidoctor.convert(document, emptyOptions())
then:
preprocessorCalled.get()
diff --git a/asciidoctorj-core/src/test/groovy/org/asciidoctor/extension/WhenATreeProcessorWorksOnTables.groovy b/asciidoctorj-core/src/test/groovy/org/asciidoctor/extension/WhenATreeProcessorWorksOnTables.groovy
index 8123584c6..442f8f1f1 100644
--- a/asciidoctorj-core/src/test/groovy/org/asciidoctor/extension/WhenATreeProcessorWorksOnTables.groovy
+++ b/asciidoctorj-core/src/test/groovy/org/asciidoctor/extension/WhenATreeProcessorWorksOnTables.groovy
@@ -67,7 +67,7 @@ class WhenATreeProcessorWorksOnTables extends Specification {
| World | Hello
|===
-''', Options.builder().standalone(false))
+''', Options.builder().standalone(false).build())
def htmlDocument = Jsoup.parse(content)
diff --git a/asciidoctorj-core/src/test/groovy/org/asciidoctor/extension/WhenAstIsIterated.groovy b/asciidoctorj-core/src/test/groovy/org/asciidoctor/extension/WhenAstIsIterated.groovy
index 95a7314a8..b2d21daaa 100644
--- a/asciidoctorj-core/src/test/groovy/org/asciidoctor/extension/WhenAstIsIterated.groovy
+++ b/asciidoctorj-core/src/test/groovy/org/asciidoctor/extension/WhenAstIsIterated.groovy
@@ -1,10 +1,12 @@
package org.asciidoctor.extension
import org.asciidoctor.Asciidoctor
-import org.asciidoctor.ast.StructuralNode
import org.asciidoctor.ast.Document
+import org.asciidoctor.ast.StructuralNode
import spock.lang.Specification
+import static org.asciidoctor.util.OptionsTestHelper.emptyOptions
+
class WhenAstIsIterated extends Specification {
Asciidoctor asciidoctor = Asciidoctor.Factory.create()
@@ -30,7 +32,7 @@ A list with items
def "getDocument should always return the same instance"() {
when:
- Document document = asciidoctor.load(DOCUMENT, [:])
+ Document document = asciidoctor.load(DOCUMENT, emptyOptions())
List allBlocks = document.findBy([:])
then:
@@ -40,7 +42,7 @@ A list with items
def "getParent should always return the same instance"() {
when:
- Document document = asciidoctor.load(DOCUMENT, [:])
+ Document document = asciidoctor.load(DOCUMENT, emptyOptions())
def allBlocks = document.findBy([:])
then: 'Every block of the document should return the same node as the parent from getParent()'
diff --git a/asciidoctorj-core/src/test/groovy/org/asciidoctor/jruby/internal/RubyAttributesMapDecoratorSpecification.groovy b/asciidoctorj-core/src/test/groovy/org/asciidoctor/jruby/internal/RubyAttributesMapDecoratorSpecification.groovy
index 6497ba7d9..2c14a31c0 100644
--- a/asciidoctorj-core/src/test/groovy/org/asciidoctor/jruby/internal/RubyAttributesMapDecoratorSpecification.groovy
+++ b/asciidoctorj-core/src/test/groovy/org/asciidoctor/jruby/internal/RubyAttributesMapDecoratorSpecification.groovy
@@ -5,6 +5,8 @@ import org.asciidoctor.ast.Block
import org.asciidoctor.ast.Document
import spock.lang.Specification
+import static org.asciidoctor.util.OptionsTestHelper.emptyOptions
+
class RubyAttributesMapDecoratorSpecification extends Specification {
public static final String ATTR_ONE = '1'
@@ -25,7 +27,7 @@ Lorem ipsum dolor
def "should consistently show positional attributes as string keys"() {
when:
- Document document = asciidoctor.load(documentWithPositionalAttribute, new HashMap())
+ Document document = asciidoctor.load(documentWithPositionalAttribute, emptyOptions())
Block block = (Block) document.getBlocks().get(0)
Map attributes = block.getAttributes()
@@ -42,7 +44,7 @@ Lorem ipsum dolor
def "should remove positional attributes by string keys"() {
given: 'a block with a positional attribute'
- Document document = asciidoctor.load(documentWithPositionalAttribute, new HashMap())
+ Document document = asciidoctor.load(documentWithPositionalAttribute, emptyOptions())
Block block = (Block) document.getBlocks().get(0)
@@ -63,14 +65,14 @@ Lorem ipsum dolor
def "should return previous value on put"() {
given: 'a block with a positional attribute'
- Document document = asciidoctor.load(documentWithPositionalAttribute, new HashMap())
+ Document document = asciidoctor.load(documentWithPositionalAttribute, emptyOptions())
Block block = (Block) document.getBlocks().get(0)
when: 'I put another value for the positional attribute 1'
def attributes = block.getAttributes()
def newValue = 42
- def previousValue = attributes.put(ATTR_ONE, newValue)
+ String previousValue = attributes.put(ATTR_ONE, newValue)
then: 'put returned the previous value'
previousValue.startsWith(blockStyle)
diff --git a/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAnAsciidoctorClassIsInstantiated.java b/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAnAsciidoctorClassIsInstantiated.java
index 1451dd4ef..679661440 100644
--- a/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAnAsciidoctorClassIsInstantiated.java
+++ b/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAnAsciidoctorClassIsInstantiated.java
@@ -21,8 +21,11 @@
import java.nio.file.Path;
import java.text.Format;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.List;
+import static org.asciidoctor.util.OptionsTestHelper.emptyOptions;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.Matchers.isEmptyString;
@@ -49,16 +52,14 @@ public class WhenAnAsciidoctorClassIsInstantiated {
@Test
public void should_accept_empty_string_as_empty_content_when_output_is_String() {
- Options basicOptions = Options.builder().build();
- String result = asciidoctor.convert("", basicOptions);
+ String result = asciidoctor.convert("", emptyOptions());
assertThat(result, isEmptyString());
}
@Test
public void should_accept_null_string_as_empty_content_when_output_is_String() {
- Options basicOptions = Options.builder().build();
- String result = asciidoctor.convert(null, basicOptions);
+ String result = asciidoctor.convert(null, emptyOptions());
assertThat(result, isEmptyString());
}
@@ -78,10 +79,9 @@ public void should_accept_null_string_as_empty_content_when_output_is_File() {
@Test
public void should_fail_when_reader_is_null() {
- Options basicOptions = Options.builder().build();
StringWriter writer = new StringWriter();
- Throwable throwable = Assertions.catchThrowable(() -> asciidoctor.convert(null, writer, basicOptions));
+ Throwable throwable = Assertions.catchThrowable(() -> asciidoctor.convert(null, writer, emptyOptions()));
Assertions.assertThat(throwable)
.isInstanceOf(NullPointerException.class)
@@ -94,7 +94,7 @@ public void content_should_be_read_from_reader_and_written_to_writer()
FileReader inputAsciidoctorFile = new FileReader(renderSampleDocument);
StringWriter rendererWriter = new StringWriter();
- asciidoctor.convert(inputAsciidoctorFile, rendererWriter, options().build().map());
+ asciidoctor.convert(inputAsciidoctorFile, rendererWriter, emptyOptions());
StringBuffer renderedContent = rendererWriter.getBuffer();
assertRenderedFile(renderedContent.toString());
@@ -127,8 +127,8 @@ public void file_document_should_be_rendered_into_current_directory_using_option
@Test
public void file_document_should_be_rendered_into_current_directory() {
- String renderContent = asciidoctor.convertFile(renderSampleDocument, options()
- .inPlace(true).build().map());
+ Options inPlaceOptions = options().inPlace(true).build();
+ String renderContent = asciidoctor.convertFile(renderSampleDocument, inPlaceOptions);
File expectedFile = new File(renderSampleDocument.getParent(), "rendersample.html");
@@ -191,7 +191,7 @@ public void file_document_should_be_rendered_into_foreign_directory_using_option
public void docbook_document_should_be_rendered_into_current_directory() {
Attributes attributes = Attributes.builder().backend("docbook").build();
- Map options = options().inPlace(true).attributes(attributes).build().map();
+ Options options = options().inPlace(true).attributes(attributes).build();
String renderContent = asciidoctor.convertFile(renderSampleDocument, options);
@@ -245,7 +245,7 @@ public void string_content_with_custom_date_should_be_rendered(
customDate.set(Calendar.DATE, 5);
Attributes attributes = Attributes.builder().localDate(customDate.getTime()).build();
- Map options = options().attributes(attributes).build().map();
+ Options options = options().attributes(attributes).build();
String render_file = asciidoctor.convert(Files.readString(documentWithDate), options);
assertRenderedLocalDateContent(render_file, "2012-12-05.");
@@ -263,7 +263,7 @@ public void string_content_with_custom_time_should_be_rendered(
customTime.set(Calendar.SECOND, 0);
Attributes attributes = Attributes.builder().localTime(customTime.getTime()).build();
- Map options = options().attributes(attributes).build().map();
+ Options options = options().attributes(attributes).build();
String render_file = asciidoctor.convert(Files.readString(documentWithDate), options);
@@ -277,7 +277,7 @@ public void string_content_with_custom_time_should_be_rendered(
public void string_content_document_should_be_rendered_into_default_backend() throws IOException, SAXException,
ParserConfigurationException {
- String render_file = asciidoctor.convert(Files.readString(renderSampleDocument.toPath()), new HashMap<>());
+ String render_file = asciidoctor.convert(Files.readString(renderSampleDocument.toPath()), emptyOptions());
assertRenderedFile(render_file);
}
diff --git a/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAnAsciidoctorJInstanceIsRequired.java b/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAnAsciidoctorJInstanceIsRequired.java
index b5954fd14..a446bc9ce 100644
--- a/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAnAsciidoctorJInstanceIsRequired.java
+++ b/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAnAsciidoctorJInstanceIsRequired.java
@@ -15,7 +15,7 @@ public void shouldUnwrapAsciidoctorInstanceAndRegisterRubyExtension() {
AsciidoctorJRuby asciidoctorj = Asciidoctor.Factory.create().unwrap(AsciidoctorJRuby.class);
asciidoctorj.rubyExtensionRegistry().loadClass(getClass().getResourceAsStream("/ruby-extensions/YellRubyBlock.rb")).block("yell", "YellRubyBlock");
- String html = asciidoctorj.convert(DOC, Options.builder().standalone(false));
+ String html = asciidoctorj.convert(DOC, Options.builder().standalone(false).build());
assertThat(html, containsString("HELLO WORLD"));
}
diff --git a/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAsciiDocIsLoadedToDocument.java b/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAsciiDocIsLoadedToDocument.java
index 560f4255f..62602bf7e 100644
--- a/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAsciiDocIsLoadedToDocument.java
+++ b/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAsciiDocIsLoadedToDocument.java
@@ -16,9 +16,9 @@
import java.util.List;
import java.util.Map;
-import static java.util.Collections.emptyMap;
import static java.util.stream.Collectors.toList;
import static org.asciidoctor.test.AsciidoctorInstance.InstanceScope.PER_METHOD;
+import static org.asciidoctor.util.OptionsTestHelper.emptyOptions;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
@@ -72,12 +72,12 @@ public class WhenAsciiDocIsLoadedToDocument {
@Test
public void should_return_empty_sources_when_document_is_null() {
- assertEmptySources(asciidoctor.load(null, Options.builder().build()));
+ assertEmptySources(asciidoctor.load(null, emptyOptions()));
}
@Test
public void should_return_empty_sources_when_document_is_empty() {
- assertEmptySources(asciidoctor.load(null, Options.builder().build()));
+ assertEmptySources(asciidoctor.load(null, emptyOptions()));
}
private static void assertEmptySources(Document document) {
@@ -89,7 +89,7 @@ private static void assertEmptySources(Document document) {
@Test
public void should_return_section_blocks() {
- Document document = asciidoctor.load(DOCUMENT, new HashMap<>());
+ Document document = asciidoctor.load(DOCUMENT, emptyOptions());
Section section = (Section) document.getBlocks().get(1);
assertThat(section.getIndex(), is(0));
assertThat(section.getSectionName(), either(is("sect1")).or(is("section")));
@@ -98,16 +98,14 @@ public void should_return_section_blocks() {
@Test
public void should_return_blocks_from_a_document() {
-
- Document document = asciidoctor.load(DOCUMENT, new HashMap<>());
+ Document document = asciidoctor.load(DOCUMENT, emptyOptions());
assertThat(document.getDoctitle(), is("Document Title"));
assertThat(document.getBlocks(), hasSize(3));
}
@Test
public void should_return_a_document_object_from_string() {
-
- Document document = asciidoctor.load(DOCUMENT, new HashMap<>());
+ Document document = asciidoctor.load(DOCUMENT, emptyOptions());
assertThat(document.getDoctitle(), is("Document Title"));
}
@@ -127,30 +125,16 @@ public void should_find_all_nodes() {
@Test
public void should_find_elements_from_document() {
+ Document document = asciidoctor.load(DOCUMENT, emptyOptions());
+ List findBy = document.findBy(Map.of("context", ":image"));
- Document document = asciidoctor.load(DOCUMENT, new HashMap<>());
- Map