Skip to content

Commit

Permalink
No links table (#1310)
Browse files Browse the repository at this point in the history
* Table type (prefix ^) that doesn't parse wikiwords, links and emailadresses

* Added acceptance test that shows no links are generated in a NoLinksTable
  • Loading branch information
tcnh authored Nov 29, 2020
1 parent df34332 commit d21d53a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,29 @@
|Response Examiner.|
|type|pattern|matches?|
|contents|!-''italic''-!|true|
#


'''Test that wikiwords, http links and e-mail adresses don't get interpreted inside no-links tables.'''
|script |
|start|Page Builder |
|line |!-^|WikiWord|https://localhost|[email protected]|-!|
|page |!-TableTestPageFour-! |
#
#
|Response Requester. |
|uri |valid?|contents?|
|!-TableTestPageFour-!|true | |
#
#
|Response Examiner. |
|type |pattern |matches?|wrapped html?|
|contents|!-<td>WikiWord</td>-!|true | |
#
|Response Examiner. |
|type |pattern |matches?|
|contents|!-WikiWord<a title="create page" href="WikiWord?edit&nonExistent=true">[?]</a>-!|false |
|contents|!-<td>https://localhost</td>-! |true |
|contents|!-<a href="https://localhost">https://localhost</a>-! |false |
|contents|!-<td>[email protected]</td>-! |true |
|contents|!-<a href="mailto:[email protected]">[email protected]</a>-! |false |
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,20 @@ If you don't want any markup directives interpreted in the table, then you can u
|!1 like a literal|--and is especially useful--|''for test tables.''|
|^SinceTheyTend| * to have WikiWord symbols in them.|

!2 No Link Generating tables
If you don't want Wikiwords, URL's or E-mail adresses interpreted in the table, but you do want symbols like !-!today-! interpreted, then you can use a special form where your table is preceded with a ^ character:
'''Markup Text'''
{{{^|ThisTableWillExclude|WikiWords, http://links|and [email protected] |
|from being parsed, |however |''it will respect formatting''|
|and parse symbols like !-!today (yyyyMMdd)-! |}}}
'''Displays as:'''
^|ThisTableWillExclude|WikiWords, http://links|and [email protected] |
|from being parsed, |however |''it will respect formatting''|
|and parse symbols like !today (yyyyMMdd) |

!2 Hidden table heads
You can hide the first row of a table. This allows you to write comment tables that just look like ordinary HTML tables.
The complete table still gets executed, the first row is just hidden by a CSS rule.
The complete table still gets executed, the first row is just hidden by a CSS rule.
Precede the first row with a '-'. This also works for literal tables.

'''Markup Text'''
Expand Down
6 changes: 4 additions & 2 deletions src/fitnesse/ContextConfigurator.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ public FitNesseContext makeFitNesseContext() throws IOException, PluginException
variableSource,
theme);

SymbolProvider symbolProvider = SymbolProvider.wikiParsingProvider;
SymbolProvider wikiParsingProvider = SymbolProvider.wikiParsingProvider;
SymbolProvider noLinksTableParsingProvider = SymbolProvider.noLinksTableParsingProvider;

SlimTableDefaultColoring.createInstanceIfNeeded(slimTableFactory);
SlimTableDefaultColoring.install();
Expand All @@ -184,7 +185,8 @@ public FitNesseContext makeFitNesseContext() throws IOException, PluginException
}
pluginsLoader.loadTestSystems(testSystemFactory);
pluginsLoader.loadFormatters(formatterFactory);
pluginsLoader.loadSymbolTypes(symbolProvider);
pluginsLoader.loadSymbolTypes(wikiParsingProvider);
pluginsLoader.loadSymbolTypes(noLinksTableParsingProvider);
pluginsLoader.loadSlimTables(slimTableFactory);
pluginsLoader.loadCustomComparators(customComparatorRegistry);
pluginsLoader.loadTestRunFactories(context.testRunFactoryRegistry);
Expand Down
6 changes: 6 additions & 0 deletions src/fitnesse/wikitext/parser/SymbolProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ SymbolType.Italic, SymbolType.Strike, new AnchorReference(), WikiWord.symbolType
new Headings()
});

public static final SymbolProvider noLinksTableParsingProvider = SymbolProvider.copy(wikiParsingProvider)
.remove(WikiWord.symbolType)
.remove(SymbolType.EMail)
.remove(Link.symbolType)
.add(SymbolType.EndCell);

public static final SymbolProvider tableParsingProvider = new SymbolProvider(wikiParsingProvider).add(SymbolType.EndCell);

public static final SymbolProvider aliasLinkProvider = new SymbolProvider(
Expand Down
6 changes: 5 additions & 1 deletion src/fitnesse/wikitext/parser/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public Table() {
wikiMatcher(new Matcher().startLine().string("!|"));
wikiMatcher(new Matcher().startLine().string("-|"));
wikiMatcher(new Matcher().startLine().string("-!|"));
wikiMatcher(new Matcher().startLine().string("-^|"));
wikiMatcher(new Matcher().startLine().string("^|"));
wikiRule(this);
htmlTranslation(this);
}
Expand Down Expand Up @@ -57,7 +59,9 @@ public Maybe<Symbol> parse(Symbol current, Parser parser) {
protected Symbol parseCell(Parser parser, String content) {
Symbol cell = (content.contains("!"))
? parser.parseToWithSymbols(cellTerminators, SymbolProvider.literalTableProvider, ParseSpecification.tablePriority)
: parser.parseToWithSymbols(cellTerminators, SymbolProvider.tableParsingProvider, ParseSpecification.tablePriority);
: (content.contains("^"))
? parser.parseToWithSymbols(cellTerminators, SymbolProvider.noLinksTableParsingProvider, ParseSpecification.tablePriority)
: parser.parseToWithSymbols(cellTerminators, SymbolProvider.tableParsingProvider, ParseSpecification.tablePriority);
cell.setType(tableCell);
return cell;
}
Expand Down

0 comments on commit d21d53a

Please sign in to comment.