diff --git a/_documentation/pom.xml b/_documentation/pom.xml index a86d89a3..c70a9d18 100644 --- a/_documentation/pom.xml +++ b/_documentation/pom.xml @@ -43,6 +43,12 @@ ${project.version} provided + + ${project.groupId} + asciidoc-java + ${project.version} + provided + org.apache.maven maven-settings diff --git a/_documentation/src/main/minisite/content/asciidoc-java.adoc b/_documentation/src/main/minisite/content/asciidoc-java.adoc new file mode 100644 index 00000000..c49de311 --- /dev/null +++ b/_documentation/src/main/minisite/content/asciidoc-java.adoc @@ -0,0 +1,33 @@ += Ascii2SVG +:minisite-index: 400 +:minisite-index-title: Asciidoc Java +:minisite-index-icon: font +:minisite-index-description: Asciidoc Java native parser. + +The module `asciidoc-java` implements a light Asciidoc syntax parser in plain Java. +It aims at making it easier and lighter than using JRuby to embed Asciidoc in any Java based (native or not) application. + +Its usage is pretty simple: + +. You get a `Parser` instance to load the model of your document in memory (AST), +. You visit the model as you want (or reusing provided `Visitor`) to render the loaded `Document`. + +TIP: the `Document` instance is thread safe and can safely be reused accross multiple threads. The parser is also thread save but the visitors must be created per rendering instance. + +Here is a basic example: + +[source,java] +---- +final var parser = new Parser(); <1> +final var doc = parser.parse(myDocContent, new Parser.ParserContext(ContextResolver.of(Path.of("asciidoc/content")))); <2> +final var renderer = new SimpleHtmlRenderer(); <3> +renderer.visit(doc); <4> +final var html = renderer.result(); <5> +---- +<.> Create a parser instance, can be a singleton in an application, +<.> Load the document model, can also be a singletong in an application when the conditions depends on attributes, +<.> Create a renderer (here a html renderer, optionally you can pass it attributes using the other constructor), +<.> Visit the document, +<.> Get back the output of the renderer (html output here). + +IMPORTANT: the asciidoc syntax is not 100% implemented yet, if you encounter anything you miss, feel free to open an issue or pull request on our bugtracker. diff --git a/asciidoc-java/pom.xml b/asciidoc-java/pom.xml new file mode 100644 index 00000000..7d6cf1ce --- /dev/null +++ b/asciidoc-java/pom.xml @@ -0,0 +1,57 @@ + + + + 4.0.0 + + io.yupiik.maven + yupiik-tools-maven-plugin-parent + 1.1.9-SNAPSHOT + + + asciidoc-java + Yupiik Tools :: Asciidoc + Simple library to convert an asciidoc content to something else (mainly html). + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 17 + 17 + 17 + + + + org.apache.maven.plugins + maven-javadoc-plugin + + 17 + + + + + diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Admonition.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Admonition.java new file mode 100644 index 00000000..561bf9ad --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Admonition.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +import static io.yupiik.asciidoc.model.Element.ElementType.ADMONITION; + +public record Admonition(Level level, Element content) implements Element { + @Override + public ElementType type() { + return ADMONITION; + } + + public enum Level { + NOTE, + TIP, + IMPORTANT, + CAUTION, + WARNING + } +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Anchor.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Anchor.java new file mode 100644 index 00000000..7d66ab87 --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Anchor.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +import static io.yupiik.asciidoc.model.Element.ElementType.ANCHOR; + +// just a pointer to a section by "id" so rendering must resolve the section +// to use its label as title once all model is resolved if not provided +public record Anchor(String value, String label) implements Element { + @Override + public ElementType type() { + return ANCHOR; + } +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Attribute.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Attribute.java new file mode 100644 index 00000000..85bb5849 --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Attribute.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +import java.util.List; +import java.util.function.Function; + +import static io.yupiik.asciidoc.model.Element.ElementType.ATTRIBUTE; + +public record Attribute(String attribute, Function> evaluator) implements Element { + @Override + public ElementType type() { + return ATTRIBUTE; + } +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Author.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Author.java new file mode 100644 index 00000000..44e4cd6b --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Author.java @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +public record Author(String name, String mail) { +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Body.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Body.java new file mode 100644 index 00000000..6d5d7895 --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Body.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.yupiik.asciidoc.model; + +import java.util.List; + +public record Body(List children) { +} \ No newline at end of file diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Code.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Code.java new file mode 100644 index 00000000..b186fda2 --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Code.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +import java.util.Map; + +public record Code(String value, Map options, boolean inline) implements Element { + @Override + public ElementType type() { + return ElementType.CODE; + } +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/ConditionalBlock.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/ConditionalBlock.java new file mode 100644 index 00000000..7624f6e8 --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/ConditionalBlock.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; + +import static io.yupiik.asciidoc.model.Element.ElementType.CONDITIONAL_BLOCK; + +public record ConditionalBlock(Predicate evaluator, + List children, + Map options) implements Element { + @Override + public ElementType type() { + return CONDITIONAL_BLOCK; + } + + @FunctionalInterface + public interface Context { + String attribute(String key); + } + + public record Ifdef(String attribute) implements Predicate { + @Override + public boolean test(final Context context) { + return context.attribute(attribute) != null; + } + } + + public record Ifndef(String attribute) implements Predicate { + @Override + public boolean test(final Context context) { + return context.attribute(attribute) == null; + } + } + + public record Ifeval(String todo) implements Predicate { + @Override + public boolean test(final Context context) { + return context.attribute(todo) == null; + } + } +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/DescriptionList.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/DescriptionList.java new file mode 100644 index 00000000..0ceb1b8c --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/DescriptionList.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +import java.util.Map; + +import static io.yupiik.asciidoc.model.Element.ElementType.DESCRIPTION_LIST; + +public record DescriptionList(Map children) implements Element { + @Override + public ElementType type() { + return DESCRIPTION_LIST; + } +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Document.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Document.java new file mode 100644 index 00000000..3378ef85 --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Document.java @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +public record Document(Header header, Body body) { +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Element.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Element.java new file mode 100644 index 00000000..66bac94e --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Element.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +public sealed interface Element permits + Code, DescriptionList, LineBreak, Link, Macro, OrderedList, + Paragraph, Section, Text, UnOrderedList, Admonition, Anchor, + Table, Quote, OpenBlock, PassthroughBlock, ConditionalBlock, + Attribute { + ElementType type(); + + /** + * Important: the order of this enum is not guaranteed today so ensure to use {@code ordinal()} in the cases + * you know working (it is stable per JVM instance). + */ + enum ElementType { + // PREAMBLE, // not really supported/needed, if needed it can be detected by checking the paragraphs after first title and before next subtitle + // EXAMPLE, // not really supported/needed, this is just a custom role + // VERSE, // not really supported/needed, this is just a custom role + ATTRIBUTE, + PARAGRAPH, + SECTION, + LINE_BREAK, + CODE, // including source blocks + UNORDERED_LIST, + ORDERED_LIST, + DESCRIPTION_LIST, + LINK, + TEXT, + MACRO, // icon, image, audio, video, kbd, btn, menu, doublefootnote, footnote, stem, xref, pass + ADMONITION, + ANCHOR, + TABLE, + OPEN_BLOCK, + QUOTE, // TODO: we only support the markdown style quotes + PASS_BLOCK, + CONDITIONAL_BLOCK + } +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Header.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Header.java new file mode 100644 index 00000000..a2525034 --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Header.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +import java.util.Map; + +public record Header(String title, + Author author, + Revision revision, + Map attributes) { +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/LineBreak.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/LineBreak.java new file mode 100644 index 00000000..ab77c365 --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/LineBreak.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +public record LineBreak() implements Element { + @Override + public ElementType type() { + return ElementType.LINE_BREAK; + } +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Link.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Link.java new file mode 100644 index 00000000..c2af1e4c --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Link.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +import java.util.Map; + +public record Link(String url, String label, Map options) implements Element { + @Override + public ElementType type() { + return ElementType.LINK; + } +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Macro.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Macro.java new file mode 100644 index 00000000..bf40ac84 --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Macro.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +import java.util.Map; + +import static io.yupiik.asciidoc.model.Element.ElementType.MACRO; + +public record Macro(String name /* ex: icon, kbd, image, ... */, String label, Map options, boolean inline) implements Element { + @Override + public ElementType type() { + return MACRO; + } +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/OpenBlock.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/OpenBlock.java new file mode 100644 index 00000000..bf5b6f13 --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/OpenBlock.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +import java.util.List; +import java.util.Map; + +import static io.yupiik.asciidoc.model.Element.ElementType.OPEN_BLOCK; + +public record OpenBlock(List children, Map options) implements Element { + @Override + public ElementType type() { + return OPEN_BLOCK; + } +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/OrderedList.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/OrderedList.java new file mode 100644 index 00000000..eb5ea0f3 --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/OrderedList.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +import java.util.List; +import java.util.Map; + +public record OrderedList(List children, Map options) implements Element { + @Override + public ElementType type() { + return ElementType.ORDERED_LIST; + } +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Paragraph.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Paragraph.java new file mode 100644 index 00000000..e7a29bf7 --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Paragraph.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +import java.util.List; +import java.util.Map; + +import static io.yupiik.asciidoc.model.Element.ElementType.PARAGRAPH; + +public record Paragraph(List children, Map options) implements Element { + @Override + public ElementType type() { + return PARAGRAPH; + } +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/PassthroughBlock.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/PassthroughBlock.java new file mode 100644 index 00000000..df73a781 --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/PassthroughBlock.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +import java.util.Map; + +import static io.yupiik.asciidoc.model.Element.ElementType.PASS_BLOCK; + +public record PassthroughBlock(String text, Map options) implements Element { + @Override + public ElementType type() { + return PASS_BLOCK; + } +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Quote.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Quote.java new file mode 100644 index 00000000..43ddac41 --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Quote.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +import java.util.List; +import java.util.Map; + +import static io.yupiik.asciidoc.model.Element.ElementType.QUOTE; + +public record Quote(List children, Map options) implements Element { + @Override + public ElementType type() { + return QUOTE; + } +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Revision.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Revision.java new file mode 100644 index 00000000..847ccc43 --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Revision.java @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +public record Revision(String number, String date, String revmark) { +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Section.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Section.java new file mode 100644 index 00000000..2d194cb3 --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Section.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +import java.util.List; +import java.util.Map; + +public record Section(int level, Element title, List children, Map options) implements Element { + @Override + public ElementType type() { + return ElementType.SECTION; + } +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Table.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Table.java new file mode 100644 index 00000000..bfc48dc1 --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Table.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +import java.util.List; +import java.util.Map; + +public record Table(List> elements, Map options) implements Element { + @Override + public ElementType type() { + return ElementType.TABLE; + } +} diff --git a/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Text.java b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Text.java new file mode 100644 index 00000000..4804ef1d --- /dev/null +++ b/asciidoc-java/src/main/java/io/yupiik/asciidoc/model/Text.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.yupiik.asciidoc.model; + +import java.util.List; +import java.util.Map; + +import static io.yupiik.asciidoc.model.Element.ElementType.TEXT; + +public record Text(List