mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
moved from commonmark to inhouse MutableMarkdown for verification
This commit is contained in:
@@ -51,6 +51,11 @@ public class MutableMarkdown {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public MutableMarkdown(String rawMarkdown) {
|
||||||
|
this.path = null;
|
||||||
|
this.rawMarkdown = rawMarkdown;
|
||||||
|
parseStructure(rawMarkdown);
|
||||||
|
}
|
||||||
|
|
||||||
private void parseStructure(String rawMarkdown) {
|
private void parseStructure(String rawMarkdown) {
|
||||||
AbstractYamlFrontMatterVisitor v = new AbstractYamlFrontMatterVisitor();
|
AbstractYamlFrontMatterVisitor v = new AbstractYamlFrontMatterVisitor();
|
||||||
@@ -69,13 +74,19 @@ public class MutableMarkdown {
|
|||||||
} else if (node instanceof WhiteSpace) {
|
} else if (node instanceof WhiteSpace) {
|
||||||
} else if (node instanceof YamlFrontMatterBlock) {
|
} else if (node instanceof YamlFrontMatterBlock) {
|
||||||
} else {
|
} else {
|
||||||
|
if(this.path != null)
|
||||||
throw new RuntimeException("The markdown file at '" + this.path.toString() + "' must have an initial heading as a title, before any other element, but found:" + node.getClass().getSimpleName());
|
throw new RuntimeException("The markdown file at '" + this.path.toString() + "' must have an initial heading as a title, before any other element, but found:" + node.getClass().getSimpleName());
|
||||||
|
else
|
||||||
|
throw new RuntimeException("The markdown string provided must have an initial heading as a title, before any other element, but found: "+ node.getClass().getSimpleName());
|
||||||
}
|
}
|
||||||
node=node.getNext();
|
node=node.getNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (frontMatter.getTitle()==null || frontMatter.getTitle().isEmpty()) {
|
if (frontMatter.getTitle()==null || frontMatter.getTitle().isEmpty()) {
|
||||||
|
if(this.path != null)
|
||||||
throw new RuntimeException("The markdown file at '" + this.path.toString() + "' has no heading to use as a title.");
|
throw new RuntimeException("The markdown file at '" + this.path.toString() + "' has no heading to use as a title.");
|
||||||
|
else
|
||||||
|
throw new RuntimeException("The markdown string provided has no heading to use as a title.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +101,10 @@ public class MutableMarkdown {
|
|||||||
if (end>=0) {
|
if (end>=0) {
|
||||||
return rawMarkdown.substring(end+4);
|
return rawMarkdown.substring(end+4);
|
||||||
} else {
|
} else {
|
||||||
|
if(path != null)
|
||||||
throw new RuntimeException("Unable to find matching boundaries in " + path.toString() + ": " + boundary);
|
throw new RuntimeException("Unable to find matching boundaries in " + path.toString() + ": " + boundary);
|
||||||
|
else
|
||||||
|
throw new RuntimeException("Unable to find matching boundaries in provided markdown: " + boundary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,12 @@
|
|||||||
<artifactId>adapter-diag</artifactId>
|
<artifactId>adapter-diag</artifactId>
|
||||||
<version>4.17.31-SNAPSHOT</version>
|
<version>4.17.31-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.commonmark</groupId>
|
||||||
|
<artifactId>commonmark</artifactId>
|
||||||
|
<version>0.20.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ import java.util.concurrent.Future;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
import org.commonmark.parser.Parser;
|
||||||
|
import org.commonmark.node.Node;
|
||||||
|
|
||||||
public class BundledMarkdownZipExporter {
|
public class BundledMarkdownZipExporter {
|
||||||
|
|
||||||
@@ -74,10 +76,14 @@ public class BundledMarkdownZipExporter {
|
|||||||
{
|
{
|
||||||
String filename = entry.getKey();
|
String filename = entry.getKey();
|
||||||
StringBuilder fileStringBuilder = entry.getValue();
|
StringBuilder fileStringBuilder = entry.getValue();
|
||||||
|
MutableMarkdown parsed = new MutableMarkdown(fileStringBuilder.toString());
|
||||||
|
for (BundledMarkdownProcessor filter : this.filters) {
|
||||||
|
parsed = filter.apply(parsed);
|
||||||
|
}
|
||||||
ZipEntry zipEntry = new ZipEntry(bindingsPrefix + filename);
|
ZipEntry zipEntry = new ZipEntry(bindingsPrefix + filename);
|
||||||
zipEntry.setTime(new Date().getTime());
|
zipEntry.setTime(new Date().getTime());
|
||||||
zipstream.putNextEntry(zipEntry);
|
zipstream.putNextEntry(zipEntry);
|
||||||
zipstream.write(fileStringBuilder.toString().getBytes());
|
zipstream.write(parsed.getComposedMarkdown().getBytes(StandardCharsets.UTF_8));
|
||||||
zipstream.closeEntry();
|
zipstream.closeEntry();
|
||||||
}
|
}
|
||||||
zipstream.finish();
|
zipstream.finish();
|
||||||
|
|||||||
Reference in New Issue
Block a user