support alternate inline format to work around docs shortcodes

This commit is contained in:
Jonathan Shook 2022-12-22 18:23:16 -06:00
parent 78afbfbc52
commit c316bed26a
5 changed files with 35 additions and 10 deletions

View File

@ -200,7 +200,7 @@ that each activity that uses the http driver shares a client instance across
all threads by default. If you want to have a new http client per-thread, all threads by default. If you want to have a new http client per-thread,
simply add a binding for `space: ThreadNumToInteger()` and reference it in simply add a binding for `space: ThreadNumToInteger()` and reference it in
an op template like `space: {space}`, OR use an inline op field in your op an op template like `space: {space}`, OR use an inline op field in your op
template like `space: {{ThreadNumToInteger()}}`. template like `space: {(ThreadNumToInteger())}`.
You can use any binding function you want for the space op field. However, You can use any binding function you want for the space op field. However,
if you were to assign it something like "space: {{Identity()}}" you would if you were to assign it something like "space: {{Identity()}}" you would

View File

@ -9,6 +9,10 @@
* Deprecated old drivers (conflicts, etc) * Deprecated old drivers (conflicts, etc)
- version conflicts (removing cql drivers 1.9.* 3.*) - version conflicts (removing cql drivers 1.9.* 3.*)
## New Topic
* Advanced linearization features
* variable capture in results
## new Docs ## new Docs
javadoc site javadoc site
developer guide developer guide

View File

@ -51,6 +51,7 @@ public class BindPoint {
reference, reference,
/** /**
* a definition bindpoint is expressed as anything between double curly braces like <pre>{@code {{Identity()}}</pre> * a definition bindpoint is expressed as anything between double curly braces like <pre>{@code {{Identity()}}</pre>
* or <pre>{@code {(Identity())}}
*/ */
definition definition
} }

View File

@ -37,7 +37,9 @@ import java.util.regex.Pattern;
*/ */
public class BindPointParser implements BiFunction<String, Map<String, String>, BindPointParser.Result> { 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"; public final static String DEFINITION = "DEFINITION";
@ -55,14 +57,18 @@ public class BindPointParser implements BiFunction<String, Map<String, String>,
spans.add(pre); spans.add(pre);
lastMatch = m.end(); lastMatch = m.end();
String anchor = m.group("anchor"); String reference = m.group("reference");
String extendedAnchor = m.group("extended"); String inline1 = m.group("inline1");
if (anchor != null) { String inline2 = m.group("inline2");
bindpoints.add(BindPoint.of(anchor, bindings.getOrDefault(anchor, null), BindPoint.Type.reference)); if (reference != null) {
spans.add(anchor); bindpoints.add(BindPoint.of(reference, bindings.getOrDefault(reference, null), BindPoint.Type.reference));
} else if (extendedAnchor != null) { spans.add(reference);
bindpoints.add(BindPoint.of(DEFINITION, extendedAnchor, BindPoint.Type.definition)); } else if (inline1 != null) {
spans.add(extendedAnchor); 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 { } else {
throw new BasicError("Unable to parse: " + template); throw new BasicError("Unable to parse: " + template);
} }

View File

@ -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 @Test
public void testCurlyBracesWithinPattern() { public void testCurlyBracesWithinPattern() {
BindPointParser bpp = new BindPointParser(); BindPointParser bpp = new BindPointParser();