-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
c7b45a3
commit 106fe2d
Showing
6 changed files
with
160 additions
and
2 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
editions/tw5.com/tiddlers/TestCases_WikifyWidget_RenderHTML.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
33 changes: 33 additions & 0 deletions
33
editions/tw5.com/tiddlers/TestCases_WikifyWidget_WidgetValue_Fail.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
43 changes: 43 additions & 0 deletions
43
editions/tw5.com/tiddlers/TestCases_WikifyWidget_WidgetValue_Success.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
19 changes: 19 additions & 0 deletions
19
editions/tw5.com/tiddlers/TestCases_WikifyWidget_WordCount_Fail.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
19 changes: 19 additions & 0 deletions
19
editions/tw5.com/tiddlers/TestCases_WikifyWidget_WordCount_Success.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters