Skip to content

Commit

Permalink
[asciidoc] fix description list regex
Browse files Browse the repository at this point in the history
  • Loading branch information
rmannibucau committed Mar 9, 2024
1 parent bf9370d commit 0e61a45
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public class Parser {

private static final Pattern CALLOUT_REF = Pattern.compile("<(?<number>\\d+)>");
private static final Pattern CALLOUT = Pattern.compile("^<(?<number>[\\d+.]+)> (?<description>.+)$");
private static final Pattern DESCRIPTION_LIST_PREFIX = Pattern.compile("^(?<name>[^:]+)(?<marker>::+)(?<content>.*)");
private static final Pattern DESCRIPTION_LIST_PREFIX = Pattern.compile("^(?<name>(?!::).*)(?<marker>::+)(?<content>.*)");
private static final Pattern ORDERED_LIST_PREFIX = Pattern.compile("^[0-9]*(?<dots>\\.+) .+");
private static final Pattern UNORDERED_LIST_PREFIX = Pattern.compile("^(?<wildcard>\\*+) .+");
private static final Pattern ATTRIBUTE_DEFINITION = Pattern.compile("^:(?<name>[^\\n\\t:]+):( +(?<value>.+))? *$");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,34 @@
import static org.junit.jupiter.api.Assertions.assertEquals;

class ParserTest {
@Test
void definitionList() {
final var body = new Parser().parseBody(new Reader(List.of("""
generate-frisby-skeleton.output (env: `GENERATE_FRISBY_SKELETON_OUTPUT`)::
Where to generate the skeleton. Default: `hcms-frisby`.
hcms.database-init.enabled (env: `HCMS_DATABASE_INIT_ENABLED`)::
Should database be initialized at startup. Default: `true`.""".split("\n"))), null);
assertEquals(List.of(
new DescriptionList(Map.of(
new Paragraph(List.of(
new Text(List.of(), "generate-frisby-skeleton.output (env: ", Map.of()),
new Code("GENERATE_FRISBY_SKELETON_OUTPUT", List.of(), Map.of(), true),
new Text(List.of(), ")", Map.of())), Map.of()),
new Paragraph(List.of(
new Text(List.of(), "Where to generate the skeleton. Default: ", Map.of()),
new Code("hcms-frisby", List.of(), Map.of(), true),
new Text(List.of(), ".", Map.of())), Map.of()),
new Paragraph(List.of(
new Text(List.of(), "hcms.database-init.enabled (env: ", Map.of()),
new Code("HCMS_DATABASE_INIT_ENABLED", List.of(), Map.of(), true),
new Text(List.of(), ")", Map.of())), Map.of()),
new Paragraph(List.of(
new Text(List.of(), "Should database be initialized at startup. Default: ", Map.of()),
new Code("true", List.of(), Map.of(), true),
new Text(List.of(), ".", Map.of())), Map.of())), Map.of())
), body.children());
}

@Test
void parseHeader() {
final var header = new Parser().parseHeader(new Reader(List.of("= Title", ":attr-1: v1", ":attr-2: v2", "", "content")));
Expand Down

0 comments on commit 0e61a45

Please sign in to comment.