mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-09-21 00:48:49 +00:00
Merge branch 'master' into this-tiddler-reference
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
title: CustomOperators/NestedParameterised
|
||||
description: Nested parameterised custom operator usage
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\function .dividebysomething(first:ignored,factor:0.5)
|
||||
[divide[2]multiply<factor>]
|
||||
\end
|
||||
|
||||
\function .multiplebysomething(first:ignored,factor:2)
|
||||
[multiply[2].dividebysomething[],<factor>]
|
||||
\end
|
||||
|
||||
<$text text={{{ [[123].multiplebysomething[]] }}}/>
|
||||
-
|
||||
<$text text={{{ [[123].multiplebysomething[x],[4]] }}}/>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>246-492</p>
|
||||
@@ -0,0 +1,24 @@
|
||||
title: CustomOperators/Parameterised
|
||||
description: Parameterised custom operator usage
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\function .multiplybysomething(first:ignored,factor:2)
|
||||
[multiply[2]multiply<factor>]
|
||||
\end
|
||||
|
||||
<$text text={{{ [[123].multiplybysomething[]] }}}/>
|
||||
-
|
||||
<$text text={{{ [[123].multiplybysomething[x],[4]] }}}/>
|
||||
|
|
||||
<$text text={{{ [[123]function[.multiplybysomething]] }}}/>
|
||||
-
|
||||
<$text text={{{ [[123]function[.multiplybysomething],[x],[4]] }}}/>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>492-984|492-984</p>
|
||||
@@ -0,0 +1,21 @@
|
||||
title: CustomOperators/Simple
|
||||
description: Simple custom operator usage
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
|
||||
\function .multiplybytwo()
|
||||
[multiply[2]]
|
||||
\end
|
||||
|
||||
<$text text={{{ [[123].multiplybytwo[]] }}}/>
|
||||
|
|
||||
<$text text={{{ [[123]function[.multiplybytwo]] }}}/>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>246|246</p>
|
||||
@@ -0,0 +1,28 @@
|
||||
title: Filters/DiffMergePatch1
|
||||
description: Tests for diff-merge-patch derived operators
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\define text1()
|
||||
the cat sat on the mat
|
||||
\end
|
||||
|
||||
\define text2()
|
||||
the hat saw in every category
|
||||
\end
|
||||
|
||||
<$text text={{{ [<text1>makepatches<text2>] }}}/>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>@@ -1,22 +1,29 @@
|
||||
the
|
||||
-c
|
||||
+h
|
||||
at sa
|
||||
-t on the mat
|
||||
+w in every category
|
||||
</p>
|
||||
@@ -0,0 +1,25 @@
|
||||
title: Filters/DiffMergePatch2
|
||||
description: Tests for diff-merge-patch derived operators
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\define text1()
|
||||
the cat sat on the mat
|
||||
\end
|
||||
|
||||
\define text2()
|
||||
the hat saw in every category
|
||||
\end
|
||||
|
||||
<$let patches={{{ [<text1>makepatches<text2>] }}}>
|
||||
|
||||
<$text text={{{ [<text1>applypatches<patches>] }}}/>
|
||||
|
||||
</$let>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
the hat saw in every category
|
||||
@@ -0,0 +1,22 @@
|
||||
title: Filters/DiffMergePatch3
|
||||
description: Tests for diff-merge-patch derived operators
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\define text1()
|
||||
the cat sat on the mat
|
||||
\end
|
||||
|
||||
\define patches()
|
||||
**NOT A VALID PATCH**
|
||||
\end
|
||||
|
||||
<$text text={{{ [<text1>applypatches<patches>] }}}/>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
the cat sat on the mat
|
||||
@@ -0,0 +1,24 @@
|
||||
title: Functions/FunctionAttributes
|
||||
description: Attributes specified as function invocations
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\function .dividebysomething(factor:0.5)
|
||||
[divide<factor>]
|
||||
\end
|
||||
|
||||
\function multiplebysomething(first:ignored,factor:2)
|
||||
[<factor>multiply[2].dividebysomething[0.25]]
|
||||
\end
|
||||
|
||||
<$text text=<<multiplebysomething>>/>
|
||||
|
|
||||
<$text text=<<multiplebysomething "nothing" "4">>/>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>16|32</p>
|
||||
@@ -0,0 +1,24 @@
|
||||
title: Functions/FunctionOperator
|
||||
description: Calling a function via the function operator
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\function .dividebysomething(factor:0.5)
|
||||
[divide<factor>]
|
||||
\end
|
||||
|
||||
\function multiplebysomething(first:ignored,factor:2)
|
||||
[multiply<factor>multiply[2].dividebysomething[0.25]]
|
||||
\end
|
||||
|
||||
<$text text={{{ [[4]function[multiplebysomething]] }}}/>
|
||||
|
|
||||
<$text text={{{ [[6]function[multiplebysomething],[ignored],[4]] }}}/>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>64|192</p>
|
||||
@@ -0,0 +1,15 @@
|
||||
title: Functions/MissingFunction
|
||||
description: Calling a missing function via the function operator
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
|
||||
<$text text={{{ [[23]function[missing]] }}}/>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
23
|
||||
@@ -0,0 +1,18 @@
|
||||
title: Functions/RunawayRecursiveFunctions
|
||||
description: Runaway recursive functions
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\function .buffalo(p)
|
||||
[.buffalo<p>]
|
||||
\end
|
||||
|
||||
<$text text=<<.buffalo 8>>/>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
/**-- Excessive filter recursion --**/
|
||||
@@ -0,0 +1,22 @@
|
||||
title: Functions/UndefinedParameters
|
||||
description: Undefined function parameters
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\function greet(who)
|
||||
[[hello ]addsuffix<who>]
|
||||
\end
|
||||
|
||||
<$text text={{{[function[greet],[world]]}}}/>
|
||||
|
||||
<<greet world>>
|
||||
|
||||
<$text text={{{[function[greet]]}}}/>
|
||||
|
||||
<<greet>>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
hello world<p>hello world</p>hello <p>hello </p>
|
||||
@@ -0,0 +1,36 @@
|
||||
title: Functions/WikifiedFunctions
|
||||
description: Wikified functions
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\function fn-buffalo(param)
|
||||
[<param>addsuffix[ with a ''buffalo'']]
|
||||
\end
|
||||
|
||||
\procedure proc-buffalo(param)
|
||||
<<param>> with a ''buffalo''
|
||||
\end
|
||||
|
||||
\define macro-buffalo(param)
|
||||
$param$ with a ''buffalo''
|
||||
\end
|
||||
|
||||
<<fn-buffalo "Going to lunch">>
|
||||
|
||||
<<proc-buffalo "Going to breakfast">>
|
||||
|
||||
<<macro-buffalo "Going to dinner">>
|
||||
|
||||
<$transclude $variable="fn-buffalo" param="Going to lunch" $output="text/plain"/>
|
||||
|
||||
<$transclude $variable="proc-buffalo" param="Going to breakfast" $output="text/plain"/>
|
||||
|
||||
<$transclude $variable="macro-buffalo" param="Going to dinner" $output="text/plain"/>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>Going to lunch with a ''buffalo''</p><p>Going to breakfastwith a<strong>buffalo</strong></p><p>Going to dinner with a <strong>buffalo</strong></p>Going to lunch with a buffalo with a buffaloGoing to dinner with a buffalo
|
||||
@@ -0,0 +1,31 @@
|
||||
title: Genesis/RedefineLet
|
||||
description: Using the genesis widget to override the let widget
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\widget $let()
|
||||
\whitespace trim
|
||||
<$parameters $params="@params">
|
||||
<$setmultiplevariables $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget<currentTiddler>addprefix[--]addsuffix[--]]">
|
||||
<$slot $name="ts-raw"/>
|
||||
</$setmultiplevariables>
|
||||
</$parameters>
|
||||
\end
|
||||
<$let
|
||||
one="Elephant"
|
||||
$two="Kangaroo"
|
||||
$$three="Giraffe"
|
||||
>
|
||||
(<$text text=<<one>>/>)
|
||||
(<$text text=<<$two>>/>)
|
||||
(<$text text=<<$$three>>/>)
|
||||
</$let>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>(--Elephant--)
|
||||
(--Kangaroo--)
|
||||
(--Giraffe--)</p>
|
||||
@@ -0,0 +1,22 @@
|
||||
title: Macros/TrailingNewlines
|
||||
description: Trailing newlines in macros must not be dropped
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\define inner()
|
||||
Paragraph 1
|
||||
|
||||
Paragraph 2
|
||||
\end
|
||||
\define outer()
|
||||
<$macrocall $name=inner />
|
||||
|
||||
\end
|
||||
<<outer>>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>Paragraph 1</p><p>Paragraph 2</p>
|
||||
@@ -0,0 +1,20 @@
|
||||
title: Procedures/Nested
|
||||
description: Nested Procedures
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\procedure alpha(x)
|
||||
\procedure beta(y)
|
||||
<$text text=<<y>>/>
|
||||
\end beta
|
||||
<$transclude $variable="beta" y={{{ [<x>addprefix<x>] }}}/>
|
||||
\end alpha
|
||||
|
||||
<<alpha "Elephant">>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>ElephantElephant</p>
|
||||
@@ -0,0 +1,27 @@
|
||||
title: Transclude/CustomWidget/ActionWidget
|
||||
description: Custom widget definition
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$transclude $tiddler='Result'>
|
||||
</$transclude>
|
||||
+
|
||||
title: Actions
|
||||
|
||||
\whitespace trim
|
||||
<!-- Define the <$$action-mywidget> widget by defining a transcludable variable with that name -->
|
||||
\widget $$action-mywidget(one:'Jaguar')
|
||||
\whitespace trim
|
||||
<$action-setfield $tiddler="Result" $field="text" $value=<<one>>/>
|
||||
\end
|
||||
|
||||
<$$action-mywidget one="Dingo">
|
||||
Crocodile
|
||||
</$$action-mywidget>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>Dingo</p>
|
||||
@@ -0,0 +1,26 @@
|
||||
title: Transclude/CustomWidget/Fail
|
||||
description: Custom widget failed definition
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<!-- Attempt to define the <$non-existent-widget> widget by defining a transcludable variable with that name -->
|
||||
\widget $non-existent-widget(one:'Jaguar')
|
||||
\whitespace trim
|
||||
<$text text=<<one>>/>
|
||||
<$slot $name="ts-raw">
|
||||
Whale
|
||||
</$slot>
|
||||
\end
|
||||
<$non-existent-widget one="Dingo">
|
||||
Crocodile
|
||||
</$non-existent-widget>
|
||||
<$non-existent-widget one="BumbleBee">
|
||||
Squirrel
|
||||
</$non-existent-widget>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>Undefined widget 'non-existent-widget'Undefined widget 'non-existent-widget'</p>
|
||||
@@ -0,0 +1,29 @@
|
||||
title: CustomWidget-Override-Codeblock
|
||||
description: Usage of genesis widget with attributes starting with dollar signs
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\import Definition
|
||||
<$codeblock code="Kangaroo"/>
|
||||
<$codeblock code={{Subject}}/>
|
||||
<$let test="Tiger">
|
||||
<$codeblock code=<<test>>/>
|
||||
</$let>
|
||||
+
|
||||
title: Definition
|
||||
|
||||
\whitespace trim
|
||||
\widget $codeblock(code)
|
||||
<$genesis $type="$codeblock" $remappable="no" code={{{ [<code>addprefix[£]addsuffix[@]] }}}/>
|
||||
\end
|
||||
+
|
||||
title: Subject
|
||||
|
||||
Python
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p><pre><code>£Kangaroo@</code></pre><pre><code>£Python@</code></pre><pre><code>£Tiger@</code></pre></p>
|
||||
@@ -0,0 +1,33 @@
|
||||
title: Transclude/CustomWidget/OverrideTransclude
|
||||
description: Custom widget definition attempting to override transclude
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$transclude $tiddler='TiddlerOne' one='Ferret'>
|
||||
</$transclude>
|
||||
+
|
||||
title: TiddlerZero
|
||||
|
||||
Antelope
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
||||
\whitespace trim
|
||||
<!-- Redefine the <$transclude> widget by defining a transcludable variable with that name -->
|
||||
\widget $transclude(one:'Jaguar')
|
||||
\whitespace trim
|
||||
<$text text=<<one>>/>
|
||||
<$slot $name="body">
|
||||
Whale
|
||||
</$slot>
|
||||
\end
|
||||
<$genesis $type="$transclude" $remappable="no" $$tiddler="TiddlerZero">
|
||||
Crocodile
|
||||
</$genesis>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>Antelope</p>
|
||||
@@ -0,0 +1,33 @@
|
||||
title: Transclude/CustomWidget/Simple
|
||||
description: Custom widget definition
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$transclude $tiddler='TiddlerOne' one='Ferret'>
|
||||
</$transclude>
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
||||
\whitespace trim
|
||||
<!-- Define the <$$mywidget> widget by defining a transcludable variable with that name -->
|
||||
\widget $$mywidget(one:'Jaguar')
|
||||
\whitespace trim
|
||||
<$text text=<<one>>/>
|
||||
<$slot $name="ts-raw">
|
||||
Whale
|
||||
</$slot>
|
||||
\end
|
||||
<$$mywidget one="Dingo">
|
||||
Crocodile
|
||||
</$$mywidget>
|
||||
<$$mywidget one="BumbleBee">
|
||||
Squirrel
|
||||
</$$mywidget>
|
||||
<$$mywidget/>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>DingoCrocodileBumbleBeeSquirrelJaguarWhale</p>
|
||||
@@ -0,0 +1,20 @@
|
||||
title: CustomWidget/Slotted/Empty
|
||||
description: Custom widget with empty slotted values
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\widget $$mywidget()
|
||||
<$slot $name=ts-raw>the body is empty</$slot>
|
||||
\end
|
||||
|
||||
#<$$mywidget/>
|
||||
#<$$mywidget></$$mywidget>
|
||||
#<$$mywidget>the body is not empty</$$mywidget>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<ol><li>the body is empty</li><li>the body is empty</li><li>the body is not empty</li></ol>
|
||||
@@ -0,0 +1,27 @@
|
||||
title: Transclude/CustomWidget/Slotted
|
||||
description: Custom widget definition
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\widget $$mywidget(one:'Jaguar')
|
||||
\whitespace trim
|
||||
<$text text=<<one>>/>
|
||||
<$slot $name="ts-stuff">
|
||||
Whale
|
||||
</$slot>
|
||||
\end
|
||||
<$$mywidget one="Dingo">
|
||||
<$fill $name="ts-stuff">
|
||||
Crocodile
|
||||
</$fill>
|
||||
</$$mywidget>
|
||||
<$$mywidget one="BumbleBee">
|
||||
Squirrel
|
||||
</$$mywidget>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>DingoCrocodileBumbleBeeWhale</p>
|
||||
@@ -0,0 +1,27 @@
|
||||
title: Transclude/CustomWidget/TextWidgetOverride
|
||||
description: Custom widget definition redefining the text widget
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$transclude $tiddler='TiddlerOne'>
|
||||
</$transclude>
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
||||
\whitespace trim
|
||||
<!-- Redefining the text widget only works when it is explicitly invoked with the <$text> syntax, and not implicitly via typed text -->
|
||||
\widget $text(text:'Jaguar')
|
||||
\whitespace trim
|
||||
<$genesis $type="$text" $remappable="no" text={{{ [<text>addprefix[≤]addsuffix[≥]] }}}/>
|
||||
\end
|
||||
|
||||
<$text text="Dingo"/>
|
||||
|
||||
Crocodile
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>≤Dingo≥≤Jaguar≥</p>
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
title: Transclude/CustomWidget/TextWidgetOverrideWithSlot
|
||||
description: Custom widget definition redefining the text widget
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$transclude $tiddler='TiddlerOne'>
|
||||
</$transclude>
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
||||
\whitespace trim
|
||||
<!-- Redefine the <$text> widget by defining a transcludable variable with that name -->
|
||||
\widget $text(text:'Jaguar')
|
||||
\whitespace trim
|
||||
<$genesis $type="$text" $remappable="no" text=<<text>>/>
|
||||
<$set name="$text" value="">
|
||||
<$slot $name="ts-raw">
|
||||
Whale
|
||||
</$slot>
|
||||
</$set>
|
||||
\end
|
||||
<$text text="Dingo">
|
||||
Crocodile
|
||||
</$text>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>DingoCrocodile</p>
|
||||
@@ -0,0 +1,31 @@
|
||||
title: CustomWidget-Unoverride-Codeblock
|
||||
description: Usage of genesis widget with attributes starting with dollar signs, and unoverriding a core widget
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\import Definition
|
||||
<$let $codeblock="">
|
||||
<$codeblock code="Kangaroo"/>
|
||||
<$codeblock code={{Subject}}/>
|
||||
<$let test="Tiger">
|
||||
<$codeblock code=<<test>>/>
|
||||
</$let>
|
||||
</$let>
|
||||
+
|
||||
title: Definition
|
||||
|
||||
\whitespace trim
|
||||
\widget $codeblock(code)
|
||||
<$genesis $type="codeblock" $remappable="no" code={{{ [<code>addprefix[£]addsuffix[@]] }}}/>
|
||||
\end
|
||||
+
|
||||
title: Subject
|
||||
|
||||
Python
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p><pre><code>Kangaroo</code></pre><pre><code>Python</code></pre><pre><code>Tiger</code></pre></p>
|
||||
@@ -0,0 +1,29 @@
|
||||
title: Transclude/CustomWidget/VariableAttribute
|
||||
description: Custom widget definition using an attribute called $variable
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$transclude $tiddler='TiddlerOne' one='Ferret'>
|
||||
</$transclude>
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
||||
\whitespace trim
|
||||
<!-- Redefine the <$$mywidget> widget by defining a transcludable variable with that name -->
|
||||
\widget $$mywidget($variable:'Jaguar')
|
||||
\whitespace trim
|
||||
<$text text=<<$variable>>/>
|
||||
<$slot $name="ts-raw">
|
||||
Whale
|
||||
</$slot>
|
||||
\end
|
||||
<$$mywidget $variable="Dingo">
|
||||
Crocodile
|
||||
</$$mywidget>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>DingoCrocodile</p>
|
||||
@@ -0,0 +1,17 @@
|
||||
title: Transclude/Macro/JavaScript
|
||||
description: Transcluding a javascript macro
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
|
||||
<<makedatauri text:"Wildebeest" type:"text/plain">>
|
||||
|
||||
<$macrocall $name="makedatauri" text="Wildebeest" type="text/plain"/>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p><a class="tc-tiddlylink-external" href="data:text/plain,Wildebeest" rel="noopener noreferrer" target="_blank">data:text/plain,Wildebeest</a></p><p><a class="tc-tiddlylink-external" href="data:text/plain,Wildebeest" rel="noopener noreferrer" target="_blank">data:text/plain,Wildebeest</a></p>
|
||||
@@ -0,0 +1,17 @@
|
||||
title: Transclude/Macro/Plain
|
||||
description: Transcluding a macro as plain text
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$let currentTab="Jeremy">
|
||||
<$macrocall $name="currentTab" $type="text/plain" $output="text/plain"/>
|
||||
|
|
||||
<$transclude $variable="currentTab" $type="text/plain" $output="text/plain"/>
|
||||
</$let>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>Jeremy|Jeremy</p>
|
||||
@@ -0,0 +1,26 @@
|
||||
title: Transclude/Macro/Simple
|
||||
description: Transcluding a macro
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\define mamacro(one:"red",two:"green")
|
||||
It is $one$ and $two$ or <<__one__>> and <<__two__>>.
|
||||
\end
|
||||
|
||||
<$macrocall $name="mamacro"/>
|
||||
|
||||
<$transclude $variable="mamacro"/>
|
||||
|
||||
<$transclude $variable="mamacro" one="orange"/>
|
||||
|
||||
<$transclude $variable="mamacro" 0="pink"/>
|
||||
|
||||
<$transclude $variable="mamacro" one="purple" 1="pink"/>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>It is red and green or red and green.</p><p>It is red and green or red and green.</p><p>It is orange and green or orange and green.</p><p>It is pink and green or pink and green.</p><p>It is purple and pink or purple and pink.</p>
|
||||
@@ -0,0 +1,48 @@
|
||||
title: Transclude/MissingTarget
|
||||
description: Transcluding a missing target
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$transclude $tiddler='TiddlerOne' one='Ferret'>
|
||||
<$parameters one='Ferret'>
|
||||
Badger
|
||||
<$text text=<<one>>/>
|
||||
</$parameters>
|
||||
</$transclude>
|
||||
<$transclude $tiddler='TiddlerOne' one='Ferret'>
|
||||
<$fill $name="ts-missing">
|
||||
<$parameters one='Ferret'>
|
||||
Badger
|
||||
<$text text=<<one>>/>
|
||||
</$parameters>
|
||||
</$fill>
|
||||
</$transclude>
|
||||
<$transclude $tiddler='MissingTiddler' one='Ferret'>
|
||||
<$parameters one='Ferret'>
|
||||
Badger
|
||||
<$text text=<<one>>/>
|
||||
</$parameters>
|
||||
</$transclude>
|
||||
<$transclude $tiddler='MissingTiddler' one='Ferret'>
|
||||
<$fill $name="ts-missing">
|
||||
<$parameters one='Ferret'>
|
||||
Badger
|
||||
<$text text=<<one>>/>
|
||||
</$parameters>
|
||||
</$fill>
|
||||
</$transclude>
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
||||
\whitespace trim
|
||||
<$parameters one='Kangaroo'>
|
||||
Piranha
|
||||
<$text text=<<one>>/>
|
||||
</$parameters>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>PiranhaFerretPiranhaFerretBadgerFerretBadgerFerret</p>
|
||||
@@ -0,0 +1,34 @@
|
||||
title: Transclude/Parameterised/Depth
|
||||
description: Parameterised transclusion using the $depth attribute
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$transclude $tiddler='TiddlerOne' one='Ferret'/>
|
||||
|
|
||||
<$transclude $tiddler='TiddlerOne'/>
|
||||
|
|
||||
<$transclude $tiddler='TiddlerOne' one='Ferret' $$two="Osprey"/>
|
||||
|
|
||||
<$transclude $tiddler='TiddlerOne' $$two="Falcon"/>
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
||||
\whitespace trim
|
||||
{{TiddlerTwo}}
|
||||
+
|
||||
title: TiddlerTwo
|
||||
|
||||
\whitespace trim
|
||||
<$parameters one='Jaguar' $$two='Piranha' $depth="2">
|
||||
<$text text=<<one>>/>:<$text text=<<$two>>/>
|
||||
</$parameters>
|
||||
<$parameters one='Leopard' $$two='Coelacanth'>
|
||||
(<$text text=<<one>>/>|<$text text=<<$two>>/>)
|
||||
</$parameters>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>Ferret:Piranha(Leopard|Coelacanth)|Jaguar:Piranha(Leopard|Coelacanth)|Ferret:Osprey(Leopard|Coelacanth)|Jaguar:Falcon(Leopard|Coelacanth)</p>
|
||||
@@ -0,0 +1,29 @@
|
||||
title: Transclude/Parameterised/Mode
|
||||
description: Parameterised transclusion using the $parseMode attribute
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
|
||||
<$transclude $tiddler='TiddlerOne' one='Ferret'>
|
||||
|
||||
This is a block
|
||||
|
||||
</$transclude>
|
||||
|
||||
<$transclude $tiddler='TiddlerOne'>
|
||||
This is inline
|
||||
</$transclude>
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
||||
\whitespace trim
|
||||
<$parameters $parseMode="@parseMode">
|
||||
<$text text=<<@parseMode>>/>
|
||||
</$parameters>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>block</p><p>inline</p>
|
||||
@@ -0,0 +1,34 @@
|
||||
title: Transclude/Parameterised/Name/Values
|
||||
description: Parameterised transclusion accessing parameters as name/value pairs
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$transclude $tiddler="TiddlerOne" 0="" 1="" 2=""/>
|
||||
|
||||
{{TiddlerOne}}
|
||||
{{TiddlerOne|Ferret}}
|
||||
{{TiddlerOne|Butterfly|Moth}}
|
||||
{{TiddlerOne|Beetle|Scorpion|Snake}}
|
||||
{{TiddlerOne||TiddlerTwo|Beetle|Scorpion|Snake}}
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
||||
\whitespace trim
|
||||
<$parameters zero='Jaguar' $$one='Lizard' two='Mole' $params="@params">
|
||||
<$list filter="[<@params>jsonindexes[]]">
|
||||
{<$text text=<<currentTiddler>>/>: <$text text={{{ [<@params>jsonget<currentTiddler>] }}}/>}
|
||||
</$list>
|
||||
</$parameters>
|
||||
+
|
||||
title: TiddlerTwo
|
||||
|
||||
\whitespace trim
|
||||
\parameters(zero:'Mouse',$one:'Horse',two:'Owl')
|
||||
(<$transclude $tiddler=<<currentTiddler>> zero=<<zero>> $$one=<<$one>> two=<<two>>/>)
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>{0:}{1:}{2:}</p><p></p><p>{0:Ferret}</p><p>{0:Butterfly}{1:Moth}</p><p>{0:Beetle}{1:Scorpion}{2:Snake}</p><p>({$one:Scorpion}{two:Snake}{zero:Beetle})</p>
|
||||
@@ -0,0 +1,29 @@
|
||||
title: Transclude/Parameterised/ParseTreeNodes
|
||||
description: Parameterised transclusion using the $parseTreeNodes attribute
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
|
||||
<$transclude $tiddler='TiddlerOne' one='Ferret'>
|
||||
|
||||
This is a block
|
||||
|
||||
</$transclude>
|
||||
|
||||
<$transclude $tiddler='TiddlerOne'>
|
||||
This is inline
|
||||
</$transclude>
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
||||
\whitespace trim
|
||||
<$parameters $parseTreeNodes="@parseTreeNodes">
|
||||
<$text text=<<@parseTreeNodes>>/>
|
||||
</$parameters>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>[{"type":"element","tag":"p","children":[{"type":"text","text":"This is a block","start":68,"end":83}],"start":68,"end":83}]</p><p>[{"type":"text","text":"This is inline","start":136,"end":152}]</p>
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
title: Transclude/Parameterised/Positional/Shortcut/Parameters
|
||||
description: Positional parameterised transclusion using shortcut syntax and parameters pragma
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
{{TiddlerOne}}
|
||||
{{TiddlerOne|Ferret}}
|
||||
{{TiddlerOne|Butterfly|Moth}}
|
||||
{{TiddlerOne|Beetle|Scorpion|Snake}}
|
||||
{{TiddlerOne||TiddlerTwo|Beetle|Scorpion|Snake}}
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
||||
\whitespace trim
|
||||
\parameters(zero:Jaguar,one:'Lizard',two:'Mole')
|
||||
[{<$text text=<<zero>>/>}{<$text text=<<one>>/>}{<$text text=<<two>>/>}]
|
||||
+
|
||||
title: TiddlerTwo
|
||||
|
||||
\whitespace trim
|
||||
\parameters(zero:'Mouse',one:Horse,two:'Owl')
|
||||
(<$transclude $tiddler=<<currentTiddler>> zero=<<zero>> one=<<one>> two=<<two>>/>)
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>[{Jaguar}{Lizard}{Mole}]</p><p>[{Ferret}{Lizard}{Mole}]</p><p>[{Butterfly}{Moth}{Mole}]</p><p>[{Beetle}{Scorpion}{Snake}]</p><p>([{Beetle}{Scorpion}{Snake}])</p>
|
||||
@@ -0,0 +1,29 @@
|
||||
title: Transclude/Parameterised/Positional/Shortcut
|
||||
description: Positional parameterised transclusion using shortcut syntax
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
{{TiddlerOne}}
|
||||
{{TiddlerOne|Ferret}}
|
||||
{{TiddlerOne|Butterfly|Moth}}
|
||||
{{TiddlerOne|Beetle|Scorpion|Snake}}
|
||||
{{TiddlerOne||TiddlerTwo|Beetle|Scorpion|Snake}}
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
||||
\whitespace trim
|
||||
<$parameters zero='Jaguar' one='Lizard' two='Mole'>[{<$text text=<<zero>>/>}{<$text text=<<one>>/>}{<$text text=<<two>>/>}]</$parameters>
|
||||
+
|
||||
title: TiddlerTwo
|
||||
|
||||
\whitespace trim
|
||||
<$parameters zero='Mouse' one='Horse' two='Owl'>
|
||||
(<$transclude $tiddler=<<currentTiddler>> zero=<<zero>> one=<<one>> two=<<two>>/>)
|
||||
</$parameters>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>[{Jaguar}{Lizard}{Mole}]</p><p>[{Ferret}{Lizard}{Mole}]</p><p>[{Butterfly}{Moth}{Mole}]</p><p>[{Beetle}{Scorpion}{Snake}]</p><p>([{Beetle}{Scorpion}{Snake}])</p>
|
||||
@@ -0,0 +1,30 @@
|
||||
title: Transclude/Parameterised/Positional/Variables
|
||||
description: Positional parameterised transclusion of variables
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\function myfunction(alpha:"apple",beta:"banana",gamma:"grenadine") [<alpha>]
|
||||
\define mymacro(alpha:"apple",beta:"banana",gamma:"grenadine") $beta$
|
||||
\function f(a) [<a>]
|
||||
|
||||
(Functions:
|
||||
<$text text={{{ [<myfunction gamma:"unused" f1>] }}}/>
|
||||
,
|
||||
<$text text=<<myfunction gamma:"unused" f1>>/>
|
||||
,
|
||||
<<myfunction gamma:"unused" f1>>
|
||||
)(Macros:
|
||||
<$text text={{{ [<mymacro gamma:"unused" f1>] }}}/>
|
||||
,
|
||||
<$text text=<<mymacro gamma:"unused" f1>>/>
|
||||
,
|
||||
<<mymacro gamma:"unused" f1>>
|
||||
)
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>(Functions:f1,f1,f1)(Macros:banana,banana,banana)</p>
|
||||
@@ -0,0 +1,26 @@
|
||||
title: Transclude/Parameterised/Positional
|
||||
description: Positional parameterised transclusion
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$transclude $tiddler='TiddlerOne' zero='Ferret'/>
|
||||
<$transclude zero='Ferret' $tiddler='TiddlerOne'/>
|
||||
<$transclude $tiddler='TiddlerOne' 0='Pigeon'/>
|
||||
<$transclude 0='Pigeon' $tiddler='TiddlerOne'/>
|
||||
<$transclude $tiddler='TiddlerOne' zero='Ferret' 0='Pigeon'/>
|
||||
<$transclude zero='Ferret' 0='Pigeon' $tiddler='TiddlerOne'/>
|
||||
<$transclude $tiddler='TiddlerOne'/>
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
||||
\whitespace trim
|
||||
<$parameters zero='Jaguar'>
|
||||
<$text text=<<zero>>/>
|
||||
</$parameters>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>FerretFerretPigeonPigeonFerretFerretJaguar</p>
|
||||
@@ -0,0 +1,20 @@
|
||||
title: Transclude/Parameterised/Shortcut/Parameters
|
||||
description: Simple parameterised transclusion using the parameters pragma
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$transclude $tiddler='TiddlerOne' one='Ferret'/>
|
||||
<$transclude $tiddler='TiddlerOne'/>
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
||||
\whitespace trim
|
||||
\parameters(one:'Jaguar')
|
||||
<$text text=<<one>>/>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>FerretJaguar</p>
|
||||
@@ -0,0 +1,21 @@
|
||||
title: Transclude/Parameterised/Shortcut
|
||||
description: Simple parameterised transclusion
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\procedure test(one:'Jaguar')
|
||||
{<$text text=<<one>>/>}
|
||||
\end
|
||||
|
||||
<$transclude $variable='test' one='Ferret'/>
|
||||
<$transclude $variable='test'/>
|
||||
<<test "Rat">>
|
||||
<<test one:"Mouse">>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>{Ferret}{Jaguar}{Rat}{Mouse}</p>
|
||||
@@ -0,0 +1,26 @@
|
||||
title: Transclude/Parameterised/Simple
|
||||
description: Simple parameterised transclusion
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$transclude $tiddler='TiddlerOne' one='Ferret'/>
|
||||
|
|
||||
<$transclude $tiddler='TiddlerOne'/>
|
||||
|
|
||||
<$transclude $tiddler='TiddlerOne' one='Ferret' $$two="Osprey"/>
|
||||
|
|
||||
<$transclude $tiddler='TiddlerOne' $$two="Falcon"/>
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
||||
\whitespace trim
|
||||
<$parameters one='Jaguar' $$two='Piranha'>
|
||||
<$text text=<<one>>/>:<$text text=<<$two>>/>
|
||||
</$parameters>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>Ferret:Piranha|Jaguar:Piranha|Ferret:Osprey|Jaguar:Falcon</p>
|
||||
@@ -0,0 +1,29 @@
|
||||
title: Transclude/Parameterised/SlotFillParseTreeNodes
|
||||
description: Parameterised transclusion using the $slotFillParseTreeNodes attribute
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
|
||||
<$transclude $tiddler='TiddlerOne' one='Ferret'>
|
||||
<$fill $name="one">This is first</$fill>
|
||||
<$fill $name="two">But this is second</$fill>
|
||||
</$transclude>
|
||||
|
||||
<$transclude $tiddler='TiddlerOne'>
|
||||
<$fill $name="one">This is first
|
||||
<$fill $name="two">But this is second</$fill></$fill>
|
||||
</$transclude>
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
||||
\whitespace trim
|
||||
<$parameters $slotFillParseTreeNodes="@slotFillParseTreeNodes">
|
||||
<$text text={{{ [<@slotFillParseTreeNodes>jsonindexes[]join[,]] }}}/>
|
||||
</$parameters>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>one,ts-raw,two</p><p>one,ts-raw</p>
|
||||
@@ -0,0 +1,24 @@
|
||||
title: Transclude/Parameterised/Slotted/Missing
|
||||
description: Parameterised transclusion with slotted missing values
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$transclude $tiddler='TiddlerOne' one='Ferret'>
|
||||
</$transclude>
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
||||
\whitespace trim
|
||||
<$parameters one='Jaguar'>
|
||||
<$text text=<<one>>/>
|
||||
<$slot $name="content">
|
||||
Whale
|
||||
</$slot>
|
||||
</$parameters>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>FerretWhale</p>
|
||||
@@ -0,0 +1,27 @@
|
||||
title: Transclude/Parameterised/Slotted
|
||||
description: Parameterised transclusion with slotted values
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$transclude $tiddler='TiddlerOne' one='Ferret'>
|
||||
<$fill $name="content">
|
||||
Hippopotamus
|
||||
</$fill>
|
||||
</$transclude>
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
||||
\whitespace trim
|
||||
<$parameters one='Jaguar'>
|
||||
<$text text=<<one>>/>
|
||||
<$slot $name="content">
|
||||
Whale
|
||||
</$slot>
|
||||
</$parameters>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>FerretHippopotamus</p>
|
||||
@@ -0,0 +1,25 @@
|
||||
title: Transclude/Procedures/Whitespace
|
||||
description: Procedures should inherit whitespace settings from definition site
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
\procedure testproc()
|
||||
This is a sentence
|
||||
\end
|
||||
|
||||
\define testmacro()
|
||||
This is a sentence
|
||||
\end
|
||||
This is a sentence
|
||||
[<<testproc>>]
|
||||
[<<testmacro>>]
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>This is a sentence
|
||||
[This is a sentence]
|
||||
[This is a sentence ]</p>
|
||||
@@ -0,0 +1,38 @@
|
||||
title: Transclude/Typed
|
||||
description: Typed transclusion
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\procedure testproc()
|
||||
This is ''wikitext''
|
||||
\end
|
||||
|
||||
<$transclude $variable="testproc"/>
|
||||
-
|
||||
<$transclude $variable="testproc" $type="text/plain"/>
|
||||
|
||||
<$transclude $tiddler="Data" $index="testindex"/>
|
||||
-
|
||||
<$transclude $tiddler="Data" $index="testindex" $type="text/plain"/>
|
||||
|
||||
<$transclude $tiddler="Data" $field="custom"/>
|
||||
-
|
||||
<$transclude $tiddler="Data" $field="custom" $type="text/plain"/>
|
||||
+
|
||||
title: Data
|
||||
type: application/x-tiddler-dictionary
|
||||
custom: This is ''wikitext''
|
||||
|
||||
testindex: This is ''wikitext''
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>This is <strong>wikitext</strong>
|
||||
-
|
||||
<pre><code>This is ''wikitext''</code></pre></p><p>This is <strong>wikitext</strong>
|
||||
-
|
||||
<pre><code>This is ''wikitext''</code></pre></p><p>This is <strong>wikitext</strong>
|
||||
-
|
||||
<pre><code>This is ''wikitext''</code></pre></p>
|
||||
@@ -0,0 +1,15 @@
|
||||
title: Widgets/LetWidgetSelfReferences
|
||||
description: Test let widget self references
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$let default={{{ [[default]is[variable]then[aa]else[bb]] }}} >
|
||||
<<default>>
|
||||
</$let>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>bb</p>
|
||||
@@ -0,0 +1,15 @@
|
||||
title: Widgets/LetWidgetUndefinedVariable
|
||||
description: Test let widget undefined variable
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$let test1=<<test>> test2={{{ [<test1>] }}}>
|
||||
<<test2>>
|
||||
</$let>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p></p>
|
||||
@@ -422,7 +422,7 @@ Tests the filtering mechanism.
|
||||
expect(wiki.filterTiddlers("[[one]tagging[]sort[title]]").join(",")).toBe("Tiddler Three,Tiddler8,TiddlerOne,TiddlerSeventh");
|
||||
expect(wiki.filterTiddlers("[[one]tagging[]]").join(",")).toBe("Tiddler Three,TiddlerOne,TiddlerSeventh,Tiddler8");
|
||||
expect(wiki.filterTiddlers("[[two]tagging[]sort[title]]").join(",")).toBe("$:/TiddlerFive,$:/TiddlerTwo,Tiddler Three");
|
||||
var fakeWidget = {getVariable: function() {return "one";}};
|
||||
var fakeWidget = {wiki: wiki, getVariable: function(name) {return name === "currentTiddler" ? "one": undefined;}};
|
||||
expect(wiki.filterTiddlers("[all[current]tagging[]]",fakeWidget).join(",")).toBe("Tiddler Three,TiddlerOne,TiddlerSeventh,Tiddler8");
|
||||
});
|
||||
|
||||
@@ -625,7 +625,7 @@ Tests the filtering mechanism.
|
||||
expect(wiki.filterTiddlers("[{!!title}]").join(",")).toBe("");
|
||||
expect(wiki.filterTiddlers("[prefix{Tiddler8}] +[sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne");
|
||||
expect(wiki.filterTiddlers("[modifier{Tiddler8!!test-field}] +[sort[title]]").join(",")).toBe("TiddlerOne");
|
||||
var fakeWidget = {wiki: wiki, getVariable: function() {return "Tiddler Three";}};
|
||||
var fakeWidget = {wiki: wiki, getVariable: function(name) {return name === "currentTiddler" ? "Tiddler Three": undefined;}};
|
||||
expect(wiki.filterTiddlers("[modifier{!!modifier}] +[sort[title]]",fakeWidget).join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three");
|
||||
});
|
||||
|
||||
@@ -1071,6 +1071,20 @@ Tests the filtering mechanism.
|
||||
expect(wiki.filterTiddlers("[charcode[9],[10]]").join(" ")).toBe(String.fromCharCode(9) + String.fromCharCode(10));
|
||||
expect(wiki.filterTiddlers("[charcode[]]").join(" ")).toBe("");
|
||||
});
|
||||
|
||||
it("should handle the levenshtein operator", function() {
|
||||
expect(wiki.filterTiddlers("[[apple]levenshtein[apple]]").join(" ")).toBe("0");
|
||||
expect(wiki.filterTiddlers("[[apple]levenshtein[banana]]").join(" ")).toBe("9");
|
||||
expect(wiki.filterTiddlers("[[representation]levenshtein[misreprehensionisation]]").join(" ")).toBe("10");
|
||||
expect(wiki.filterTiddlers("[[the cat sat on the mat]levenshtein[the hat saw in every category]]").join(" ")).toBe("13");
|
||||
});
|
||||
|
||||
it("should handle the makepatches operator", function() {
|
||||
expect(wiki.filterTiddlers("[[apple]makepatches[apple]]").join(" ")).toBe("");
|
||||
expect(wiki.filterTiddlers("[[apple]makepatches[banana]]").join(" ")).toBe("@@ -1,5 +1,6 @@\n-apple\n+banana\n");
|
||||
expect(wiki.filterTiddlers("[[representation]makepatches[misreprehensionisation]]").join(" ")).toBe("@@ -1,13 +1,21 @@\n+mis\n repre\n-sent\n+hensionis\n atio\n");
|
||||
expect(wiki.filterTiddlers("[[the cat sat on the mat]makepatches[the hat saw in every category]]").join(" ")).toBe("@@ -1,22 +1,29 @@\n the \n-c\n+h\n at sa\n-t on the mat\n+w in every category\n");
|
||||
});
|
||||
|
||||
it("should parse filter variable parameters", function(){
|
||||
expect($tw.utils.parseFilterVariable("currentTiddler")).toEqual(
|
||||
|
||||
@@ -124,7 +124,7 @@ describe("Wiki.parseTextReference tests", function() {
|
||||
// Non-existent subtiddler of a plugin
|
||||
expect(parseAndGetSource("$:/ShadowPlugin","text",null,"MyMissingTiddler")).toEqual(null);
|
||||
// Plain text tiddler
|
||||
expect(parseAndGetSource("TiddlerNine")).toEqual(undefined);
|
||||
expect(parseAndGetSource("TiddlerNine")).toEqual("this is plain text");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -188,4 +188,4 @@ describe("Utility tests", function() {
|
||||
|
||||
});
|
||||
|
||||
})();
|
||||
})();
|
||||
@@ -143,7 +143,7 @@ describe("Widget module", function() {
|
||||
var wiki = new $tw.Wiki();
|
||||
// Add a tiddler
|
||||
wiki.addTiddlers([
|
||||
{title: "TiddlerOne", text: "<$transclude tiddler='TiddlerTwo'/>\n"},
|
||||
{title: "TiddlerOne", text: "<$transclude tiddler='TiddlerTwo'/>"},
|
||||
{title: "TiddlerTwo", text: "<$transclude tiddler='TiddlerOne'/>"}
|
||||
]);
|
||||
// Test parse tree
|
||||
@@ -157,7 +157,7 @@ describe("Widget module", function() {
|
||||
// Render the widget node to the DOM
|
||||
var wrapper = renderWidgetNode(widgetNode);
|
||||
// Test the rendering
|
||||
expect(wrapper.innerHTML).toBe("<span class=\"tc-error\">Recursive transclusion error in transclude widget</span>\n");
|
||||
expect(wrapper.innerHTML).toBe("<span class=\"tc-error\">Recursive transclusion error in transclude widget</span>");
|
||||
});
|
||||
|
||||
it("should deal with SVG elements", function() {
|
||||
@@ -683,7 +683,7 @@ describe("Widget module", function() {
|
||||
expect(wrapper.innerHTML).toBe("<p>New value</p>");
|
||||
});
|
||||
|
||||
it("should can mix setWidgets and macros when importing", function() {
|
||||
it("should support mixed setWidgets and macros when importing", function() {
|
||||
var wiki = new $tw.Wiki();
|
||||
// Add some tiddlers
|
||||
wiki.addTiddlers([
|
||||
@@ -699,6 +699,20 @@ describe("Widget module", function() {
|
||||
expect(wrapper.innerHTML).toBe("<p>Aval Bval Cval</p>");
|
||||
});
|
||||
|
||||
it("should skip parameters widgets when importing", function() {
|
||||
var wiki = new $tw.Wiki();
|
||||
// Add some tiddlers
|
||||
wiki.addTiddlers([
|
||||
{title: "B", text: "<$parameters bee=nothing><$set name='B' value='Bval'>\n\ndummy text</$set></$parameters>"},
|
||||
]);
|
||||
var text = "\\import B\n<<B>>";
|
||||
var widgetNode = createWidgetNode(parseText(text,wiki),wiki);
|
||||
// Render the widget node to the DOM
|
||||
var wrapper = renderWidgetNode(widgetNode);
|
||||
// Test the rendering
|
||||
expect(wrapper.innerHTML).toBe("<p>Bval</p>");
|
||||
});
|
||||
|
||||
it("can have more than one macroDef variable imported", function() {
|
||||
var wiki = new $tw.Wiki();
|
||||
wiki.addTiddlers([
|
||||
|
||||
@@ -19,7 +19,8 @@ describe("WikiText parser tests", function() {
|
||||
|
||||
// Define a parsing shortcut
|
||||
var parse = function(text) {
|
||||
return wiki.parseText("text/vnd.tiddlywiki",text).tree;
|
||||
var tree = wiki.parseText("text/vnd.tiddlywiki",text).tree;
|
||||
return tree;
|
||||
};
|
||||
|
||||
it("should parse tags", function() {
|
||||
@@ -114,7 +115,70 @@ describe("WikiText parser tests", function() {
|
||||
it("should parse macro definitions", function() {
|
||||
expect(parse("\\define myMacro()\nnothing\n\\end\n")).toEqual(
|
||||
|
||||
[ { type : 'set', attributes : { name : { type : 'string', value : 'myMacro' }, value : { type : 'string', value : 'nothing' } }, children : [ ], params : [ ], isMacroDefinition : true } ]
|
||||
[{"type":"set","attributes":{"name":{"name":"name","type":"string","value":"myMacro"},"value":{"name":"value","type":"string","value":"nothing"}},"children":[],"params":[],"isMacroDefinition":true,"orderedAttributes":[{"name":"name","type":"string","value":"myMacro"},{"name":"value","type":"string","value":"nothing"}]}]
|
||||
|
||||
);
|
||||
});
|
||||
|
||||
it("should parse procedure definitions with no parameters", function() {
|
||||
expect(parse("\\procedure myMacro()\nnothing\n\\end\n")).toEqual(
|
||||
|
||||
[{"type":"set","attributes":{"name":{"name":"name","type":"string","value":"myMacro"},"value":{"name":"value","type":"string","value":"nothing"}},"children":[],"params":[],"orderedAttributes":[{"name":"name","type":"string","value":"myMacro"},{"name":"value","type":"string","value":"nothing"}],"isProcedureDefinition":true}]
|
||||
|
||||
);
|
||||
});
|
||||
|
||||
it("should parse single line procedure definitions with no parameters", function() {
|
||||
expect(parse("\\procedure myMacro() nothing\n")).toEqual(
|
||||
|
||||
[{"type":"set","attributes":{"name":{"name":"name","type":"string","value":"myMacro"},"value":{"name":"value","type":"string","value":"nothing"}},"children":[],"params":[],"orderedAttributes":[{"name":"name","type":"string","value":"myMacro"},{"name":"value","type":"string","value":"nothing"}],"isProcedureDefinition":true}]
|
||||
|
||||
);
|
||||
});
|
||||
|
||||
it("should parse procedure definitions with parameters", function() {
|
||||
expect(parse("\\procedure myMacro(one,two,three,four:elephant)\nnothing\n\\end\n")).toEqual(
|
||||
|
||||
[{"type":"set","attributes":{"name":{"name":"name","type":"string","value":"myMacro"},"value":{"name":"value","type":"string","value":"nothing"}},"children":[],"params":[{"name":"one"},{"name":"two"},{"name":"three"},{"name":"four","default":"elephant"}],"orderedAttributes":[{"name":"name","type":"string","value":"myMacro"},{"name":"value","type":"string","value":"nothing"}],"isProcedureDefinition":true}]
|
||||
|
||||
);
|
||||
});
|
||||
|
||||
it("should parse procedure definitions", function() {
|
||||
expect(parse("\\procedure myMacro(one:'Jaguar')\n<$text text=<<one>>/>\n\\end\n\n")).toEqual(
|
||||
|
||||
[{"type":"set","attributes":{"name":{"name":"name","type":"string","value":"myMacro"},"value":{"name":"value","type":"string","value":"<$text text=<<one>>/>"}},"children":[],"params":[{"name":"one","default":"Jaguar"}],"orderedAttributes":[{"name":"name","type":"string","value":"myMacro"},{"name":"value","type":"string","value":"<$text text=<<one>>/>"}],"isProcedureDefinition":true}]
|
||||
|
||||
);
|
||||
|
||||
}); it("should parse function definitions with no parameters", function() {
|
||||
expect(parse("\\function myMacro()\nnothing\n\\end\n")).toEqual(
|
||||
|
||||
[{"type":"set","attributes":{"name":{"name":"name","type":"string","value":"myMacro"},"value":{"name":"value","type":"string","value":"nothing"}},"children":[],"params":[],"orderedAttributes":[{"name":"name","type":"string","value":"myMacro"},{"name":"value","type":"string","value":"nothing"}],"isFunctionDefinition":true}]
|
||||
|
||||
);
|
||||
});
|
||||
|
||||
it("should parse single line function definitions with no parameters", function() {
|
||||
expect(parse("\\function myMacro() nothing\n")).toEqual(
|
||||
|
||||
[{"type":"set","attributes":{"name":{"name":"name","type":"string","value":"myMacro"},"value":{"name":"value","type":"string","value":"nothing"}},"children":[],"params":[],"orderedAttributes":[{"name":"name","type":"string","value":"myMacro"},{"name":"value","type":"string","value":"nothing"}],"isFunctionDefinition":true}]
|
||||
|
||||
);
|
||||
});
|
||||
|
||||
it("should parse function definitions with parameters", function() {
|
||||
expect(parse("\\function myMacro(one,two,three,four:elephant)\nnothing\n\\end\n")).toEqual(
|
||||
|
||||
[{"type":"set","attributes":{"name":{"name":"name","type":"string","value":"myMacro"},"value":{"name":"value","type":"string","value":"nothing"}},"children":[],"params":[{"name":"one"},{"name":"two"},{"name":"three"},{"name":"four","default":"elephant"}],"orderedAttributes":[{"name":"name","type":"string","value":"myMacro"},{"name":"value","type":"string","value":"nothing"}],"isFunctionDefinition":true}]
|
||||
|
||||
);
|
||||
});
|
||||
|
||||
it("should parse function definitions", function() {
|
||||
expect(parse("\\function myMacro(one:'Jaguar')\n<$text text=<<one>>/>\n\\end\n\n")).toEqual(
|
||||
|
||||
[{"type":"set","attributes":{"name":{"name":"name","type":"string","value":"myMacro"},"value":{"name":"value","type":"string","value":"<$text text=<<one>>/>"}},"children":[],"params":[{"name":"one","default":"Jaguar"}],"orderedAttributes":[{"name":"name","type":"string","value":"myMacro"},{"name":"value","type":"string","value":"<$text text=<<one>>/>"}],"isFunctionDefinition":true}]
|
||||
|
||||
);
|
||||
});
|
||||
@@ -122,7 +186,7 @@ describe("WikiText parser tests", function() {
|
||||
it("should parse comment in pragma area. Comment will be invisible", function() {
|
||||
expect(parse("<!-- comment in pragma area -->\n\\define aMacro()\nnothing\n\\end\n")).toEqual(
|
||||
|
||||
[ { type : 'set', attributes : { name : { type : 'string', value : 'aMacro' }, value : { type : 'string', value : 'nothing' } }, children : [ ], params : [ ], isMacroDefinition : true } ]
|
||||
[{"type":"set","attributes":{"name":{"name":"name","type":"string","value":"aMacro"},"value":{"name":"value","type":"string","value":"nothing"}},"children":[],"params":[],"isMacroDefinition":true,"orderedAttributes":[{"name":"name","type":"string","value":"aMacro"},{"name":"value","type":"string","value":"nothing"}]}]
|
||||
|
||||
);
|
||||
});
|
||||
@@ -143,38 +207,38 @@ describe("WikiText parser tests", function() {
|
||||
it("should parse inline macro calls", function() {
|
||||
expect(parse("<<john>><<paul>><<george>><<ringo>>")).toEqual(
|
||||
|
||||
[ { type: 'element', tag: 'p', start: 0, end: 35, children: [ { type: 'macrocall', start: 0, params: [ ], name: 'john', end: 8 }, { type: 'macrocall', start: 8, params: [ ], name: 'paul', end: 16 }, { type: 'macrocall', start: 16, params: [ ], name: 'george', end: 26 }, { type: 'macrocall', start: 26, params: [ ], name: 'ringo', end: 35 } ] } ]
|
||||
[{"type":"element","tag":"p","children":[{"type":"transclude","start":0,"end":8,"attributes":{"$variable":{"name":"$variable","type":"string","value":"john"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"john"}]},{"type":"transclude","start":8,"end":16,"attributes":{"$variable":{"name":"$variable","type":"string","value":"paul"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"paul"}]},{"type":"transclude","start":16,"end":26,"attributes":{"$variable":{"name":"$variable","type":"string","value":"george"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"george"}]},{"type":"transclude","start":26,"end":35,"attributes":{"$variable":{"name":"$variable","type":"string","value":"ringo"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"ringo"}]}],"start":0,"end":35}]
|
||||
|
||||
);
|
||||
expect(parse("text <<john one:val1 two: 'val \"2\"' three: \"val '3'\" four: \"\"\"val 4\"5'\"\"\" five: [[val 5]] >>")).toEqual(
|
||||
|
||||
[{ type: 'element', tag: 'p', start: 0, end: 92, children: [ { type: 'text', text: 'text ', start: 0, end: 5 }, { type: 'macrocall', name: 'john', start: 5, params: [ { type: 'macro-parameter', start: 11, value: 'val1', name: 'one', end: 20 }, { type: 'macro-parameter', start: 20, value: 'val "2"', name: 'two', end: 35 }, { type: 'macro-parameter', start: 35, value: 'val \'3\'', name: 'three', end: 52 }, { type: 'macro-parameter', start: 52, value: 'val 4"5\'', name: 'four', end: 73 }, { type: 'macro-parameter', start: 73, value: 'val 5', name: 'five', end: 89 } ], end: 92 } ] } ]
|
||||
[{"type":"element","tag":"p","children":[{"type":"text","text":"text ","start":0,"end":5},{"type":"transclude","start":5,"end":92,"attributes":{"$variable":{"name":"$variable","type":"string","value":"john"},"one":{"name":"one","type":"string","value":"val1","start":11,"end":20},"two":{"name":"two","type":"string","value":"val \"2\"","start":20,"end":35},"three":{"name":"three","type":"string","value":"val '3'","start":35,"end":52},"four":{"name":"four","type":"string","value":"val 4\"5'","start":52,"end":73},"five":{"name":"five","type":"string","value":"val 5","start":73,"end":89}},"orderedAttributes":[{"name":"$variable","type":"string","value":"john"},{"name":"one","type":"string","value":"val1","start":11,"end":20},{"name":"two","type":"string","value":"val \"2\"","start":20,"end":35},{"name":"three","type":"string","value":"val '3'","start":35,"end":52},{"name":"four","type":"string","value":"val 4\"5'","start":52,"end":73},{"name":"five","type":"string","value":"val 5","start":73,"end":89}]}],"start":0,"end":92}]
|
||||
|
||||
);
|
||||
expect(parse("ignored << carrots <<john>>")).toEqual(
|
||||
|
||||
[ { type: 'element', tag: 'p', start: 0, end: 27, children: [ { type: 'text', text: 'ignored << carrots ', start: 0, end: 19 }, { type: 'macrocall', name: 'john', start: 19, params: [ ], end: 27 } ] } ]
|
||||
[{"type":"element","tag":"p","children":[{"type":"text","text":"ignored << carrots ","start":0,"end":19},{"type":"transclude","start":19,"end":27,"attributes":{"$variable":{"name":"$variable","type":"string","value":"john"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"john"}]}],"start":0,"end":27}]
|
||||
|
||||
);
|
||||
expect(parse("text <<<john>>")).toEqual(
|
||||
|
||||
[ { type: 'element', tag: 'p', start: 0, end: 14, children: [ { type: 'text', text: 'text ', start: 0, end: 5 }, { type: 'macrocall', name: '<john', start: 5, params: [ ], end: 14 } ] } ]
|
||||
[{"type":"element","tag":"p","children":[{"type":"text","text":"text ","start":0,"end":5},{"type":"transclude","start":5,"end":14,"attributes":{"$variable":{"name":"$variable","type":"string","value":"<john"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"<john"}]}],"start":0,"end":14}]
|
||||
|
||||
);
|
||||
expect(parse("before\n<<john>>")).toEqual(
|
||||
|
||||
[ { type: 'element', tag: 'p', start: 0, end: 15, children: [ { type: 'text', text: 'before\n', start: 0, end: 7 }, { type: 'macrocall', start: 7, params: [ ], name: 'john', end: 15 } ] } ]
|
||||
[{"type":"element","tag":"p","children":[{"type":"text","text":"before\n","start":0,"end":7},{"type":"transclude","start":7,"end":15,"attributes":{"$variable":{"name":"$variable","type":"string","value":"john"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"john"}]}],"start":0,"end":15}]
|
||||
|
||||
);
|
||||
// A single space will cause it to be inline
|
||||
expect(parse("<<john>> ")).toEqual(
|
||||
|
||||
[ { type: 'element', tag: 'p', start: 0, end: 9, children: [ { type: 'macrocall', start: 0, params: [ ], name: 'john', end: 8 }, { type: 'text', text: ' ', start: 8, end: 9 } ] } ]
|
||||
[{"type":"element","tag":"p","children":[{"type":"transclude","start":0,"end":8,"attributes":{"$variable":{"name":"$variable","type":"string","value":"john"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"john"}]},{"type":"text","text":" ","start":8,"end":9}],"start":0,"end":9}]
|
||||
|
||||
);
|
||||
expect(parse("text <<outie one:'my <<innie>>' >>")).toEqual(
|
||||
|
||||
[ { type: 'element', tag: 'p', start: 0, end: 34, children: [ { type: 'text', text: 'text ', start: 0, end: 5 }, { type: 'macrocall', start: 5, params: [ { type: 'macro-parameter', start: 12, value: 'my <<innie>>', name: 'one', end: 31 } ], name: 'outie', end: 34 } ] } ]
|
||||
[{"type":"element","tag":"p","children":[{"type":"text","text":"text ","start":0,"end":5},{"type":"transclude","start":5,"end":34,"attributes":{"$variable":{"name":"$variable","type":"string","value":"outie"},"one":{"name":"one","type":"string","value":"my <<innie>>","start":12,"end":31}},"orderedAttributes":[{"name":"$variable","type":"string","value":"outie"},{"name":"one","type":"string","value":"my <<innie>>","start":12,"end":31}]}],"start":0,"end":34}]
|
||||
|
||||
);
|
||||
|
||||
@@ -183,37 +247,37 @@ describe("WikiText parser tests", function() {
|
||||
it("should parse block macro calls", function() {
|
||||
expect(parse("<<john>>\n<<paul>>\r\n<<george>>\n<<ringo>>")).toEqual(
|
||||
|
||||
[ { type: 'macrocall', start: 0, name: 'john', params: [ ], end: 8, isBlock: true }, { type: 'macrocall', start: 9, name: 'paul', params: [ ], end: 17, isBlock: true }, { type: 'macrocall', start: 19, name: 'george', params: [ ], end: 29, isBlock: true }, { type: 'macrocall', start: 30, name: 'ringo', params: [ ], end: 39, isBlock: true } ]
|
||||
[ { type: 'transclude', start: 0, attributes: { $variable: { name: "$variable", type: "string", value: "john" }}, orderedAttributes: [ { name: "$variable", type: "string", value: "john" }], end: 8, isBlock: true }, { type: 'transclude', start: 9, attributes: { $variable: { name: "$variable", type: "string", value: "paul" }}, orderedAttributes: [ { name: "$variable", type: "string", value: "paul" }], end: 17, isBlock: true }, { type: 'transclude', start: 19, attributes: { $variable: { name: "$variable", type: "string", value: "george" }}, orderedAttributes: [ { name: "$variable", type: "string", value: "george" }], end: 29, isBlock: true }, { type: 'transclude', start: 30, attributes: { $variable: { name: "$variable", type: "string", value: "ringo" }}, orderedAttributes: [ { name: "$variable", type: "string", value: "ringo" }], end: 39, isBlock: true } ]
|
||||
|
||||
);
|
||||
expect(parse("<<john one:val1 two: 'val \"2\"' three: \"val '3'\" four: \"\"\"val 4\"5'\"\"\" five: [[val 5]] >>")).toEqual(
|
||||
|
||||
[ { type: 'macrocall', start: 0, name: 'john', params: [ { type: 'macro-parameter', start: 6, value: 'val1', name: 'one', end: 15 }, { type: 'macro-parameter', start: 15, value: 'val "2"', name: 'two', end: 30 }, { type: 'macro-parameter', start: 30, value: 'val \'3\'', name: 'three', end: 47 }, { type: 'macro-parameter', start: 47, value: 'val 4"5\'', name: 'four', end: 68 }, { type: 'macro-parameter', start: 68, value: 'val 5', name: 'five', end: 84 }], end: 87, isBlock: true } ]
|
||||
[{"type":"transclude","start":0,"end":87,"attributes":{"$variable":{"name":"$variable","type":"string","value":"john"},"one":{"name":"one","type":"string","value":"val1","start":6,"end":15},"two":{"name":"two","type":"string","value":"val \"2\"","start":15,"end":30},"three":{"name":"three","type":"string","value":"val '3'","start":30,"end":47},"four":{"name":"four","type":"string","value":"val 4\"5'","start":47,"end":68},"five":{"name":"five","type":"string","value":"val 5","start":68,"end":84}},"orderedAttributes":[{"name":"$variable","type":"string","value":"john"},{"name":"one","type":"string","value":"val1","start":6,"end":15},{"name":"two","type":"string","value":"val \"2\"","start":15,"end":30},{"name":"three","type":"string","value":"val '3'","start":30,"end":47},{"name":"four","type":"string","value":"val 4\"5'","start":47,"end":68},{"name":"five","type":"string","value":"val 5","start":68,"end":84}],"isBlock":true}]
|
||||
|
||||
);
|
||||
expect(parse("<< carrots\n\n<<john>>")).toEqual(
|
||||
|
||||
[ { type: 'element', tag: 'p', start : 0, end : 10, children: [ { type: 'text', text: '<< carrots', start : 0, end : 10 } ] }, { type: 'macrocall', start: 12, params: [ ], name: 'john', end: 20, isBlock: true } ]
|
||||
[ { type: 'element', tag: 'p', start : 0, end : 10, children: [ { type: 'text', text: '<< carrots', start : 0, end : 10 } ] }, { type: 'transclude', start: 12, attributes: { $variable: {name: "$variable", type:"string", value: "john"} }, orderedAttributes: [ {name: "$variable", type:"string", value: "john"} ], end: 20, isBlock: true } ]
|
||||
|
||||
);
|
||||
expect(parse("before\n\n<<john>>")).toEqual(
|
||||
|
||||
[ { type: 'element', tag: 'p', start : 0, end : 6, children: [ { type: 'text', text: 'before', start : 0, end : 6 } ] }, { type: 'macrocall', start: 8, name: 'john', params: [ ], end: 16, isBlock: true } ]
|
||||
[ { type: 'element', tag: 'p', start : 0, end : 6, children: [ { type: 'text', text: 'before', start : 0, end : 6 } ] }, { type: 'transclude', start: 8, attributes: { $variable: {name: "$variable", type:"string", value: "john"} }, orderedAttributes: [ {name: "$variable", type:"string", value: "john"} ], end: 16, isBlock: true } ]
|
||||
|
||||
);
|
||||
expect(parse("<<john>>\nafter")).toEqual(
|
||||
|
||||
[ { type: 'macrocall', start: 0, name: 'john', params: [ ], end: 8, isBlock: true }, { type: 'element', tag: 'p', start: 9, end: 14, children: [ { type: 'text', text: 'after', start: 9, end: 14 } ] } ]
|
||||
[ { type: 'transclude', start: 0, attributes: { $variable: {name: "$variable", type:"string", value: "john"} }, orderedAttributes: [ {name: "$variable", type:"string", value: "john"} ], end: 8, isBlock: true }, { type: 'element', tag: 'p', start: 9, end: 14, children: [ { type: 'text', text: 'after', start: 9, end: 14 } ] } ]
|
||||
|
||||
);
|
||||
expect(parse("<<multiline arg:\"\"\"\n\nwikitext\n\"\"\" >>")).toEqual(
|
||||
|
||||
[ { type: 'macrocall', start: 0, params: [ { type: 'macro-parameter', start: 11, value: '\n\nwikitext\n', name: 'arg', end: 33 } ], name: 'multiline', end: 36, isBlock: true }]
|
||||
[{"type":"transclude","start":0,"end":36,"attributes":{"$variable":{"name":"$variable","type":"string","value":"multiline"},"arg":{"name":"arg","type":"string","value":"\n\nwikitext\n","start":11,"end":33}},"orderedAttributes":[{"name":"$variable","type":"string","value":"multiline"},{"name":"arg","type":"string","value":"\n\nwikitext\n","start":11,"end":33}],"isBlock":true}]
|
||||
|
||||
);
|
||||
expect(parse("<<outie one:'my <<innie>>' >>")).toEqual(
|
||||
|
||||
[ { type: 'macrocall', start: 0, params: [ { type: 'macro-parameter', start: 7, value: 'my <<innie>>', name: 'one', end: 26 } ], name: 'outie', end: 29, isBlock: true } ]
|
||||
[ { type: 'transclude', start: 0, attributes: { $variable: {name: "$variable", type:"string", value: "outie"}, one: {name: "one", type:"string", value: "my <<innie>>", start: 7, end: 26} }, orderedAttributes: [ {name: "$variable", type:"string", value: "outie"}, {name: "one", type:"string", value: "my <<innie>>", start: 7, end: 26} ], end: 29, isBlock: true } ]
|
||||
|
||||
);
|
||||
});
|
||||
@@ -221,23 +285,23 @@ describe("WikiText parser tests", function() {
|
||||
it("should parse tricky macrocall parameters", function() {
|
||||
expect(parse("<<john pa>am>>")).toEqual(
|
||||
|
||||
[ { type: 'macrocall', start: 0, params: [ { type: 'macro-parameter', start: 6, value: 'pa>am', end: 12 } ], name: 'john', end: 14, isBlock: true } ]
|
||||
[{"type":"transclude","start":0,"end":14,"attributes":{"0":{"name":"0","type":"string","value":"pa>am","start":6,"end":12},"$variable":{"name":"$variable","type":"string","value":"john"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"john"},{"name":"0","type":"string","value":"pa>am","start":6,"end":12}],"isBlock":true}]
|
||||
|
||||
);
|
||||
expect(parse("<<john param> >>")).toEqual(
|
||||
|
||||
[ { type: 'macrocall', start: 0, params: [ { type: 'macro-parameter', start: 6, value: 'param>', end: 13 } ], name: 'john', end: 16, isBlock: true } ]
|
||||
[{"type":"transclude","start":0,"end":16,"attributes":{"0":{"name":"0","type":"string","value":"param>","start":6,"end":13},"$variable":{"name":"$variable","type":"string","value":"john"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"john"},{"name":"0","type":"string","value":"param>","start":6,"end":13}],"isBlock":true}]
|
||||
|
||||
);
|
||||
expect(parse("<<john param>>>")).toEqual(
|
||||
|
||||
[ { type: 'element', tag: 'p', start: 0, end: 15, children: [ { type: 'macrocall', start: 0, params: [ { type: 'macro-parameter', start: 6, value: 'param', end: 12 } ], name: 'john', end: 14 }, { type: 'text', text: '>', start: 14, end: 15 } ] } ]
|
||||
[{"type":"element","tag":"p","children":[{"type":"transclude","start":0,"end":14,"attributes":{"0":{"name":"0","type":"string","value":"param","start":6,"end":12},"$variable":{"name":"$variable","type":"string","value":"john"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"john"},{"name":"0","type":"string","value":"param","start":6,"end":12}]},{"type":"text","text":">","start":14,"end":15}],"start":0,"end":15}]
|
||||
|
||||
);
|
||||
// equals signs should be allowed
|
||||
expect(parse("<<john var>=4 >>")).toEqual(
|
||||
|
||||
[ { type: 'macrocall', start: 0, params: [ { type: 'macro-parameter', start: 6, value: 'var>=4', end: 13 } ], name: 'john', end: 16, isBlock: true } ]
|
||||
[{"type":"transclude","start":0,"end":16,"attributes":{"0":{"name":"0","type":"string","value":"var>=4","start":6,"end":13},"$variable":{"name":"$variable","type":"string","value":"john"}},"orderedAttributes":[{"name":"$variable","type":"string","value":"john"},{"name":"0","type":"string","value":"var>=4","start":6,"end":13}],"isBlock":true}]
|
||||
|
||||
);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*\
|
||||
title: test-wikitext-tabs-macro.js
|
||||
type: application/javascript
|
||||
tags: [[$:/tags/test-spec]]
|
||||
tags: [[$:/tags/test-spec-disabled]]
|
||||
|
||||
Tests the core tabs macro by comparing the HTML output with a stored template.
|
||||
Intended to permit future readability improvements.
|
||||
@@ -74,7 +74,7 @@ describe("Tabs-macro HTML tests", function() {
|
||||
expect(wiki.renderTiddler("text/html","test-tabs-macro-horizontal")).toBe(expected.fields.text.replace(/\n/g,""));
|
||||
});
|
||||
|
||||
it("should render 'horizontal' tabs from v5.2.2 and up with whitespace trim", function() {
|
||||
it("should render all 'horizontal' tabs from v5.2.2 and up with whitespace trim", function() {
|
||||
expect(wiki.renderTiddler("text/html","test-tabs-macro-horizontal-all")).toBe(expectedAll.fields.text.replace(/\n/g,""));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user