mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-22 05:50:01 +00:00
Merge branch 'master' into geospatial-plugin
This commit is contained in:
commit
5165fcdcb8
@ -211,7 +211,7 @@ TestCases/Hint: Test cases are self contained examples for testing and learning
|
||||
TestCases/All/Caption: All Test Cases
|
||||
TestCases/All/Hint: All Test Cases
|
||||
TestCases/Failed/Caption: Failed Test Cases
|
||||
TestCases/Failed/Hint: Just Failed Test Cases
|
||||
TestCases/Failed/Hint: Only Failed Test Cases
|
||||
Theme/Caption: Theme
|
||||
Theme/Prompt: Current theme:
|
||||
TiddlerFields/Caption: Tiddler Fields
|
||||
|
@ -65,9 +65,9 @@ sidebar-tab-foreground-selected: Sidebar tab foreground for selected tabs
|
||||
sidebar-tab-foreground: Sidebar tab foreground
|
||||
sidebar-tiddler-link-foreground-hover: Sidebar tiddler link foreground hover
|
||||
sidebar-tiddler-link-foreground: Sidebar tiddler link foreground
|
||||
testcase-accent-level-1: Testcase accent colour with no nesting
|
||||
testcase-accent-level-2: Testcase accent colour with 2nd level nesting
|
||||
testcase-accent-level-3: Testcase accent colour with 3rd level nesting or higher
|
||||
testcase-accent-level-1: Test case accent colour with no nesting
|
||||
testcase-accent-level-2: Test case accent colour with 2nd level nesting
|
||||
testcase-accent-level-3: Test case accent colour with 3rd level nesting or higher
|
||||
site-title-foreground: Site title foreground
|
||||
static-alert-foreground: Static alert foreground
|
||||
tab-background-selected: Tab background for selected tabs
|
||||
|
@ -3,30 +3,7 @@ title: $:/core/modules/parsers/wikiparser/rules/quoteblock.js
|
||||
type: application/javascript
|
||||
module-type: wikirule
|
||||
|
||||
Wiki text rule for quote blocks. For example:
|
||||
|
||||
```
|
||||
<<<.optionalClass(es) optional cited from
|
||||
a quote
|
||||
<<<
|
||||
|
||||
<<<.optionalClass(es)
|
||||
a quote
|
||||
<<< optional cited from
|
||||
```
|
||||
|
||||
Quotes can be quoted by putting more <s
|
||||
|
||||
```
|
||||
<<<
|
||||
Quote Level 1
|
||||
|
||||
<<<<
|
||||
QuoteLevel 2
|
||||
<<<<
|
||||
|
||||
<<<
|
||||
```
|
||||
Wiki text rule for quote blocks.
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
@ -47,16 +24,15 @@ exports.init = function(parser) {
|
||||
exports.parse = function() {
|
||||
var classes = ["tc-quote"];
|
||||
// Get all the details of the match
|
||||
var reEndString = "^" + this.match[1] + "(?!<)";
|
||||
var reEndString = "^\\s*" + this.match[1] + "(?!<)";
|
||||
// Move past the <s
|
||||
this.parser.pos = this.matchRegExp.lastIndex;
|
||||
|
||||
// Parse any classes, whitespace and then the optional cite itself
|
||||
classes.push.apply(classes, this.parser.parseClasses());
|
||||
this.parser.skipWhitespace({treatNewlinesAsNonWhitespace: true});
|
||||
var cite = this.parser.parseInlineRun(/(\r?\n)/mg);
|
||||
// before handling the cite, parse the body of the quote
|
||||
var tree= this.parser.parseBlocks(reEndString);
|
||||
var tree = this.parser.parseBlocks(reEndString);
|
||||
// If we got a cite, put it before the text
|
||||
if(cite.length > 0) {
|
||||
tree.unshift({
|
||||
|
@ -3,7 +3,7 @@ title: $:/core/modules/widgets/data.js
|
||||
type: application/javascript
|
||||
module-type: widget
|
||||
|
||||
Widget to represent a single item of data
|
||||
Widget to dynamically represent one or more tiddlers
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
@ -134,10 +134,10 @@ DataWidget.prototype.extractCompoundTiddler = function(title) {
|
||||
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
|
||||
*/
|
||||
DataWidget.prototype.refresh = function(changedTiddlers) {
|
||||
// Refresh our attributes
|
||||
var changedAttributes = this.computeAttributes();
|
||||
// Refresh our children, and indicate that we refreshed if any of our attribute values have changed
|
||||
return this.refreshChildren(changedTiddlers) || $tw.utils.count(changedAttributes) > 0;
|
||||
// It would be expensive to calculate whether the changedTiddlers impact the filter
|
||||
// identified by the $filter attribute so we just refresh ourselves unconditionally
|
||||
this.refreshSelf();
|
||||
return true;
|
||||
};
|
||||
|
||||
exports.data = DataWidget;
|
||||
|
@ -61,8 +61,6 @@ TestCaseWidget.prototype.render = function(parent,nextSibling) {
|
||||
}
|
||||
loadTiddler("$:/core");
|
||||
loadTiddler("$:/plugins/tiddlywiki/codemirror");
|
||||
// Load the test case template
|
||||
// loadTiddler(this.testcaseTemplate);
|
||||
// Load tiddlers from child data widgets
|
||||
var tiddlers = [];
|
||||
this.findChildrenDataWidgets(this.contentRoot.children,"data",function(widget) {
|
||||
@ -114,6 +112,7 @@ TestCaseWidget.prototype.render = function(parent,nextSibling) {
|
||||
this.setVariable("outputHTML",outputHTML);
|
||||
this.setVariable("expectedHTML",expectedHTML);
|
||||
this.setVariable("testResult",testResult);
|
||||
this.setVariable("currentTiddler",this.testcaseTestOutput);
|
||||
}
|
||||
// Don't display anything if testHideIfPass is "yes" and the tests have passed
|
||||
if(this.testcaseHideIfPass === "yes" && testResult === "pass") {
|
||||
|
@ -1,15 +1,23 @@
|
||||
title: $:/core/ui/testcases/DefaultTemplate
|
||||
|
||||
\whitespace trim
|
||||
\procedure linkcatcherActions()
|
||||
<%if [<navigateTo>has[title]] %>
|
||||
<$qualify title=<<state>> name="qualifiedState">
|
||||
<$action-setfield $tiddler=<<qualifiedState>> text=<<navigateTo>>/>
|
||||
</$qualify>
|
||||
<%endif%>
|
||||
\end
|
||||
|
||||
<$let
|
||||
state={{{ [<qualify "$:/state/testcase">] }}}
|
||||
>
|
||||
<div class="tc-testcase-wrapper">
|
||||
<div class="tc-testcase-header">
|
||||
<div class="tc-test-case-wrapper">
|
||||
<div class="tc-test-case-header">
|
||||
<h2>
|
||||
<$genesis $type={{{ [<linkTarget>!match[]then[$link]else[div]] }}}>
|
||||
<%if [<testResult>!match[]] %>
|
||||
<span class={{{ tc-testcase-result-icon [<testResult>!match[fail]then[tc-testcase-result-icon-pass]] [<testResult>match[fail]then[tc-testcase-result-icon-fail]] +[join[ ]] }}}>
|
||||
<span class={{{ tc-test-case-result-icon [<testResult>!match[fail]then[tc-test-case-result-icon-pass]] [<testResult>match[fail]then[tc-test-case-result-icon-fail]] +[join[ ]] }}}>
|
||||
<%if [<testResult>!match[fail]] %>
|
||||
{{$:/core/images/done-button}}
|
||||
<%else%>
|
||||
@ -21,27 +29,34 @@ title: $:/core/ui/testcases/DefaultTemplate
|
||||
</$genesis>
|
||||
</h2>
|
||||
</div>
|
||||
<%if [[Narrative]is[tiddler]] %>
|
||||
<div class="tc-test-case-narrative">
|
||||
<$transclude $tiddler="Narrative" mode="block"/>
|
||||
</div>
|
||||
<%endif%>
|
||||
<%if [<testResult>match[fail]] %>
|
||||
<div class="tc-testcase-result-fail">
|
||||
<div class="tc-testcase-result-fail-header">
|
||||
<div class="tc-test-case-result-fail">
|
||||
<div class="tc-test-case-result-fail-header">
|
||||
TEST FAILED
|
||||
</div>
|
||||
<div class="tc-testcase-result-fail-body">
|
||||
<div class="tc-test-case-result-fail-body">
|
||||
<$diff-text source=<<expectedHTML>> dest=<<outputHTML>>/>
|
||||
</div>
|
||||
</div>
|
||||
<%endif%>
|
||||
<div class="tc-testcase-panes">
|
||||
<div class="tc-testcase-source">
|
||||
<$macrocall $name="tabs" tabsList="[all[tiddlers]sort[]] -[prefix<state>] -Description -ExpectedResult -Output Output +[putfirst[]] -[has[plugin-type]]" state=<<state>> default="Output" template="$:/core/ui/testcases/DefaultTemplate/Source"/>
|
||||
<div class="tc-test-case-panes">
|
||||
<div class="tc-test-case-source">
|
||||
<$macrocall $name="tabs" tabsList="[all[tiddlers]sort[]] -[prefix<state>] -Description -Narrative -ExpectedResult -Output Output +[putfirst[]] -[has[plugin-type]]" state=<<state>> default="Output" template="$:/core/ui/testcases/DefaultTemplate/SourceTabs"/>
|
||||
</div>
|
||||
<div class="tc-testcase-divider">
|
||||
<div class="tc-test-case-divider">
|
||||
</div>
|
||||
<div class="tc-testcase-output">
|
||||
<div class="tc-test-case-output">
|
||||
<%if [<displayFormat>!match[]else[wikitext]match[plaintext]] %>
|
||||
<pre><$view tiddler="Output" format="plainwikified" mode="block"/></pre>
|
||||
<%else%>
|
||||
<$transclude $tiddler="Output" $mode="block"/>
|
||||
<$linkcatcher actions=<<linkcatcherActions>>>
|
||||
<$transclude $tiddler="Output" $mode="block"/>
|
||||
</$linkcatcher>
|
||||
<%endif%>
|
||||
</div>
|
||||
</div>
|
||||
|
24
core/ui/TestCases/DefaultTemplateSourceTabs.tid
Normal file
24
core/ui/TestCases/DefaultTemplateSourceTabs.tid
Normal file
@ -0,0 +1,24 @@
|
||||
title: $:/core/ui/testcases/DefaultTemplate/SourceTabs
|
||||
|
||||
\whitespace trim
|
||||
\procedure body()
|
||||
<$list filter="[<currentTab>fields[]] -text +[limit[1]]" variable="ignore">
|
||||
<table class="tc-field-table">
|
||||
<tbody>
|
||||
<$list filter="[<currentTab>fields[]sort[]] -text -title title +[putfirst[]]" variable="fieldName">
|
||||
<tr>
|
||||
<td>
|
||||
<$text text=<<fieldName>>/>
|
||||
</td>
|
||||
<td>
|
||||
<$view tiddler=<<currentTab>> field=<<fieldName>>/>
|
||||
</td>
|
||||
</tr>
|
||||
</$list>
|
||||
</tbody>
|
||||
</table>
|
||||
</$list>
|
||||
<$edit class="tc-edit-texteditor" tiddler=<<currentTab>>/>
|
||||
\end
|
||||
|
||||
<$transclude $variable="body" $mode="inline"/>
|
@ -1,7 +1,7 @@
|
||||
title: $:/config/ViewTemplateBodyFilters/
|
||||
tags: $:/tags/ViewTemplateBodyFilter
|
||||
|
||||
testcase: [tag[$:/tags/wiki-test-spec]type[text/vnd.tiddlywiki-multiple]then[$:/core/ui/TestCaseTemplate]]
|
||||
testcase: [tag[$:/tags/wiki-test-spec]type[text/vnd.tiddlywiki-multiple]then[$:/core/ui/TestCaseTemplate]] [tag[$:/tags/wiki-test-spec-failing]type[text/vnd.tiddlywiki-multiple]then[$:/core/ui/TestCaseTemplate]]
|
||||
stylesheet: [tag[$:/tags/Stylesheet]then[$:/core/ui/ViewTemplate/body/rendered-plain-text]]
|
||||
core-ui-tags: [tag[$:/tags/PageTemplate]] [tag[$:/tags/EditTemplate]] [tag[$:/tags/ViewTemplate]] [tag[$:/tags/KeyboardShortcut]] [tag[$:/tags/ImportPreview]] [tag[$:/tags/EditPreview]][tag[$:/tags/EditorToolbar]] [tag[$:/tags/Actions]] :then[[$:/core/ui/ViewTemplate/body/code]]
|
||||
system: [prefix[$:/boot/]] [prefix[$:/config/]] [prefix[$:/core/macros]] [prefix[$:/core/save/]] [prefix[$:/core/templates/]] [prefix[$:/info/]] [prefix[$:/language/]] [prefix[$:/languages/]] [prefix[$:/snippets/]] [prefix[$:/state/]] [prefix[$:/status/]] [prefix[$:/info/]] [prefix[$:/temp/]] +[!is[image]limit[1]then[$:/core/ui/ViewTemplate/body/code]]
|
||||
|
31
editions/tw5.com/tiddlers/concepts/CompoundTiddlers.tid
Normal file
31
editions/tw5.com/tiddlers/concepts/CompoundTiddlers.tid
Normal file
@ -0,0 +1,31 @@
|
||||
title: CompoundTiddlers
|
||||
modified: 20240507221902644
|
||||
created: 20240507221902644
|
||||
tags: Concepts
|
||||
|
||||
Compound tiddlers are a special type of tiddler that can store one or more payload tiddlers. The tiddlers within a compound tiddler are only accessible via special operations, typically with the TestCaseWidget.
|
||||
|
||||
The compound tiddler format is extremely simple, and includes the notable flaw that it does not permit tiddlers that contain a plus sign (`+`) on a line by itself. It is not intended as a general purpose way of storing tiddler data.
|
||||
|
||||
Compound tiddlers are identified by having their type field set to `text/vnd.tiddlywiki-multiple`.
|
||||
|
||||
The content of a compound tiddler consists of a sequence of tiddlers separated by a plus sign (`+`) on a line by itself. Each tiddler uses the same format as [[.tid files|TiddlerFiles]].
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
title: First
|
||||
tags: one two
|
||||
|
||||
This is the first tiddler
|
||||
+
|
||||
title: Second
|
||||
tags: three four
|
||||
|
||||
This is the second tiddler
|
||||
+
|
||||
title: third
|
||||
tags: five six
|
||||
|
||||
This is the third tiddler
|
||||
```
|
@ -1,13 +1,27 @@
|
||||
title: TestCaseTiddlers
|
||||
modified: 20240507221902644
|
||||
created: 20240507221902644
|
||||
tags: Concepts
|
||||
|
||||
Test case tiddlers encapsulate one or more tiddlers that can be displayed as a [[test case|TestCaseWidget]]: an independent embedded wiki that can be used for testing or learning purposes.
|
||||
|
||||
Test case tiddlers are formatted as CompoundTiddlers, allowing them to contain multiple tiddlers packed into one.
|
||||
|
||||
Test case tiddlers have the following fields:
|
||||
|
||||
|!Field |!Description |
|
||||
|<<.field type>> | Should be set to `text/vnd.tiddlywiki-multiple` |
|
||||
|<<.field tags>> | Test cases are tagged [[$:/tags/wiki-test-spec]]. Test cases that intentionally fail are tagged [[$:/tags/wiki-test-spec-failing]] |
|
||||
|<<.field description>> |Descriptive heading for the test, intended to make it easy to identify the test |
|
||||
|<<.field display-format>> |Optional, defaults to `wikitext`. Set to `plaintext` to cause the output to be rended as plain text |
|
||||
|
||||
Test case tiddlers with the appropriate tag are shown in $:/ControlPanel
|
||||
|
||||
Some payload tiddlers are set aside for special purposes:
|
||||
|
||||
|!Tiddler |!Description |
|
||||
|''Narrative'' |Narrative description of the test, intended to explain the purpose and operation of the test |
|
||||
|''Output'' |The tiddler that produces the test output |
|
||||
|''~ExpectedResult'' |HTML of expected result of rendering the ''Output'' tiddler |
|
||||
|
||||
|
||||
|
||||
Behind the scenes, the templates used to view TestCaseTiddlers use the <<.wlink TestCaseWidget>> widget.
|
||||
|
||||
! Testcase Conventions
|
||||
|
||||
The following conventions are used for testcase tiddlers:
|
||||
|
||||
* `Description` contains a brief description of the test (rendered in inline mode)
|
||||
* `Output` contains the tiddler text to be rendered. It can also reference other tiddlers
|
||||
* `ExpectedResult` contains the HTML that should match the rendering of the tiddler `Output`
|
||||
|
@ -4,7 +4,7 @@ tags: [[Filter Expression]]
|
||||
title: Filter Run Prefix
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
There are 2 types of filter run prefixes that are interchangeable. Named prefixes and shortcut prefixes.
|
||||
There are 2 types of filter run prefixes that are interchangeable; [[named prefixes|Named Filter Run Prefix]] and [[shortcut prefixes|Shortcut Filter Run Prefix]].
|
||||
|
||||
<$railroad text="""
|
||||
\start none
|
||||
|
@ -15,8 +15,6 @@ A demo of the geospatial functionality is [ext[available here|./plugins/tiddlywi
|
||||
|
||||
It also includes a number of new features that are intended for eventual inclusion in the core:
|
||||
|
||||
* TestCaseWidget
|
||||
* Enhancements to the existing DataWidget
|
||||
* [[jsonset Operator]]
|
||||
|
||||
</div>
|
||||
|
@ -4,6 +4,10 @@ tags: [[$:/tags/wiki-test-spec]]
|
||||
description: Importing a compound payload tiddler and adding custom fields
|
||||
display-format: plaintext
|
||||
|
||||
title: Narrative
|
||||
|
||||
Using the data widget to import a tiddler stored in a compound tiddler
|
||||
+
|
||||
title: Output
|
||||
|
||||
<$data $compound-tiddler="Compound" custom="Alpha"/>
|
||||
|
@ -4,6 +4,10 @@ tags: [[$:/tags/wiki-test-spec]]
|
||||
description: Imported filter definition
|
||||
display-format: plaintext
|
||||
|
||||
title: Narrative
|
||||
|
||||
Using the data widget to create copies of all the tiddlers with the title prefix "Day: T", adding the field "custom" set to "Beta"
|
||||
+
|
||||
title: Output
|
||||
|
||||
<$data $filter="[prefix[Day: T]]" custom="Beta"/>
|
||||
|
@ -4,22 +4,26 @@ tags: [[$:/tags/wiki-test-spec]]
|
||||
description: Imported tiddler definition
|
||||
display-format: plaintext
|
||||
|
||||
title: Narrative
|
||||
|
||||
Using the data widget to create a tiddler that is a copy of the tiddler "Hello" with the addition of the field "custom" set to "Alpha"
|
||||
+
|
||||
title: Output
|
||||
|
||||
<$data $tiddler="HelloThere" custom="Alpha"/>
|
||||
<$data $tiddler="Hello" custom="Alpha"/>
|
||||
+
|
||||
title: HelloThere
|
||||
title: Hello
|
||||
modifier: JoeBloggs
|
||||
|
||||
This is the HelloThere tiddler
|
||||
This is the Hello tiddler
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>[
|
||||
{
|
||||
"title": "HelloThere",
|
||||
"title": "Hello",
|
||||
"modifier": "JoeBloggs",
|
||||
"text": "This is the HelloThere tiddler",
|
||||
"text": "This is the Hello tiddler",
|
||||
"custom": "Alpha"
|
||||
}
|
||||
]</p>
|
@ -0,0 +1,30 @@
|
||||
title: TestCases/DataWidget/Refreshing
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
description: Refreshing the data widget
|
||||
display-format: plaintext
|
||||
|
||||
title: Narrative
|
||||
|
||||
Verifying that the JSON output of the data widget is correctly refreshed when the data changes
|
||||
+
|
||||
title: Output
|
||||
|
||||
<$data title="Epsilon" text={{Subject}}/>
|
||||
+
|
||||
title: Subject
|
||||
|
||||
Nothing
|
||||
+
|
||||
title: Actions
|
||||
|
||||
<$action-setfield $tiddler="Subject" text="Theta"/>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>[
|
||||
{
|
||||
"title": "Epsilon",
|
||||
"text": "Theta"
|
||||
}
|
||||
]</p>
|
@ -4,6 +4,10 @@ tags: [[$:/tags/wiki-test-spec]]
|
||||
description: Simple tiddler definition
|
||||
display-format: plaintext
|
||||
|
||||
title: Narrative
|
||||
|
||||
Using the data widget to create a tiddler with the title "Epsilon" and the text "Theta"
|
||||
+
|
||||
title: Output
|
||||
|
||||
<$data title="Epsilon" text="Theta"/>
|
||||
|
@ -3,6 +3,10 @@ type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec-failing]]
|
||||
description: An example of a failing test
|
||||
|
||||
title: Narrative
|
||||
|
||||
This test case intentionally fails to show how failures are displayed.
|
||||
+
|
||||
title: Output
|
||||
|
||||
The sum is <$text text={{{ [[2]add[2]] }}}/>.
|
||||
|
@ -0,0 +1,16 @@
|
||||
description: currentTiddler should be properly set
|
||||
tags: $:/tags/wiki-test-spec
|
||||
title: TestCases/TestCaseTiddler/currentTiddler
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
|
||||
title: Narrative
|
||||
|
||||
currentTiddler variable in Output tiddler should be "Output"
|
||||
+
|
||||
title: Output
|
||||
|
||||
<$text text=<<currentTiddler>>>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>Output</p>
|
@ -1,6 +1,6 @@
|
||||
caption: data
|
||||
created: 20230406161341763
|
||||
modified: 20230406161341763
|
||||
created: 20240507221902644
|
||||
modified: 20240507221902644
|
||||
tags: Widgets
|
||||
title: DataWidget
|
||||
type: text/vnd.tiddlywiki
|
||||
@ -21,41 +21,22 @@ The content of the data widget is ignored. It supports the following attributes:
|
||||
|
||||
The data widget is not rendered when used within the <<.wlink TestCaseWidget>> widget or the [[Innerwiki Plugin]] but for ease of testing, when used elsewhere it renders a JSON representation of the payload tiddlers.
|
||||
|
||||
Without any of the attributes <<.attr $tiddler>>, <<.attr $filter>> or <<.attr $compound-tiddler>>, any attributes whose name does not start with $ are used as the field values for creating a single new tiddler. For example, here a tiddler with the title "Epsilon" and the text "Theta" is created:
|
||||
Without any of the attributes <<.attr $tiddler>>, <<.attr $filter>> or <<.attr $compound-tiddler>>, any attributes whose name does not start with $ are used as the field values for creating a single new tiddler.
|
||||
|
||||
<<testcase "TestCases/DataWidget/SimpleTiddler">>
|
||||
|
||||
If any of the attributes <<.attr $tiddler>>, <<.attr $filter>> or <<.attr $compound-tiddler>> are specified then they are used to generate base tiddlers that are then modified with the addition of fields derived from any attributes whose name does not start with $.
|
||||
|
||||
This example, here we specify a copy of the "HelloThere" tiddler with the addition of the field "custom" set to "Alpha":
|
||||
The attribute <<.attr $tiddler>> is used to ingest a single tiddler from the wiki containing the data widget:
|
||||
|
||||
<<testcase "TestCases/DataWidget/ImportedTiddler">>
|
||||
|
||||
This example injects all image tiddlers with the addition of the field "custom" set to "Beta":
|
||||
The attribute <<.attr $filter>> is used to ingest multiple tiddlers from the wiki containing the data widget:
|
||||
|
||||
<<testcase "TestCases/DataWidget/ImportedFilter">>
|
||||
|
||||
! Compound Tiddlers
|
||||
|
||||
Compound tiddlers provide a way to easily create multiple tiddlers from within a single tiddler. They are contained in tiddlers of type `text/vnd.tiddlywiki-multiple`. The text field consists of a series of tiddlers in the same format as `.tid` files, each separated by a line containing a single `+` character.
|
||||
[[Compound tiddlers|CompoundTiddlers]] provide a way to easily create multiple tiddlers from within a single tiddler. They are contained in tiddlers of type `text/vnd.tiddlywiki-multiple`. The text field consists of a series of tiddlers in the same format as `.tid` files, each separated by a line containing a single `+` character.
|
||||
|
||||
<<testcase "TestCases/DataWidget/ImportCompound">>
|
||||
|
||||
Here is a more complex example of the content of a compound tiddler:
|
||||
|
||||
```
|
||||
title: First
|
||||
tags: one two
|
||||
|
||||
This is the first tiddler
|
||||
+
|
||||
title: Second
|
||||
tags: three four
|
||||
|
||||
This is the second tiddler
|
||||
+
|
||||
title: third
|
||||
tags: five six
|
||||
|
||||
This is the third tiddler
|
||||
```
|
||||
|
@ -1,6 +1,6 @@
|
||||
caption: testcase
|
||||
created: 20230406161341763
|
||||
modified: 20230406161341763
|
||||
created: 20240507221902644
|
||||
modified: 20240507221902644
|
||||
tags: Widgets
|
||||
title: TestCaseWidget
|
||||
type: text/vnd.tiddlywiki
|
||||
@ -11,26 +11,24 @@ The <<.wid testcase>> widget is designed to present interactive example test cas
|
||||
|
||||
This makes it possible to run independent tests that also serve as documentation examples.
|
||||
|
||||
The <<.wid testcase>> widget can be used directly as documented below, but it is generally easier to create [[TestCaseTiddlers]]. These are special CompoundTiddlers that can contain multiple payload tiddlers making up a test case.
|
||||
|
||||
!! Features
|
||||
|
||||
Here is an example of a testcase showing the default split view with the source tiddlers on the left and the tiddler titled `Output` rendered on the right. It also displays the tiddler titled `Description` as the heading.
|
||||
Here is an example of a test case showing the default split view with the source tiddlers on the left and the tiddler titled `Output` rendered on the right.
|
||||
|
||||
<<testcase "TestCases/TranscludeWidget/SimpleTransclusion">>
|
||||
|
||||
The payload tiddlers listed in the tabs on the left are editable, with the results being immediately reflected in the preview pane on the right. However, if the <<.wid testcase>> widget is refreshed then the modifications are lost.
|
||||
Notice also that clicking on links within the output pane will switch to the tab containing that tiddler.
|
||||
|
||||
The green tick at the top left of a testcase indicates that a test has been set up and that it passes.
|
||||
The text of the payload tiddlers listed on the left are editable, with the results being immediately reflected in the preview pane on the right. However, if the <<.wid testcase>> widget is refreshed then the modifications are lost.
|
||||
|
||||
The green tick at the top left of a test case indicates that a test has been set up and that it passes.
|
||||
|
||||
If the test fails, a red cross is shown, and there is a display of the differences between the actual results and the expected results:
|
||||
|
||||
<<testcase "TestCases/TestCaseWidget/FailingTest">>
|
||||
|
||||
!! Usage
|
||||
|
||||
The <<.wid testcase>> widget can be used directly as documented below, but it is generally easier and more flexible to create [[TestCaseTiddlers]]. These are special, self contained tiddlers that can contain multiple payload tiddlers making up a testcase.
|
||||
|
||||
Note that the testcase wiki will inherit variables that are visible to the <<.wid testcase>> widget itself.
|
||||
|
||||
! Limitations
|
||||
|
||||
The <<.wid testcase>> widget creates a lightweight TiddlyWiki environment that is a parasite of the main wiki. Because it is not a full, independent TiddlyWiki environment, there are some important limitations:
|
||||
@ -38,16 +36,16 @@ The <<.wid testcase>> widget creates a lightweight TiddlyWiki environment that i
|
||||
* Output is rendered into a DIV, and so cannot be styled independently of the host wiki
|
||||
* Any changes to the wiki made interactively by the user are volatile, and are lost when the <<.wid testcase>> widget is refreshed
|
||||
* Startup actions are not supported
|
||||
* Only plugins available in the host wiki can be included in the testcase
|
||||
* Only plugins available in the host wiki can be included in the test case
|
||||
|
||||
If these limitations are a problem, the [[Innerwiki Plugin]] offers the ability to embed a fully independent subwiki via an `<iframe>` element, but without the testing related features of the <<.wid testcase>> widget.
|
||||
|
||||
! Content and Attributes
|
||||
|
||||
The content of the `<$testcase>` widget is not displayed but instead is scanned for <<.wlink DataWidget>> widgets that define the payload tiddlers to be included in the testcase.
|
||||
The content of the `<$testcase>` widget is not displayed but instead is scanned for <<.wlink DataWidget>> widgets that define the payload tiddlers to be included in the test case.
|
||||
|
||||
|!Attribute |!Description |
|
||||
|<<.attr template>> |Optional title of the template used to display the testcase (defaults to $:/core/ui/testcases/DefaultTemplate). Note that custom templates will need to be explicitly added to the payload |
|
||||
|<<.attr template>> |Optional title of the template used to display the test case (defaults to $:/core/ui/testcases/DefaultTemplate). Note that custom templates will need to be explicitly added to the payload |
|
||||
|<<.attr testOutput>> |Optional title of the tiddler whose output should be subject to testing (note that both <<.attr testOutput>> and <<.attr testExpectedResult>> must be provided in order for testing to occur) |
|
||||
|<<.attr testExpectedResult>> |Optional title of the tiddler whose content is the expected result of rendering the output tiddler (note that both <<.attr testOutput>> and <<.attr testExpectedResult>> must be provided in order for testing to occur) |
|
||||
|<<.attr testActions>> |Optional title of the tiddler containing actions that should be executed before the test occurs |
|
||||
@ -61,35 +59,43 @@ The payload tiddlers are the tiddler values that are loaded into the subwiki tha
|
||||
|
||||
The <<.attr template>> attribute defaults to $:/core/ui/testcases/DefaultTemplate
|
||||
|
||||
The default template uses several variables that can be set by the user:
|
||||
The default test case template assigns special meanings to a number of payload tiddlers:
|
||||
|
||||
|!Tiddler |!Description |
|
||||
|''Description'' |Descriptive heading for the test, intended to make it easy to identify the test |
|
||||
|''Narrative'' |Narrative description of the test, intended to explain the purpose and operation of the test |
|
||||
|''Output'' |The tiddler that produces the test output |
|
||||
|''~ExpectedResult'' |HTML of expected result of rendering the ''Output'' tiddler |
|
||||
|
||||
The test case wiki will inherit variables that are visible to the <<.wid testcase>> widget itself. The default template uses several variables that can be set by the user:
|
||||
|
||||
|!Variable |!Description |
|
||||
|<<.var linkTarget>> |Causes the testcase description to be rendered as a link to the current tiddler |
|
||||
|<<.var linkTarget>> |Causes the test case description to be rendered as a link to the current tiddler |
|
||||
|<<.var displayFormat>> |Defaults to "wikitext", can also be "plaintext" to force plain text display |
|
||||
|
||||
A custom template can be specified for special purposes. For example, the provided template $:/core/ui/testcases/RawJSONTemplate just displays the payload tiddlers in JSON, which can be used for debugging purposes.
|
||||
|
||||
! Testcase Template Variables
|
||||
! Test Czase Template Variables
|
||||
|
||||
The <<.wid testcase>> widget makes the following variables available within the rendered template:
|
||||
|
||||
|!Variable |!Description |
|
||||
|<<.var transclusion>> |A hash that reflects the names and values of all the payload tiddlers. This makes it easier for testcase templates to create unique state tiddler titles using the [[qualify Macro]] or QualifyWidget |
|
||||
|<<.var transclusion>> |A hash that reflects the names and values of all the payload tiddlers. This makes it easier for test case templates to create unique state tiddler titles using the [[qualify Macro]] or QualifyWidget |
|
||||
|<<.var payloadTiddlers>> |JSON array of payload tiddler fields |
|
||||
|<<.var outputHTML>> |The actual output HTML if running tests |
|
||||
|<<.var expectedHTML>> |The expected output HTML if running tests |
|
||||
|<<.var testResult>> |The tests result if running tests (may be "pass" or "fail") |
|
||||
|
||||
! Examples
|
||||
! Example
|
||||
|
||||
Here is an example of setting up a testcase that includes expected test results:
|
||||
Here is an example of setting up a test case that includes expected test results:
|
||||
|
||||
<$testcase>
|
||||
<$data title="Description" text="Example of a testcase with expected results"/>
|
||||
<$data title="Description" text="Example of a test case with expected results"/>
|
||||
<$data title="Output" text="""<$testcase testOutput="Output" testExpectedResult="ExpectedResult">
|
||||
<$data title="Description" text="How to calculate 2 plus 2"/>
|
||||
<$data title="Output" text="<$text text={{{ [[2]add[2]] }}}/>"/>
|
||||
<$data title="ExpectedResult" text="<p>8</p>"/>
|
||||
<$data title="Description" text="How to calculate 2 plus 2"/>
|
||||
<$data title="Output" text="<$text text={{{ [[2]add[2]] }}}/>"/>
|
||||
<$data title="ExpectedResult" text="<p>8</p>"/>
|
||||
</$testcase>
|
||||
"""/>
|
||||
</$testcase>
|
||||
|
@ -1,6 +1,6 @@
|
||||
caption: Block Quotes
|
||||
created: 20131206154636572
|
||||
modified: 20170417165145317
|
||||
modified: 20240512000910702
|
||||
tags: WikiText
|
||||
title: Block Quotes in WikiText
|
||||
type: text/vnd.tiddlywiki
|
||||
@ -72,3 +72,34 @@ You can also mix block quotes with other list items. For example:
|
||||
**> Another quote
|
||||
* List Three
|
||||
">>
|
||||
|
||||
! Advanced Wikitext and Block Quotes
|
||||
You can also mix block quotes with paragraphs and other block wikitext. Be mindful of block mode - if other quoted content follows a paragraph, end it with a blank line. The final paragraph in the quote does not need to end with a blank line. If using indentation, make sure __not to indent the blank lines__. The parser will interpret this as additional inline content and not return to block mode. For example:
|
||||
|
||||
<<wikitext-example src:'<<< Mixing Block Quotes with Inline Wikitext
|
||||
A paragraph appears before other //wikitext//, which needs to end with a blank line.
|
||||
|
||||
* List One
|
||||
** List Two
|
||||
**> A quote
|
||||
"""
|
||||
A poem
|
||||
with line beaks
|
||||
needs to have
|
||||
a blank line after
|
||||
the final quotes
|
||||
if followed
|
||||
by other content
|
||||
"""
|
||||
|
||||
<<<< Deep Block Quote
|
||||
A paragraph before other //wikitext//, which ends with a blank line.
|
||||
|
||||
! A Header
|
||||
Another paragraph, which needs to end with a blank line.
|
||||
|
||||
!! Sub Header
|
||||
A final paragraph, which __does not__ need to end with a blank line as the Block Quote ends.
|
||||
<<<<
|
||||
<<<
|
||||
'>>
|
@ -1,9 +1,9 @@
|
||||
caption: Hard Linebreaks
|
||||
created: 20131214165710101
|
||||
modified: 20131214170106553
|
||||
modified: 20240512001649319
|
||||
tags: WikiText
|
||||
title: Hard Linebreaks in WikiText
|
||||
type: text/vnd.tiddlywiki
|
||||
caption: Hard Linebreaks
|
||||
|
||||
The usual handling of [[paragraphs in wikitext|Paragraphs in WikiText]] causes single line breaks to be ignored, and double linebreaks to be interpreted as the end of a paragraph.
|
||||
|
||||
@ -15,4 +15,8 @@ and this is a new line
|
||||
while this is yet another line
|
||||
and this is the final one
|
||||
apart from this one
|
||||
"""'>>
|
||||
"""
|
||||
|
||||
'>>
|
||||
|
||||
<<.tip 'Note: <strong>Hard Linebreaks in ~WikiText</strong> require an extra blank line after the trailing `"""` before the parser will return to [[block mode|Block Mode WikiText]].'>>.
|
@ -1,6 +1,6 @@
|
||||
caption: block parser mode
|
||||
created: 20220110234234616
|
||||
modified: 20220122182842032
|
||||
modified: 20240512001555383
|
||||
tags: [[WikiText Parser Modes]]
|
||||
title: Block Mode WikiText
|
||||
type: text/vnd.tiddlywiki
|
||||
@ -28,7 +28,7 @@ Common characteristics of such block mode WikiText:
|
||||
The above WikiText types are only recognised in ''block mode''. However, the text <<.em enclosed>> by most of them will be parsed in ''inline mode'' ([[Block Quotes in WikiText]] and [[Styles and Classes in WikiText]] are the two exceptions in which the parser will continue in ''block mode''). While in ''inline mode'' the parser may encounter something which moves it to ''block mode'' (see [[WikiText parser mode transitions]]).
|
||||
|
||||
At the end of the terminating line, the parser will return to ''block mode''.
|
||||
<<.tip 'Note: [[Hard Linebreaks in WikiText]] require an extra blank line after the trailing `"""` before the parser will return to <b>block mode</b>'>>.
|
||||
<<.tip 'Note: [[Hard Linebreaks in WikiText]] require an extra blank line after the trailing `"""` before the parser will return to <strong>block mode</strong>.'>>
|
||||
|
||||
If the punctuation for the above types of WikiText is encountered while the parser is in ''inline mode'', it will be //ignored// and output as-is.
|
||||
|
||||
|
@ -3226,35 +3226,40 @@ span.tc-translink > a:first-child {
|
||||
** Test Cases
|
||||
*/
|
||||
|
||||
.tc-testcase-wrapper {
|
||||
.tc-test-case-wrapper {
|
||||
border: 1px solid <<colour foreground>>;
|
||||
background-color: <<colour muted-foreground>>;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.tc-testcase-wrapper {
|
||||
.tc-tiddler-frame .tc-test-case-wrapper {
|
||||
margin-left: -0.5em;
|
||||
margin-right: -0.5em;
|
||||
}
|
||||
|
||||
.tc-test-case-wrapper {
|
||||
background-color: <<colour testcase-accent-level-1>>;
|
||||
}
|
||||
|
||||
.tc-testcase-wrapper .tc-testcase-wrapper {
|
||||
.tc-test-case-wrapper .tc-test-case-wrapper {
|
||||
background-color: <<colour testcase-accent-level-2>>;
|
||||
}
|
||||
|
||||
.tc-testcase-wrapper .tc-testcase-wrapper .tc-testcase-wrapper {
|
||||
.tc-test-case-wrapper .tc-test-case-wrapper .tc-test-case-wrapper {
|
||||
background-color: <<colour testcase-accent-level-3>>;
|
||||
}
|
||||
|
||||
.tc-testcase-header {
|
||||
.tc-test-case-header {
|
||||
font-weight: normal;
|
||||
margin: 0.5em 0;
|
||||
padding: 0 0.5em;
|
||||
}
|
||||
|
||||
.tc-testcase-divider {
|
||||
.tc-test-case-divider {
|
||||
x-background-color: <<colour muted-foreground>>;
|
||||
}
|
||||
|
||||
.tc-testcase-result-icon {
|
||||
.tc-test-case-result-icon {
|
||||
fill: #fff;
|
||||
padding: 0.25em;
|
||||
display: inline-block;
|
||||
@ -3264,29 +3269,29 @@ span.tc-translink > a:first-child {
|
||||
margin-right: 0.25em;
|
||||
}
|
||||
|
||||
.tc-testcase-result-icon-pass {
|
||||
.tc-test-case-result-icon-pass {
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
.tc-testcase-result-icon-fail {
|
||||
.tc-test-case-result-icon-fail {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
.tc-testcase-result-icon svg {
|
||||
.tc-test-case-result-icon svg {
|
||||
width: 0.5em;
|
||||
height: 0.5em;
|
||||
}
|
||||
|
||||
.tc-testcase-header > h2,
|
||||
.tc-testcase-source > pre {
|
||||
.tc-test-case-header > h2,
|
||||
.tc-test-case-source > pre {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.tc-testcase-header > h2 a.tc-tiddlylink-missing {
|
||||
.tc-test-case-header > h2 a.tc-tiddlylink-missing {
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.tc-testcase-result-fail {
|
||||
.tc-test-case-result-fail {
|
||||
border: 1px solid <<colour foreground>>;
|
||||
background-color: <<colour background>>;
|
||||
border-radius: 4px;
|
||||
@ -3294,21 +3299,27 @@ span.tc-translink > a:first-child {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.tc-testcase-result-fail-header {
|
||||
background: <<colour foreground>>;
|
||||
color: <<colour background>>;
|
||||
.tc-test-case-result-fail-header {
|
||||
background: <<colour diff-delete-background>>;
|
||||
color: <<colour diff-delete-foreground>>;
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.tc-testcase-result-fail-body {
|
||||
.tc-test-case-result-fail-body {
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.tc-testcase-source > pre {
|
||||
.tc-test-case-source > pre {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.tc-testcase-panes {
|
||||
.tc-test-case-narrative {
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
.tc-test-case-panes {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
flex-wrap: wrap;
|
||||
@ -3317,21 +3328,21 @@ span.tc-translink > a:first-child {
|
||||
border-bottom-right-radius: 6px;
|
||||
}
|
||||
|
||||
.tc-testcase-source {
|
||||
.tc-test-case-source {
|
||||
flex: 1 0 49%;
|
||||
min-width: 250px;
|
||||
}
|
||||
|
||||
.tc-testcase-source .tc-tab-content {
|
||||
.tc-test-case-source .tc-tab-content {
|
||||
background: <<colour background>>;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.tc-testcase-source .tc-field-table {
|
||||
.tc-test-case-source .tc-field-table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tc-testcase-source table.tc-field-table {
|
||||
.tc-test-case-source table.tc-field-table {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@ -3339,22 +3350,22 @@ span.tc-translink > a:first-child {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.tc-testcase-divider {
|
||||
.tc-test-case-divider {
|
||||
flex: 0 0 1.5%;
|
||||
}
|
||||
|
||||
.tc-testcase-source .tc-tab-buttons {
|
||||
.tc-test-case-source .tc-tab-buttons {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.tc-testcase-output {
|
||||
.tc-test-case-output {
|
||||
box-shadow: inset 2px 2px 10px 0px <<colour muted-foreground>>;
|
||||
background: <<colour background>>;
|
||||
border-radius: 4px;
|
||||
border: 1px solid <<colour foreground>>;
|
||||
flex: 1 0 49%;
|
||||
min-width: 250px;
|
||||
padding: 0.25em;
|
||||
padding: 0.25em 1em;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user