mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
support alternate inline format to work around docs shortcodes
This commit is contained in:
@@ -51,6 +51,7 @@ public class BindPoint {
|
||||
reference,
|
||||
/**
|
||||
* a definition bindpoint is expressed as anything between double curly braces like <pre>{@code {{Identity()}}</pre>
|
||||
* or <pre>{@code {(Identity())}}
|
||||
*/
|
||||
definition
|
||||
}
|
||||
|
||||
@@ -37,7 +37,9 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class BindPointParser implements BiFunction<String, Map<String, String>, BindPointParser.Result> {
|
||||
|
||||
public final static Pattern BINDPOINT_ANCHOR = Pattern.compile("(\\{((?<anchor>\\w+[-_<>,\\d\\w.]*)})|(\\{\\{(?<extended>(?!}}).+?)}}))");
|
||||
public final static Pattern BINDPOINT_ANCHOR = Pattern.compile(
|
||||
"(\\{((?<reference>\\w+[-_<>,\\d\\w.]*)})|(\\{\\{(?<inline1>(?!}}).+?)}})|(\\{\\((?<inline2>(?!\\)}).+?)\\)}))"
|
||||
);
|
||||
public final static String DEFINITION = "DEFINITION";
|
||||
|
||||
|
||||
@@ -55,14 +57,18 @@ public class BindPointParser implements BiFunction<String, Map<String, String>,
|
||||
spans.add(pre);
|
||||
lastMatch = m.end();
|
||||
|
||||
String anchor = m.group("anchor");
|
||||
String extendedAnchor = m.group("extended");
|
||||
if (anchor != null) {
|
||||
bindpoints.add(BindPoint.of(anchor, bindings.getOrDefault(anchor, null), BindPoint.Type.reference));
|
||||
spans.add(anchor);
|
||||
} else if (extendedAnchor != null) {
|
||||
bindpoints.add(BindPoint.of(DEFINITION, extendedAnchor, BindPoint.Type.definition));
|
||||
spans.add(extendedAnchor);
|
||||
String reference = m.group("reference");
|
||||
String inline1 = m.group("inline1");
|
||||
String inline2 = m.group("inline2");
|
||||
if (reference != null) {
|
||||
bindpoints.add(BindPoint.of(reference, bindings.getOrDefault(reference, null), BindPoint.Type.reference));
|
||||
spans.add(reference);
|
||||
} else if (inline1 != null) {
|
||||
bindpoints.add(BindPoint.of(DEFINITION, inline1, BindPoint.Type.definition));
|
||||
spans.add(inline1);
|
||||
} else if (inline2 != null) {
|
||||
bindpoints.add(BindPoint.of(DEFINITION, inline2, BindPoint.Type.definition));
|
||||
spans.add(inline2);
|
||||
} else {
|
||||
throw new BasicError("Unable to parse: " + template);
|
||||
}
|
||||
|
||||
@@ -60,6 +60,20 @@ public class BindPointParserTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInline2TypeBindPoint() {
|
||||
BindPointParser bpp = new BindPointParser();
|
||||
assertThat(bpp.apply("test {(this is a definition)} and {{another}}", Map.of())).isEqualTo(
|
||||
new BindPointParser.Result(
|
||||
List.of("test ","this is a definition"," and ","another",""),
|
||||
List.of(
|
||||
BindPoint.of(BindPointParser.DEFINITION,"this is a definition", BindPoint.Type.definition),
|
||||
BindPoint.of(BindPointParser.DEFINITION, "another",BindPoint.Type.definition)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCurlyBracesWithinPattern() {
|
||||
BindPointParser bpp = new BindPointParser();
|
||||
|
||||
Reference in New Issue
Block a user