mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-04-01 00:06:55 +00:00
Provide examples for the wikify widget (#8792)
* Provide examples for the wikify widget * fix a typo in the wikify widget doc tiddler * Update and rename TestCases_WikifyWidget_WidgetInput_Fail.tid to TestCases_WikifyWidget_WidgetValue_Fail.tid * Update and rename TestCases_WikifyWidget_WidgetInput_Success.tid to TestCases_WikifyWidget_WidgetValue_Success.tid * Update WikifyWidget.tid * Update TestCases_WikifyWidget_WidgetValue_Fail.tid * Update TestCases_WikifyWidget_WidgetValue_Success.tid * Update WikifyWidget.tid * Update TestCases_WikifyWidget_WidgetValue_Success.tid fix small error causing validation to fail * Update TestCases_WikifyWidget_WidgetValue_Success.tid * remove trailing end line * remove trailing new line * add description, remove modified field
This commit is contained in:
parent
c7b45a3eb0
commit
106fe2dfb9
@ -0,0 +1,28 @@
|
||||
created: 20241201235747500
|
||||
description: Exporting rendered html
|
||||
tags: $:/tags/wiki-test-spec
|
||||
title: TestCases/WikifyWidget/RenderHTML
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
|
||||
title: Narrative
|
||||
|
||||
You can use <<.wid wikify>> to copy your wikitext as a formated HTML.
|
||||
+
|
||||
title: Output
|
||||
|
||||
<$wikify name="code" text={{code}} output="html">
|
||||
|
||||
<$codeblock code=<<code>> />
|
||||
|
||||
<$macrocall $name="copy-to-clipboard" src=<<code>>/>
|
||||
|
||||
</$wikify>
|
||||
+
|
||||
title: code
|
||||
text:
|
||||
|
||||
!! A nice list
|
||||
|
||||
* Item 1
|
||||
* Item 2
|
||||
* Item 3
|
@ -0,0 +1,33 @@
|
||||
created: 20241202000005087
|
||||
description: Using a widget as a value
|
||||
tags: $:/tags/wiki-test-spec-failing
|
||||
title: TestCases/WikifyWidget/WidgetValue/Fail
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
|
||||
title: Narrative
|
||||
|
||||
If you try to directly use a widget as a value, you will instead get the raw wikitext of the widget and not the rendered value.
|
||||
+
|
||||
title: Output
|
||||
|
||||
<span style.color={{widget}} style.background={{target}}>
|
||||
{{widget}} text on {{target}} is a good contrast
|
||||
</span>
|
||||
+
|
||||
title: widget
|
||||
text: <$transclude $variable="contrastcolour" target={{target}} fallbackTarget=<<fallbackTarget>> colourA={{colourA}} colourB={{colourB}} />
|
||||
+
|
||||
title: target
|
||||
text: purple
|
||||
+
|
||||
title: colourA
|
||||
text: white
|
||||
+
|
||||
title: colourB
|
||||
text: black
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p><span style="color:white<$transclude $variable="contrastcolour" target={{target}} fallbackTarget=<<fallbackTarget>> colourA={{colourA}} colourB={{colourB}} />;background:purple;">
|
||||
white text on purple is a good contrast
|
||||
</span></p>
|
@ -0,0 +1,43 @@
|
||||
created: 20241202003148804
|
||||
description: Using a widget as a value
|
||||
tags: $:/tags/wiki-test-spec
|
||||
title: TestCases/WikifyWidget/WidgetValue/Success
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
|
||||
title: Narrative
|
||||
|
||||
If you use <<.wid wikify>>, you can get the rendered output and use it as a value.
|
||||
+
|
||||
title: Output
|
||||
|
||||
<$wikify name="wikified-color" text={{widget}} >
|
||||
<span style.color=<<wikified-color>> style.background={{target}}>
|
||||
{{widget}} text on {{target}} is a good contrast
|
||||
</span>
|
||||
</$wikify>
|
||||
+
|
||||
title: widget
|
||||
|
||||
<$transclude $variable="contrastcolour"
|
||||
target={{target}}
|
||||
fallbackTarget=<<fallbackTarget>>
|
||||
colourA={{colourA}}
|
||||
colourB={{colourB}}
|
||||
/>
|
||||
+
|
||||
title: target
|
||||
text: purple
|
||||
+
|
||||
title: colourA
|
||||
text: white
|
||||
+
|
||||
title: colourB
|
||||
text: black
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>
|
||||
<span style="color:white;background:purple;">
|
||||
white text on purple is a good contrast
|
||||
</span>
|
||||
</p>
|
@ -0,0 +1,19 @@
|
||||
created: 20241201235746062
|
||||
description: Accurate word count
|
||||
tags: $:/tags/wiki-test-spec-failing
|
||||
title: TestCases/WikifyWidget/WordCount/Fail
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
|
||||
title: Narrative
|
||||
|
||||
If a tiddler transclude some content, or use widgets to generate content, filters that try to calculate the word count won’t be accurate: they will instead count the raw text words.
|
||||
+
|
||||
title: Output
|
||||
|
||||
Word count = <$count filter="[{lorem}split[ ]!is[blank]]"/>
|
||||
+
|
||||
title: lorem
|
||||
text: <$list filter="[range[1],[3]]"><$text text=" word "/></$list>
|
||||
+
|
||||
title: ExpectedResult
|
||||
text: <p>Word count = 3</p>
|
@ -0,0 +1,19 @@
|
||||
created: 20241202011409888
|
||||
description: Accurate word count
|
||||
tags: $:/tags/wiki-test-spec
|
||||
title: TestCases/WikifyWidget/WordCount/Success
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
|
||||
title: Narrative
|
||||
|
||||
If you use wikify, you can calculate an accurate word count.
|
||||
+
|
||||
title: Output
|
||||
|
||||
<$wikify name="lorem" text={{lorem}} output="text">Word count = <$count filter="[<lorem>split[ ]!is[blank]]"/></$wikify>
|
||||
+
|
||||
title: lorem
|
||||
text: <$list filter="[range[1],[3]]"><$text text=" word "/></$list>
|
||||
+
|
||||
title: ExpectedResult
|
||||
text: <p>Word count = 3</p>
|
@ -1,13 +1,13 @@
|
||||
caption: wikify
|
||||
created: 20160321144949700
|
||||
modified: 20220122191540121
|
||||
modified: 20241202014354100
|
||||
tags: Widgets
|
||||
title: WikifyWidget
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
! Introduction
|
||||
|
||||
The wikify widget parses and renders a string of text and assigns the result to a specified [[variable|Variables]]. The new value of the variable is available to the content within the wikify widget.
|
||||
The <<.wid wikify>> widget parses and renders a string of text and assigns the result to a specified [[variable|Variables]]. The new value of the variable is available to the content within the wikify widget.
|
||||
|
||||
! Content and Attributes
|
||||
|
||||
@ -28,3 +28,19 @@ The available output types are:
|
||||
|html |Return the rendered HTML of the output |
|
||||
|parsetree |Return a formatted JSON representation of the parse tree |
|
||||
|widgettree |Return a formatted JSON representation of the widget tree |
|
||||
|
||||
! Examples
|
||||
|
||||
!! Using a widget as a value
|
||||
|
||||
<<testcase "TestCases/WikifyWidget/WidgetValue/Success">>
|
||||
<<testcase "TestCases/WikifyWidget/WidgetValue/Fail">>
|
||||
|
||||
!! Accurate word count
|
||||
|
||||
<<testcase "TestCases/WikifyWidget/WordCount/Success">>
|
||||
<<testcase "TestCases/WikifyWidget/WordCount/Fail">>
|
||||
|
||||
!! Exporting rendered html
|
||||
|
||||
<<testcase "TestCases/WikifyWidget/RenderHTML">>
|
||||
|
Loading…
x
Reference in New Issue
Block a user