This page is part of a static HTML representation of the TiddlyWiki at https://tiddlywiki.com/

WikifyWidget

6th December 2024 at 11:33pm

Introduction

The $wikify widget parses and renders a string of text and assigns the result to a specified variable. The new value of the variable is available to the content within the $wikify widget.

Content and Attributes

The content of the $wikify widget is the scope for the value assigned to the variable.

AttributeDescription
nameThe name of the variable to assign
textThe text to parse and render
typeThe ContentType of the text (defaults to text/vnd.tiddlywiki)
modeThe parse mode: block (the default) or inline
outputKeyword indicating the desired output type, defaulting to text (see below)

The available output types are:

KeywordDescription
textReturn the plain text of the rendered output (ie HTML tags are omitted)
formattedtextReturn the plain text with simple text formatting of the rendered output (ie HTML tags are omitted)
htmlReturn the rendered HTML of the output
parsetreeReturn a formatted JSON representation of the parse tree
widgettreeReturn a formatted JSON representation of the widget tree

Examples

Using a widget as a value

If you use $wikify, you can get the rendered output and use it as a value.

titleOutput

white text on purple is a good contrast

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.

TEST FAILED
1 differences
<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>
titleOutput

> colourA={{colourA}} colourB={{colourB}} />;background:purple;"> white text on purple is a good contrast

Accurate word count

If you use wikify, you can calculate an accurate word count.

titleOutput

Word count = 3

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.

TEST FAILED
2 differences
<p>Word count = 35</p>
titleOutput

Word count = 5

Exporting rendered html

You can use $wikify to copy your wikitext as a formated HTML.

titleOutput
<h2 class="">A nice list</h2><ul><li>Item 1</li><li>Item 2</li><li>Item 3</li></ul>

Rendering parameterised SVG for use in stylesheets

The core svg icons use a parameter widget, making their use in stylesheets impossible without wikify.

titleOutput