Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ Instead of defining arguments on the ''!contents'' widget, variables can be defi
-!Defaults: Suite(*), Test(+), Imported(@), Symbolic(>), Skip(-). | PROPERTY_TOC {true} !-
-!PROPERTY_CHARACTERS {*+@>-}|
|-c |Show number of test pages in a suite. | |
|-tFOO |Only include pages whose 'Suites' property contains FOO.| |
79 changes: 44 additions & 35 deletions src/fitnesse/wikitext/parser/Contents.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,52 @@ public Contents() {

@Override
public Maybe<Symbol> parse(Symbol current, Parser parser) {
Symbol body = parser.parseToEnd(SymbolType.Newline);
for (Symbol child: body.getChildren()) {
if (child.isType(SymbolType.Whitespace)) continue;
String option = child.getContent();
if (!option.startsWith("-")) return Symbol.nothing;
if (option.equals("-R")) {
current.putProperty(option, String.valueOf(Integer.MAX_VALUE));
}
else if (option.startsWith("-R")) {
current.putProperty("-R", option.substring(2));
}
else {
current.putProperty(option, "");
Symbol body = parser.parseToEnd(SymbolType.Newline);

for (int i = 0; i < body.getChildren().size(); i++) {
Symbol child = body.getChildren().get(i);

if (child.isType(SymbolType.Whitespace)) continue;
String option = child.getContent();
if (!option.startsWith("-")) return Symbol.nothing;
if (option.equals("-R")) {
current.putProperty(option, String.valueOf(Integer.MAX_VALUE));
} else if (option.startsWith("-R")) {
current.putProperty("-R", option.substring(2));
} else if (option.equalsIgnoreCase("-t") || option.equalsIgnoreCase("-tag")) {
if (i + 1 < body.getChildren().size()) {
Symbol tagValueSymbol = body.getChildren().get(i + 1);
if (!tagValueSymbol.isType(SymbolType.Whitespace)) {
current.putProperty("-tag", tagValueSymbol.getContent());
i++;
}
}
} else {
current.putProperty(option, "");
}
}

current.copyVariables(new String[] {
Names.HELP_TOC,
Names.HELP_INSTEAD_OF_TITLE_TOC,
Names.REGRACE_TOC,
Names.PROPERTY_TOC,
Names.FILTER_TOC,
Names.MORE_SUFFIX_TOC,
Names.PROPERTY_CHARACTERS,
Names.TEST_PAGE_COUNT_TOC},
parser.getVariableSource());

return new Maybe<>(current);
}
@Override
public String toTarget(Translator translator, Symbol symbol) {
ContentsItemBuilder itemBuilder
= new ContentsItemBuilder(symbol, 1, translator.getPage());
HtmlTag contentsDiv = new HtmlTag("div");
contentsDiv.addAttribute("class", "contents");
contentsDiv.add(HtmlUtil.makeBold("Contents:"));
contentsDiv.add(itemBuilder.buildLevel(translator.getPage()));
return contentsDiv.html();
current.copyVariables(new String[]{
Names.HELP_TOC,
Names.HELP_INSTEAD_OF_TITLE_TOC,
Names.REGRACE_TOC,
Names.PROPERTY_TOC,
Names.FILTER_TOC,
Names.MORE_SUFFIX_TOC,
Names.PROPERTY_CHARACTERS,
Names.TEST_PAGE_COUNT_TOC
}, parser.getVariableSource());

return new Maybe<>(current);
}

public String toTarget(Translator translator, Symbol symbol) {
ContentsItemBuilder itemBuilder
= new ContentsItemBuilder(symbol, 1, translator.getPage());
HtmlTag contentsDiv = new HtmlTag("div");
contentsDiv.addAttribute("class", "contents");
contentsDiv.add(HtmlUtil.makeBold("Contents:"));
contentsDiv.add(itemBuilder.buildLevel(translator.getPage()));
return contentsDiv.html();
}
}
Loading