> set = new HashSet<>();
+ set.add(new NodeRenderingHandler<>(TypographicSmarts.class, this::render));
+ set.add(new NodeRenderingHandler<>(TypographicQuotes.class, this::render));
+ return set;
+ }
+
+ private void render(TypographicQuotes node, NodeRendererContext context, HtmlWriter html) {
+ if (node.getTypographicOpening() != null && !node.getTypographicOpening().isEmpty()) html.raw(node.getTypographicOpening());
+ context.renderChildren(node);
+ if (node.getTypographicClosing() != null && !node.getTypographicClosing().isEmpty()) html.raw(node.getTypographicClosing());
+ }
+
+ private void render(TypographicSmarts node, NodeRendererContext context, HtmlWriter html) {
+ html.raw(node.getTypographicText());
+ }
+
+ public static class Factory implements NodeRendererFactory {
+ @NotNull
+ @Override
+ public NodeRenderer apply(@NotNull DataHolder options) {
+ return new TypographicNodeRenderer(options);
+ }
+ }
+}
diff --git a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/package-info.java b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/package-info.java
new file mode 100644
index 0000000000..37aa02744d
--- /dev/null
+++ b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/package-info.java
@@ -0,0 +1 @@
+package com.vladsch.flexmark.ext.d2.internal;
diff --git a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/package-info.java b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/package-info.java
new file mode 100644
index 0000000000..4d3df0552b
--- /dev/null
+++ b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/package-info.java
@@ -0,0 +1 @@
+package com.vladsch.flexmark.ext.d2;
diff --git a/flexmark-ext-d2-diagrams/src/main/javadoc/overview.html b/flexmark-ext-d2-diagrams/src/main/javadoc/overview.html
new file mode 100644
index 0000000000..ffa4eeda63
--- /dev/null
+++ b/flexmark-ext-d2-diagrams/src/main/javadoc/overview.html
@@ -0,0 +1,8 @@
+
+
+
+
+
+flexmark-java extension for d2 diagrams
+
+
diff --git a/flexmark-ext-d2-diagrams/src/main/javadoc/overview.md b/flexmark-ext-d2-diagrams/src/main/javadoc/overview.md
new file mode 100644
index 0000000000..28a211ee24
--- /dev/null
+++ b/flexmark-ext-d2-diagrams/src/main/javadoc/overview.md
@@ -0,0 +1 @@
+**flexmark-java extension for d2 diagrams**
diff --git a/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ComboTypographicSpecTest.java b/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ComboTypographicSpecTest.java
new file mode 100644
index 0000000000..650556d05b
--- /dev/null
+++ b/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ComboTypographicSpecTest.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2015-2016 Vladimir Schneider , all rights reserved.
+ *
+ * This code is private property of the copyright holder and cannot be used without
+ * having obtained a license or prior written permission of the of the copyright holder.
+ *
+ * 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 com.vladsch.flexmark.ext.typographic;
+
+import com.vladsch.flexmark.core.test.util.RendererSpecTest;
+import com.vladsch.flexmark.parser.Parser;
+import com.vladsch.flexmark.test.util.spec.ResourceLocation;
+import com.vladsch.flexmark.test.util.spec.SpecExample;
+import com.vladsch.flexmark.util.data.DataHolder;
+import com.vladsch.flexmark.util.data.MutableDataSet;
+import org.jetbrains.annotations.NotNull;
+import org.junit.runners.Parameterized;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ComboTypographicSpecTest extends RendererSpecTest {
+ final private static String SPEC_RESOURCE = "/ext_typographic_ast_spec.md";
+ final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(ComboTypographicSpecTest.class, SPEC_RESOURCE);
+ final private static DataHolder OPTIONS = new MutableDataSet()
+ .set(Parser.EXTENSIONS, Collections.singleton(TypographicExtension.create()))
+ .toImmutable();
+
+ final private static Map optionsMap = new HashMap<>();
+ static {
+ optionsMap.put("no-quotes", new MutableDataSet().set(TypographicExtension.ENABLE_QUOTES, false));
+ optionsMap.put("no-smarts", new MutableDataSet().set(TypographicExtension.ENABLE_SMARTS, false));
+ }
+ public ComboTypographicSpecTest(@NotNull SpecExample example) {
+ super(example, optionsMap, OPTIONS);
+ }
+
+ @Parameterized.Parameters(name = "{0}")
+ public static List data() {
+ return getTestData(RESOURCE_LOCATION);
+ }
+}
diff --git a/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ExtTypographicTestSuite.java b/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ExtTypographicTestSuite.java
new file mode 100644
index 0000000000..950e1f537d
--- /dev/null
+++ b/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ExtTypographicTestSuite.java
@@ -0,0 +1,11 @@
+package com.vladsch.flexmark.ext.d2;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ ComboTypographicSpecTest.class,
+})
+public class ExtD2TestSuite {
+}
diff --git a/flexmark-ext-d2-diagrams/src/test/resources/com.vladsch.flexmark.ext.d2.txt b/flexmark-ext-d2-diagrams/src/test/resources/com.vladsch.flexmark.ext.d2.txt
new file mode 100644
index 0000000000..34dbc4597b
--- /dev/null
+++ b/flexmark-ext-d2-diagrams/src/test/resources/com.vladsch.flexmark.ext.d2.txt
@@ -0,0 +1 @@
+java/
From 2fe128df653fe98246380ebf6147b9aa50cd95ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Biegun?=
<69080338+Anakin100100@users.noreply.github.com>
Date: Thu, 24 Aug 2023 11:58:34 +0000
Subject: [PATCH 2/5] enable test running
---
.vscode/settings.json | 3 +
.../com/vladsch/flexmark/ext/d2/D2Block.java | 13 ++++
.../vladsch/flexmark/ext/d2/D2Extension.java | 3 +-
.../com/vladsch/flexmark/ext/d2/D2Node.java | 59 +++++++++++++++++++
.../com/vladsch/flexmark/ext/d2/D2Value.java | 20 +++++++
.../ext/d2/internal/D2BlockParser.java | 14 ++---
.../ext/d2/internal/D2NodeRenderer.java | 21 +++----
...pographicSpecTest.java => D2SpecTest.java} | 16 ++---
...phicTestSuite.java => ExtD2TestSuite.java} | 2 +-
.../src/test/resources/ext_d2_ast_spec.md | 0
flexmark-java.iml | 1 +
pom.xml | 5 ++
12 files changed, 123 insertions(+), 34 deletions(-)
create mode 100644 .vscode/settings.json
create mode 100644 flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Block.java
create mode 100644 flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Node.java
create mode 100644 flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Value.java
rename flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/{ComboTypographicSpecTest.java => D2SpecTest.java} (70%)
rename flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/{ExtTypographicTestSuite.java => ExtD2TestSuite.java} (82%)
create mode 100644 flexmark-ext-d2-diagrams/src/test/resources/ext_d2_ast_spec.md
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000000..c5f3f6b9c7
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "java.configuration.updateBuildConfiguration": "interactive"
+}
\ No newline at end of file
diff --git a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Block.java b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Block.java
new file mode 100644
index 0000000000..1df2b93f75
--- /dev/null
+++ b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Block.java
@@ -0,0 +1,13 @@
+package com.vladsch.flexmark.ext.d2;
+
+import com.vladsch.flexmark.util.ast.Block;
+import com.vladsch.flexmark.util.sequence.BasedSequence;
+import org.jetbrains.annotations.NotNull;
+
+public class D2Block extends Block {
+ @NotNull
+ @Override
+ public BasedSequence[] getSegments() {
+ return EMPTY_SEGMENTS;
+ }
+}
diff --git a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Extension.java b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Extension.java
index c060d6af88..4acd6b5dd5 100644
--- a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Extension.java
+++ b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Extension.java
@@ -7,7 +7,6 @@
import com.vladsch.flexmark.util.data.MutableDataHolder;
import com.vladsch.flexmark.util.data.NullableDataKey;
-import org.jcp.xml.dsig.internal.dom.DOMXPathFilter2Transform;
import org.jetbrains.annotations.NotNull;
/**
@@ -39,7 +38,7 @@ public void extend(Parser.Builder parserBuilder) {
@Override
public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) {
if (htmlRendererBuilder.isRendererType("HTML") || htmlRendererBuilder.isRendererType("JIRA")) {
- htmlRendererBuilder.nodeRendererFactory(new TypographicNodeRenderer.Factory());
+ htmlRendererBuilder.nodeRendererFactory(new D2NodeRenderer.Factory());
}
}
}
diff --git a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Node.java b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Node.java
new file mode 100644
index 0000000000..fa014778aa
--- /dev/null
+++ b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Node.java
@@ -0,0 +1,59 @@
+package com.vladsch.flexmark.ext.d2;
+
+import com.vladsch.flexmark.util.ast.Node;
+import com.vladsch.flexmark.util.sequence.BasedSequence;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class D2Node extends Node {
+ private BasedSequence key;
+ //private List values;
+
+ @NotNull
+ @Override
+ public BasedSequence[] getSegments() {
+ return new BasedSequence[] { key };
+ }
+
+ public D2Node(BasedSequence key, List values) {
+ this.key = key;
+ //this.values = values;
+ for (BasedSequence value : values) {
+ appendChild(new D2Value(value));
+ }
+ }
+
+ public String getKey() {
+ return key.toString();
+ }
+
+ public BasedSequence getKeySequence() {
+ return key;
+ }
+
+ public void setKey(BasedSequence key) {
+ this.key = key;
+ }
+
+ public List getValues() {
+ ArrayList list = new ArrayList<>();
+ Node child = getFirstChild();
+ while (child != null) {
+ list.add(child.getChars().toString());
+ child = child.getNext();
+ }
+ return list;
+ }
+
+ public List getValuesSequences() {
+ ArrayList list = new ArrayList<>();
+ Node child = getFirstChild();
+ while (child != null) {
+ list.add(child.getChars());
+ child = child.getNext();
+ }
+ return list;
+ }
+}
diff --git a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Value.java b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Value.java
new file mode 100644
index 0000000000..20bc0ea35a
--- /dev/null
+++ b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Value.java
@@ -0,0 +1,20 @@
+package com.vladsch.flexmark.ext.d2;
+
+import com.vladsch.flexmark.util.ast.Node;
+import com.vladsch.flexmark.util.sequence.BasedSequence;
+import org.jetbrains.annotations.NotNull;
+
+public class D2Value extends Node {
+ @NotNull
+ @Override
+ public BasedSequence[] getSegments() {
+ return EMPTY_SEGMENTS;
+ }
+
+ public D2Value() {
+ }
+
+ public D2Value(BasedSequence chars) {
+ super(chars);
+ }
+}
diff --git a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2BlockParser.java b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2BlockParser.java
index ba6158fd19..fc34aa5a91 100644
--- a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2BlockParser.java
+++ b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2BlockParser.java
@@ -1,7 +1,7 @@
package com.vladsch.flexmark.ext.d2.internal;
-import com.vladsch.flexmark.ext.yaml.front.matter.YamlFrontMatterBlock;
-import com.vladsch.flexmark.ext.yaml.front.matter.YamlFrontMatterNode;
+import com.vladsch.flexmark.ext.d2.D2Block;
+import com.vladsch.flexmark.ext.d2.D2Node;
import com.vladsch.flexmark.parser.InlineParser;
import com.vladsch.flexmark.parser.block.*;
import com.vladsch.flexmark.parser.core.DocumentBlockParser;
@@ -31,7 +31,7 @@ public class D2BlockParser extends AbstractBlockParser {
private boolean inLiteral;
private BasedSequence currentKey;
private List currentValues;
- private YamlFrontMatterBlock block;
+ private D2Block block;
private BlockContent content;
public D2BlockParser() {
@@ -39,7 +39,7 @@ public D2BlockParser() {
inLiteral = false;
currentKey = null;
currentValues = new ArrayList<>();
- block = new YamlFrontMatterBlock();
+ block = new D2Block();
content = new BlockContent();
}
@@ -72,7 +72,7 @@ public BlockContinue tryContinue(ParserState state) {
if (inYAMLBlock) {
if (REGEX_END.matcher(line).matches()) {
if (currentKey != null) {
- YamlFrontMatterNode child = new YamlFrontMatterNode(currentKey, currentValues);
+ D2Node child = new D2Node(currentKey, currentValues);
child.setCharsFromContent();
block.appendChild(child);
}
@@ -84,7 +84,7 @@ public BlockContinue tryContinue(ParserState state) {
Matcher matcher = REGEX_METADATA.matcher(line);
if (matcher.matches()) {
if (currentKey != null) {
- YamlFrontMatterNode child = new YamlFrontMatterNode(currentKey, currentValues);
+ D2Node child = new D2Node(currentKey, currentValues);
child.setCharsFromContent();
block.appendChild(child);
}
@@ -168,7 +168,7 @@ public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockPar
// check whether this line is the first line of whole document or not
if (parentParser instanceof DocumentBlockParser && parentParser.getBlock().getFirstChild() == null &&
REGEX_BEGIN.matcher(line).matches()) {
- return BlockStart.of(new YamlFrontMatterBlockParser()).atIndex(state.getNextNonSpaceIndex());
+ return BlockStart.of(new D2BlockParser()).atIndex(state.getNextNonSpaceIndex());
}
return BlockStart.none();
diff --git a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2NodeRenderer.java b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2NodeRenderer.java
index 3e0a7d85fb..bffbe4bd96 100644
--- a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2NodeRenderer.java
+++ b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2NodeRenderer.java
@@ -1,7 +1,6 @@
-package com.vladsch.flexmark.ext.typographic.internal;
+package com.vladsch.flexmark.ext.d2.internal;
-import com.vladsch.flexmark.ext.typographic.TypographicQuotes;
-import com.vladsch.flexmark.ext.typographic.TypographicSmarts;
+import com.vladsch.flexmark.ext.d2.D2Node;
import com.vladsch.flexmark.html.HtmlWriter;
import com.vladsch.flexmark.html.renderer.NodeRenderer;
import com.vladsch.flexmark.html.renderer.NodeRendererContext;
@@ -14,33 +13,27 @@
import java.util.Set;
public class D2NodeRenderer implements NodeRenderer {
- public TypographicNodeRenderer(DataHolder options) {
+ public D2NodeRenderer(DataHolder options) {
}
@Override
public Set> getNodeRenderingHandlers() {
HashSet> set = new HashSet<>();
- set.add(new NodeRenderingHandler<>(TypographicSmarts.class, this::render));
- set.add(new NodeRenderingHandler<>(TypographicQuotes.class, this::render));
+ set.add(new NodeRenderingHandler<>(D2Node.class, D2NodeRenderer.this::render));
return set;
}
- private void render(TypographicQuotes node, NodeRendererContext context, HtmlWriter html) {
- if (node.getTypographicOpening() != null && !node.getTypographicOpening().isEmpty()) html.raw(node.getTypographicOpening());
- context.renderChildren(node);
- if (node.getTypographicClosing() != null && !node.getTypographicClosing().isEmpty()) html.raw(node.getTypographicClosing());
+ private void render(D2Node node, NodeRendererContext context, HtmlWriter html) {
+ System.out.println("rendering d2 node 1");
}
- private void render(TypographicSmarts node, NodeRendererContext context, HtmlWriter html) {
- html.raw(node.getTypographicText());
- }
public static class Factory implements NodeRendererFactory {
@NotNull
@Override
public NodeRenderer apply(@NotNull DataHolder options) {
- return new TypographicNodeRenderer(options);
+ return new D2NodeRenderer(options);
}
}
}
diff --git a/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ComboTypographicSpecTest.java b/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/D2SpecTest.java
similarity index 70%
rename from flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ComboTypographicSpecTest.java
rename to flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/D2SpecTest.java
index 650556d05b..5434936e41 100644
--- a/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ComboTypographicSpecTest.java
+++ b/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/D2SpecTest.java
@@ -13,7 +13,7 @@
*
*/
-package com.vladsch.flexmark.ext.typographic;
+package com.vladsch.flexmark.ext.d2;
import com.vladsch.flexmark.core.test.util.RendererSpecTest;
import com.vladsch.flexmark.parser.Parser;
@@ -29,19 +29,15 @@
import java.util.List;
import java.util.Map;
-public class ComboTypographicSpecTest extends RendererSpecTest {
- final private static String SPEC_RESOURCE = "/ext_typographic_ast_spec.md";
- final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(ComboTypographicSpecTest.class, SPEC_RESOURCE);
+public class D2SpecTest extends RendererSpecTest {
+ final private static String SPEC_RESOURCE = "/ext_d2_ast_spec.md";
+ final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(D2SpecTest.class, SPEC_RESOURCE);
final private static DataHolder OPTIONS = new MutableDataSet()
- .set(Parser.EXTENSIONS, Collections.singleton(TypographicExtension.create()))
+ .set(Parser.EXTENSIONS, Collections.singleton(D2Extension.create()))
.toImmutable();
final private static Map optionsMap = new HashMap<>();
- static {
- optionsMap.put("no-quotes", new MutableDataSet().set(TypographicExtension.ENABLE_QUOTES, false));
- optionsMap.put("no-smarts", new MutableDataSet().set(TypographicExtension.ENABLE_SMARTS, false));
- }
- public ComboTypographicSpecTest(@NotNull SpecExample example) {
+ public D2SpecTest(@NotNull SpecExample example) {
super(example, optionsMap, OPTIONS);
}
diff --git a/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ExtTypographicTestSuite.java b/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ExtD2TestSuite.java
similarity index 82%
rename from flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ExtTypographicTestSuite.java
rename to flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ExtD2TestSuite.java
index 950e1f537d..60128f2b6f 100644
--- a/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ExtTypographicTestSuite.java
+++ b/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ExtD2TestSuite.java
@@ -5,7 +5,7 @@
@RunWith(Suite.class)
@Suite.SuiteClasses({
- ComboTypographicSpecTest.class,
+ D2SpecTest.class,
})
public class ExtD2TestSuite {
}
diff --git a/flexmark-ext-d2-diagrams/src/test/resources/ext_d2_ast_spec.md b/flexmark-ext-d2-diagrams/src/test/resources/ext_d2_ast_spec.md
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/flexmark-java.iml b/flexmark-java.iml
index 0644c646e9..221a6e598a 100644
--- a/flexmark-java.iml
+++ b/flexmark-java.iml
@@ -26,6 +26,7 @@
+
diff --git a/pom.xml b/pom.xml
index 3a2a62832b..cd6ca5a296 100644
--- a/pom.xml
+++ b/pom.xml
@@ -368,6 +368,11 @@
flexmark-ext-resizable-image
${project.version}
+
+ com.vladsch.flexmark
+ flexmark-ext-d2-diagrams
+ ${project.version}
+
com.vladsch.flexmark
flexmark-ext-xwiki-macros
From d4e6be3dc512fee65d1ab8f6e2bab49c0a41a20c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Biegun?=
Date: Sat, 26 Aug 2023 02:50:16 -0700
Subject: [PATCH 3/5] enable testing
---
.vscode/settings.json | 10 +++-
.../flexmark-ext-d2-diagrams.iml | 4 +-
.../vladsch/flexmark/ext/d2/D2Extension.java | 2 -
.../ext/d2/internal/D2NodeRenderer.java | 3 +-
.../flexmark/ext/d2/D2FormatterSpecTest.java | 38 +++++++++++++++
.../vladsch/flexmark/ext/d2/D2SpecTest.java | 48 -------------------
.../flexmark/ext/d2/ExtD2TestSuite.java | 11 -----
.../src/test/resources/d2_formatter_spec.md | 24 ++++++++++
.../src/test/resources/ext_d2_ast_spec.md | 0
.../flexmark/test/util/FullSpecTestCase.java | 15 +++---
pom.xml | 1 +
11 files changed, 83 insertions(+), 73 deletions(-)
create mode 100644 flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/D2FormatterSpecTest.java
delete mode 100644 flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/D2SpecTest.java
delete mode 100644 flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ExtD2TestSuite.java
create mode 100644 flexmark-ext-d2-diagrams/src/test/resources/d2_formatter_spec.md
delete mode 100644 flexmark-ext-d2-diagrams/src/test/resources/ext_d2_ast_spec.md
diff --git a/.vscode/settings.json b/.vscode/settings.json
index c5f3f6b9c7..c0453d2234 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,3 +1,9 @@
{
- "java.configuration.updateBuildConfiguration": "interactive"
-}
\ No newline at end of file
+ "java.configuration.updateBuildConfiguration": "interactive",
+ "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx4G -Xms100m -Xlog:disable",
+ "maven.view": "hierarchical",
+ "[markdown]": {
+ "editor.defaultFormatter": null,
+ "editor.formatOnSave": false
+ }
+}
diff --git a/flexmark-ext-d2-diagrams/flexmark-ext-d2-diagrams.iml b/flexmark-ext-d2-diagrams/flexmark-ext-d2-diagrams.iml
index 844dbdab85..49f79a850d 100644
--- a/flexmark-ext-d2-diagrams/flexmark-ext-d2-diagrams.iml
+++ b/flexmark-ext-d2-diagrams/flexmark-ext-d2-diagrams.iml
@@ -5,12 +5,12 @@
-
+
-
+
diff --git a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Extension.java b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Extension.java
index 4acd6b5dd5..774c3a6d64 100644
--- a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Extension.java
+++ b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/D2Extension.java
@@ -3,9 +3,7 @@
import com.vladsch.flexmark.ext.d2.internal.*;
import com.vladsch.flexmark.html.HtmlRenderer;
import com.vladsch.flexmark.parser.Parser;
-import com.vladsch.flexmark.util.data.DataKey;
import com.vladsch.flexmark.util.data.MutableDataHolder;
-import com.vladsch.flexmark.util.data.NullableDataKey;
import org.jetbrains.annotations.NotNull;
diff --git a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2NodeRenderer.java b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2NodeRenderer.java
index bffbe4bd96..e87b82bac6 100644
--- a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2NodeRenderer.java
+++ b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2NodeRenderer.java
@@ -25,10 +25,9 @@ public Set> getNodeRenderingHandlers() {
}
private void render(D2Node node, NodeRendererContext context, HtmlWriter html) {
- System.out.println("rendering d2 node 1");
+ System.out.println("rendering d2 node
");
}
-
public static class Factory implements NodeRendererFactory {
@NotNull
@Override
diff --git a/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/D2FormatterSpecTest.java b/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/D2FormatterSpecTest.java
new file mode 100644
index 0000000000..d8c96510dc
--- /dev/null
+++ b/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/D2FormatterSpecTest.java
@@ -0,0 +1,38 @@
+package com.vladsch.flexmark.ext.d2;
+
+import com.vladsch.flexmark.core.test.util.FormatterSpecTest;
+import com.vladsch.flexmark.formatter.Formatter;
+import com.vladsch.flexmark.parser.Parser;
+import com.vladsch.flexmark.test.util.spec.ResourceLocation;
+import com.vladsch.flexmark.test.util.spec.SpecExample;
+import com.vladsch.flexmark.util.data.DataHolder;
+import com.vladsch.flexmark.util.data.MutableDataSet;
+import org.jetbrains.annotations.NotNull;
+import org.junit.runners.Parameterized;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+public class D2FormatterSpecTest extends FormatterSpecTest {
+ final private static String SPEC_RESOURCE = "/d2_formatter_spec.md";
+ final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE);
+ final private static DataHolder OPTIONS = new MutableDataSet()
+ .set(Parser.EXTENSIONS, Collections.singleton(D2Extension.create()))
+ .toImmutable();
+
+ final private static Map optionsMap = placementAndSortOptions(
+ Parser.REFERENCES_KEEP,
+ Formatter.REFERENCE_PLACEMENT,
+ Formatter.REFERENCE_SORT);
+
+ public D2FormatterSpecTest(@NotNull SpecExample example) {
+ super(example, optionsMap, OPTIONS);
+ }
+
+ @Parameterized.Parameters(name = "{0}")
+ public static List data() {
+ List data = getTestData(RESOURCE_LOCATION);
+ return data;
+ }
+}
diff --git a/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/D2SpecTest.java b/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/D2SpecTest.java
deleted file mode 100644
index 5434936e41..0000000000
--- a/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/D2SpecTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2015-2016 Vladimir Schneider , all rights reserved.
- *
- * This code is private property of the copyright holder and cannot be used without
- * having obtained a license or prior written permission of the of the copyright holder.
- *
- * 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 com.vladsch.flexmark.ext.d2;
-
-import com.vladsch.flexmark.core.test.util.RendererSpecTest;
-import com.vladsch.flexmark.parser.Parser;
-import com.vladsch.flexmark.test.util.spec.ResourceLocation;
-import com.vladsch.flexmark.test.util.spec.SpecExample;
-import com.vladsch.flexmark.util.data.DataHolder;
-import com.vladsch.flexmark.util.data.MutableDataSet;
-import org.jetbrains.annotations.NotNull;
-import org.junit.runners.Parameterized;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class D2SpecTest extends RendererSpecTest {
- final private static String SPEC_RESOURCE = "/ext_d2_ast_spec.md";
- final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(D2SpecTest.class, SPEC_RESOURCE);
- final private static DataHolder OPTIONS = new MutableDataSet()
- .set(Parser.EXTENSIONS, Collections.singleton(D2Extension.create()))
- .toImmutable();
-
- final private static Map optionsMap = new HashMap<>();
- public D2SpecTest(@NotNull SpecExample example) {
- super(example, optionsMap, OPTIONS);
- }
-
- @Parameterized.Parameters(name = "{0}")
- public static List data() {
- return getTestData(RESOURCE_LOCATION);
- }
-}
diff --git a/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ExtD2TestSuite.java b/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ExtD2TestSuite.java
deleted file mode 100644
index 60128f2b6f..0000000000
--- a/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/ExtD2TestSuite.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.vladsch.flexmark.ext.d2;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- D2SpecTest.class,
-})
-public class ExtD2TestSuite {
-}
diff --git a/flexmark-ext-d2-diagrams/src/test/resources/d2_formatter_spec.md b/flexmark-ext-d2-diagrams/src/test/resources/d2_formatter_spec.md
new file mode 100644
index 0000000000..4eea790092
--- /dev/null
+++ b/flexmark-ext-d2-diagrams/src/test/resources/d2_formatter_spec.md
@@ -0,0 +1,24 @@
+---
+title: D2 Diagrams Extension Formatting Spec
+author: Paweł Biegun
+version: 1.0
+date: '2023.08.26'
+license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)'
+...
+
+---
+
+## D2 Diagrams
+
+Converts d2 diagram to svg
+
+```````````````````````````````` example D2 Diagrams: 1
+```d2
+A -> B
+B -> A
+```
+.
+.
+Document[0, 23]
+ D2Block[0, 23]
+````````````````````````````````
\ No newline at end of file
diff --git a/flexmark-ext-d2-diagrams/src/test/resources/ext_d2_ast_spec.md b/flexmark-ext-d2-diagrams/src/test/resources/ext_d2_ast_spec.md
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/FullSpecTestCase.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/FullSpecTestCase.java
index 67f0b36ca5..b8812ef5dc 100644
--- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/FullSpecTestCase.java
+++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/FullSpecTestCase.java
@@ -10,7 +10,8 @@
public abstract class FullSpecTestCase extends RenderingTestCase implements SpecExampleProcessor {
@NotNull
public DumpSpecReader create(@NotNull ResourceLocation location) {
- return SpecReader.create(location, (stream, fileUrl) -> new DumpSpecReader(stream, this, fileUrl, compoundSections()));
+ return SpecReader.create(location,
+ (stream, fileUrl) -> new DumpSpecReader(stream, this, fileUrl, compoundSections()));
}
protected boolean compoundSections() {
@@ -30,7 +31,8 @@ protected void fullTestSpecComplete() {
@Test
public void testSpecExample() {
ResourceLocation location = getSpecResourceLocation();
- if (location.isNull()) return;
+ if (location.isNull())
+ return;
fullTestSpecStarting();
DumpSpecReader reader = create(location);
@@ -40,10 +42,11 @@ public void testSpecExample() {
String actual = reader.getFullSpec();
String expected = reader.getExpectedFullSpec();
-// // NOTE: reading the full spec does not work when examples are modified by checkExample()
-// String fullSpec = SpecReader.readSpec(location);
-// assertEquals(reader.getFileUrl(), expected, fullSpec);
-
+ // // NOTE: reading the full spec does not work when examples are modified by
+ // checkExample()
+ // String fullSpec = SpecReader.readSpec(location);
+ // assertEquals(reader.getFileUrl(), expected, fullSpec);
+ System.out.println("test");
if (!reader.getFileUrl().isEmpty()) {
assertEquals(reader.getFileUrl(), expected, actual);
} else {
diff --git a/pom.xml b/pom.xml
index cd6ca5a296..9862faf655 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,6 +56,7 @@
flexmark-ext-yaml-front-matter
flexmark-ext-youtube-embedded
flexmark-ext-zzzzzz
+ flexmark-ext-d2-diagrams
flexmark-test-util
flexmark-tree-iteration
flexmark-util
From 09befc1aeea8febf3c4f9bf5edf48b5b131380e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Biegun?=
Date: Sat, 26 Aug 2023 10:14:19 -0700
Subject: [PATCH 4/5] save work
---
.../flexmark/ext/d2/internal/D2NodeRenderer.java | 6 ++++--
...atterSpecTest.java => D2RendererSpecTest.java} | 15 ++++-----------
.../src/test/resources/d2_formatter_spec.md | 1 +
.../flexmark/test/util/FullSpecTestCase.java | 1 -
4 files changed, 9 insertions(+), 14 deletions(-)
rename flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/{D2FormatterSpecTest.java => D2RendererSpecTest.java} (65%)
diff --git a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2NodeRenderer.java b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2NodeRenderer.java
index e87b82bac6..0cc0acf952 100644
--- a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2NodeRenderer.java
+++ b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2NodeRenderer.java
@@ -20,12 +20,14 @@ public D2NodeRenderer(DataHolder options) {
@Override
public Set> getNodeRenderingHandlers() {
HashSet> set = new HashSet<>();
- set.add(new NodeRenderingHandler<>(D2Node.class, D2NodeRenderer.this::render));
+ set.add(new NodeRenderingHandler<>(D2Node.class, this::render));
return set;
}
private void render(D2Node node, NodeRendererContext context, HtmlWriter html) {
- System.out.println("rendering d2 node
");
+ html.tag("p");
+ html.text("rendering d2 node");
+ html.tag("/p");
}
public static class Factory implements NodeRendererFactory {
diff --git a/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/D2FormatterSpecTest.java b/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/D2RendererSpecTest.java
similarity index 65%
rename from flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/D2FormatterSpecTest.java
rename to flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/D2RendererSpecTest.java
index d8c96510dc..df407a00f9 100644
--- a/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/D2FormatterSpecTest.java
+++ b/flexmark-ext-d2-diagrams/src/test/java/com/vladsch/flexmark/ext/d2/D2RendererSpecTest.java
@@ -1,7 +1,6 @@
package com.vladsch.flexmark.ext.d2;
-import com.vladsch.flexmark.core.test.util.FormatterSpecTest;
-import com.vladsch.flexmark.formatter.Formatter;
+import com.vladsch.flexmark.core.test.util.RendererSpecTest;
import com.vladsch.flexmark.parser.Parser;
import com.vladsch.flexmark.test.util.spec.ResourceLocation;
import com.vladsch.flexmark.test.util.spec.SpecExample;
@@ -12,22 +11,16 @@
import java.util.Collections;
import java.util.List;
-import java.util.Map;
-public class D2FormatterSpecTest extends FormatterSpecTest {
+public class D2RendererSpecTest extends RendererSpecTest {
final private static String SPEC_RESOURCE = "/d2_formatter_spec.md";
final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE);
final private static DataHolder OPTIONS = new MutableDataSet()
.set(Parser.EXTENSIONS, Collections.singleton(D2Extension.create()))
.toImmutable();
- final private static Map optionsMap = placementAndSortOptions(
- Parser.REFERENCES_KEEP,
- Formatter.REFERENCE_PLACEMENT,
- Formatter.REFERENCE_SORT);
-
- public D2FormatterSpecTest(@NotNull SpecExample example) {
- super(example, optionsMap, OPTIONS);
+ public D2RendererSpecTest(@NotNull SpecExample example) {
+ super(example, null, OPTIONS);
}
@Parameterized.Parameters(name = "{0}")
diff --git a/flexmark-ext-d2-diagrams/src/test/resources/d2_formatter_spec.md b/flexmark-ext-d2-diagrams/src/test/resources/d2_formatter_spec.md
index 4eea790092..beda631ce4 100644
--- a/flexmark-ext-d2-diagrams/src/test/resources/d2_formatter_spec.md
+++ b/flexmark-ext-d2-diagrams/src/test/resources/d2_formatter_spec.md
@@ -18,6 +18,7 @@ A -> B
B -> A
```
.
+rendering d2 node
.
Document[0, 23]
D2Block[0, 23]
diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/FullSpecTestCase.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/FullSpecTestCase.java
index b8812ef5dc..5c26470cf9 100644
--- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/FullSpecTestCase.java
+++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/FullSpecTestCase.java
@@ -46,7 +46,6 @@ public void testSpecExample() {
// checkExample()
// String fullSpec = SpecReader.readSpec(location);
// assertEquals(reader.getFileUrl(), expected, fullSpec);
- System.out.println("test");
if (!reader.getFileUrl().isEmpty()) {
assertEquals(reader.getFileUrl(), expected, actual);
} else {
From 3059252c21c6063e9382b5e1368d8bd9138f74dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Biegun?=
Date: Sat, 26 Aug 2023 11:04:05 -0700
Subject: [PATCH 5/5] remove redundant code from parser and parse node
---
.../ext/d2/internal/D2BlockParser.java | 67 +++----------------
.../src/test/resources/d2_formatter_spec.md | 1 +
2 files changed, 10 insertions(+), 58 deletions(-)
diff --git a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2BlockParser.java b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2BlockParser.java
index fc34aa5a91..7d945eb50e 100644
--- a/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2BlockParser.java
+++ b/flexmark-ext-d2-diagrams/src/main/java/com/vladsch/flexmark/ext/d2/internal/D2BlockParser.java
@@ -9,34 +9,26 @@
import com.vladsch.flexmark.util.ast.BlockContent;
import com.vladsch.flexmark.util.data.DataHolder;
import com.vladsch.flexmark.util.sequence.BasedSequence;
-import com.vladsch.flexmark.util.sequence.PrefixedSubSequence;
-import com.vladsch.flexmark.util.sequence.SegmentedSequence;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class D2BlockParser extends AbstractBlockParser {
- final private static Pattern REGEX_METADATA = Pattern.compile("^[ ]{0,3}([A-Za-z0-9_\\-.]+):\\s*(.*)");
- final private static Pattern REGEX_METADATA_LIST = Pattern.compile("^[ ]+-\\s*(.*)");
- final private static Pattern REGEX_METADATA_LITERAL = Pattern.compile("^\\s*(.*)");
final private static Pattern REGEX_BEGIN = Pattern.compile("^`{3}d2(\\s.*)?");
- final private static Pattern REGEX_END = Pattern.compile("^(`{3}|\\.{3})(\\s.*)?");
+ final private static Pattern REGEX_END = Pattern.compile("^`{3}(\\s.*)?");
- private boolean inYAMLBlock;
- private boolean inLiteral;
+ private boolean inD2Block;
private BasedSequence currentKey;
private List currentValues;
private D2Block block;
private BlockContent content;
public D2BlockParser() {
- inYAMLBlock = true;
- inLiteral = false;
+ inD2Block = true;
currentKey = null;
currentValues = new ArrayList<>();
block = new D2Block();
@@ -69,61 +61,20 @@ public void closeBlock(ParserState state) {
public BlockContinue tryContinue(ParserState state) {
final BasedSequence line = state.getLine();
- if (inYAMLBlock) {
+ if (inD2Block) {
if (REGEX_END.matcher(line).matches()) {
- if (currentKey != null) {
- D2Node child = new D2Node(currentKey, currentValues);
- child.setCharsFromContent();
- block.appendChild(child);
- }
- // add the last line
- addLine(state, line);
+ System.out.println("test");
+ D2Node child = new D2Node(line, currentValues);
+ child.setCharsFromContent();
+ block.appendChild(child);
return BlockContinue.finished();
- }
-
- Matcher matcher = REGEX_METADATA.matcher(line);
- if (matcher.matches()) {
- if (currentKey != null) {
- D2Node child = new D2Node(currentKey, currentValues);
- child.setCharsFromContent();
- block.appendChild(child);
- }
-
- inLiteral = false;
- currentKey = line.subSequence(matcher.start(1), matcher.end(1));
- currentValues = new ArrayList<>();
- if ("|".equals(matcher.group(2))) {
- inLiteral = true;
- } else if (!"".equals(matcher.group(2))) {
- currentValues.add(line.subSequence(matcher.start(2), matcher.end(2)));
- }
-
- return BlockContinue.atIndex(state.getIndex());
} else {
- if (inLiteral) {
- matcher = REGEX_METADATA_LITERAL.matcher(line);
- if (matcher.matches()) {
- if (currentValues.size() == 1) {
- BasedSequence combined = SegmentedSequence.create(currentValues.get(0), PrefixedSubSequence.prefixOf("\n", line.subSequence(matcher.start(1), matcher.end(1)).trim()));
- currentValues.set(0, combined);
- } else {
- currentValues.add(line.subSequence(matcher.start(1), matcher.end(1)).trim());
- }
- }
- } else {
- matcher = REGEX_METADATA_LIST.matcher(line);
- if (matcher.matches()) {
- currentValues.add(line.subSequence(matcher.start(1), matcher.end(1)));
- }
- }
-
return BlockContinue.atIndex(state.getIndex());
}
} else if (REGEX_BEGIN.matcher(line).matches()) {
- inYAMLBlock = true;
+ inD2Block = true;
return BlockContinue.atIndex(state.getIndex());
}
-
return BlockContinue.none();
}
diff --git a/flexmark-ext-d2-diagrams/src/test/resources/d2_formatter_spec.md b/flexmark-ext-d2-diagrams/src/test/resources/d2_formatter_spec.md
index beda631ce4..12a5f9b97a 100644
--- a/flexmark-ext-d2-diagrams/src/test/resources/d2_formatter_spec.md
+++ b/flexmark-ext-d2-diagrams/src/test/resources/d2_formatter_spec.md
@@ -22,4 +22,5 @@ B -> A
.
Document[0, 23]
D2Block[0, 23]
+ D2Node[20, 23]
````````````````````````````````
\ No newline at end of file