1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-08-24 22:52:24 +00:00

doc-macros -- fix .example macro and wikitext-macros nw syntax

This commit is contained in:
pmario 2024-02-18 00:57:00 +01:00
parent 7d90d0fcc0
commit e10737f467
2 changed files with 78 additions and 94 deletions

View File

@ -2,22 +2,20 @@ created: 20150117152607000
modified: 20230325141733992 modified: 20230325141733992
tags: $:/tags/Macro tags: $:/tags/Macro
title: $:/editions/tw5.com/doc-macros title: $:/editions/tw5.com/doc-macros
code-body: yes
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
\whitespace trim \whitespace trim
\function .concat(1,2,3,4,5) [[$(1)$$(2)$$(3)$$(4)$$(5)$]substitute[]] \function .concat(1,2,3,4,5) [[$(1)$$(2)$$(3)$$(4)$$(5)$]substitute[]]
\function .word(_) [["]] [<_>] =[["]] +[join[]]
\procedure .def(_) <dfn class="doc-def"><<_>></dfn> \procedure .def(_) <dfn class="doc-def"><<_>></dfn>
\procedure .em(_) <em class="doc-em"><<_>></em> \procedure .em(_) <em class="doc-em"><<_>></em>
\procedure .strong(_) <strong class="doc-strong"><<_>></strong> \procedure .strong(_) <strong class="doc-strong"><<_>></strong>
\procedure .place(_) <code class="doc-place"><<_>></code> \procedure .place(_) <code class="doc-place"><<_>></code>
\function .word(_) [["]] [<_>] =[["]] +[join[]]
\procedure .preamble(_) <dl><dd class="doc-preamble"><<_>></dd></dl> \procedure .preamble(_) <dl><dd class="doc-preamble"><<_>></dd></dl>
<!-- Replaced by a new .note box with icon. Notes should _not_ be definition lists --> <!-- Replaced by a new .note box with icon. Notes should _not_ be definition lists -->
<!-- For HTML that's semantically wrong --> <!-- For HTML that's semantically wrong -->
\procedure .note(_) \procedure .note(_)
@ -160,16 +158,16 @@ This is an example tiddler. See [[Table-of-Contents Macros (Examples)]].
\procedure .example(n,eg,egvar:NO-SUCH-VAR) \procedure .example(n,eg,egvar:NO-SUCH-VAR)
<div class="doc-example"> <div class="doc-example">
<$reveal default="$egvar$" type="match" text="NO-SUCH-VAR"> <$reveal default=<<egvar>> type="match" text="NO-SUCH-VAR">
<$macrocall $name="copy-to-clipboard-above-right" src="""$eg$"""/> <$macrocall $name="copy-to-clipboard-above-right" src=<<eg>/>
<$codeblock code="""$eg$"""/> <$codeblock code=<<eg>>/>
</$reveal> </$reveal>
<$reveal default="$egvar$" type="nomatch" text="NO-SUCH-VAR"> <$reveal default=<<egvar>> type="nomatch" text="NO-SUCH-VAR">
<!-- allow an example to contain """ --> <!-- allow an example to contain """ -->
<$macrocall $name="copy-to-clipboard-above-right" src=<<$egvar$>>/> <$macrocall $name="copy-to-clipboard-above-right" src=<<egvar>>/>
<$codeblock code=<<$egvar$>>/> <$codeblock code=<<egvar>>/>
</$reveal> </$reveal>
<$list filter="[title<.state-prefix>addsuffix{!!title}addsuffix[/]addsuffix[$n$]]" variable=".state"> <$list filter=`[title<.state-prefix>addsuffix{!!title}addsuffix[/]addsuffix[$(n)$]]` variable=".state">
<$reveal state=<<.state>> type="nomatch" text="show"> <$reveal state=<<.state>> type="nomatch" text="show">
<dl> <dl>
<dd><$button set=<<.state>> setTo="show">Try it</$button></dd> <dd><$button set=<<.state>> setTo="show">Try it</$button></dd>
@ -180,15 +178,15 @@ This is an example tiddler. See [[Table-of-Contents Macros (Examples)]].
<dd><$button set=<<.state>> setTo="">Hide</$button></dd> <dd><$button set=<<.state>> setTo="">Hide</$button></dd>
</dl> </dl>
<blockquote class="doc-example-result"> <blockquote class="doc-example-result">
<$reveal default="$egvar$" type="match" text="NO-SUCH-VAR"> <$reveal default=<<egvar>> type="match" text="NO-SUCH-VAR">
$$$text/vnd.tiddlywiki $$$text/vnd.tiddlywiki
$eg$ <<eg>>
$$$ $$$
</$reveal> </$reveal>
<$reveal default="$egvar$" type="nomatch" text="NO-SUCH-VAR"> <$reveal default=<<egvar>> type="nomatch" text="NO-SUCH-VAR">
<<$egvar$>> <<egvar>>
</$reveal> </$reveal>
</blockquote> </blockquote>
</$reveal> </$reveal>
@ -202,7 +200,7 @@ $$$
<td><span style="font-size:1.5em;">&#9888;</span> Warning:<br> Don't do it this way!</td> <td><span style="font-size:1.5em;">&#9888;</span> Warning:<br> Don't do it this way!</td>
<td> <td>
$eg$ <<eg>>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -210,28 +208,26 @@ $eg$
\end \end
\procedure .link-badge(text,link,colour) \procedure .link-badge(text,link,colour)
<a href=<<link>> class="doc-link-badge" style="background-color:$colour$;" target="_blank" rel="noopener noreferrer"><$text text=<<text>>/></a> <a href=<<link>> class="doc-link-badge" style.background-color=<<colour>> target="_blank" rel="noopener noreferrer"><$text text=<<text>>/></a>
\end \end
<!-- TODO use $:/palette colour settings -->
\procedure .link-badge-added(link,colour:#ffe246) <<.link-badge "added" """$link$""" """$colour$""">> \procedure .link-badge-added(link,colour:#ffe246) <$macrocall $name=".link-badge" text="added" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-addendum(link,colour:#fcc84a) <<.link-badge "addendum" """$link$""" """$colour$""">> \procedure .link-badge-addendum(link,colour:#fcc84a) <$macrocall $name=".link-badge" text="addendum" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-extended(link,colour:#f9a344) <<.link-badge "extended" """$link$""" """$colour$""">> \procedure .link-badge-extended(link,colour:#f9a344) <$macrocall $name=".link-badge" text="extended" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-fixed(link,colour:#ffa86d) <<.link-badge "fixed" """$link$""" """$colour$""">> \procedure .link-badge-fixed(link,colour:#ffa86d) <$macrocall $name=".link-badge" text="fixed" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-here(link,colour:#d88e63) <<.link-badge "here" """$link$""" """$colour$""">> \procedure .link-badge-here(link,colour:#d88e63) <$macrocall $name=".link-badge" text="here" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-hide(link,colour:#9d959f) <<.link-badge "hide" """$link$""" """$colour$""">> \procedure .link-badge-hide(link,colour:#9d959f) <$macrocall $name=".link-badge" text="hide" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-improved(link,colour:#7593c7) <<.link-badge "improved" """$link$""" """$colour$""">> \procedure .link-badge-improved(link,colour:#7593c7) <$macrocall $name=".link-badge" text="improved" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-modified(link,colour:#7f99c9) <<.link-badge "modified" """$link$""" """$colour$""">> \procedure .link-badge-modified(link,colour:#7f99c9) <$macrocall $name=".link-badge" text="modified" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-removed(link,colour:#a9aabc) <<.link-badge "removed" """$link$""" """$colour$""">> \procedure .link-badge-removed(link,colour:#a9aabc) <$macrocall $name=".link-badge" text="removed" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-renamed(link,colour:#b4b995) <<.link-badge "renamed" """$link$""" """$colour$""">> \procedure .link-badge-renamed(link,colour:#b4b995) <$macrocall $name=".link-badge" text="renamed" link=<<link>> colour=<<colour>>/>
\procedure .link-badge-updated(link,colour:#91ba66) <<.link-badge "updated" """$link$""" """$colour$""">> \procedure .link-badge-updated(link,colour:#91ba66) <$macrocall $name=".link-badge" text="updated" link=<<link>> colour=<<colour>>/>
\procedure .banner-credits(credit,url) \procedure .banner-credits(credit,url)
<img src=<<url>> width="140" style="float:left;margin-right:0.5em;"/> <img src=<<url>> width="140" style="float:left;margin-right:0.5em;"/>
$credit$ <<credit>>
<div style="clear:both;"> <div style="clear:both;">
@ -247,5 +243,3 @@ $credit$
</$list> </$list>
</ol> </ol>
\end \end
<pre><$view field="text"/></pre>

View File

@ -5,100 +5,90 @@ tags: $:/tags/Macro
title: $:/editions/tw5.com/wikitext-macros title: $:/editions/tw5.com/wikitext-macros
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
\define activatePluginTab() \whitespace trim
\procedure activatePluginTab()
<$action-setfield $tiddler="$:/state/tab-1749438307" text="$:/core/ui/ControlPanel/Plugins"/> <$action-setfield $tiddler="$:/state/tab-1749438307" text="$:/core/ui/ControlPanel/Plugins"/>
<$action-navigate $to="$:/ControlPanel"/> <$action-navigate $to="$:/ControlPanel"/>
\end \end
\define activateTiddlerWindow() \procedure activateTiddlerWindow()
<$action-sendmessage $message="tm-open-window" <$action-sendmessage $message="tm-open-window" $param=<<currentTiddler>> windowTitle="Side by Side View" width="800" height="600" />
$param=<<currentTiddler>> windowTitle="Side by Side View"
width="800" height="600" />
\end \end
\define controlPanel-plugin-link() \procedure controlPanel-plugin-link()
<$button actions=<<activatePluginTab>> class="tc-btn-invisible tc-tiddlylink"> <$button actions=<<activatePluginTab>> class="tc-btn-invisible tc-tiddlylink">
{{$:/core/images/options-button}} ~ControlPanel {{$:/core/images/options-button}} ~ControlPanel
</$button> </$button>
\end \end
\define open-tiddler-in-window() \procedure open-tiddler-in-window()
<$button actions=<<activateTiddlerWindow>> class="tc-btn-invisible tc-tiddlylink"> <$button actions=<<activateTiddlerWindow>> class="tc-btn-invisible tc-tiddlylink">
open ''this'' tiddler in a new window open ''this'' tiddler in a new window
</$button> </$button>
\end \end
\define activateEditionWindow(url) \procedure activateEditionWindow(url)
<$action-sendmessage $message="tm-open-external-window" <$action-sendmessage $message="tm-open-external-window" $param="""$url$""" windowName="_edition" windowFeatures="width=800 height=600" />
$param="""$url$""" windowName="_edition"
windowFeatures="width=800 height=600" />
\end \end
\define open-external-window(url) \procedure open-external-window(url)
<$button actions=<<activateEditionWindow """$url$""">> class="tc-btn-invisible tc-tiddlylink"> <$button actions=<<activateEditionWindow """$url$""">> class="tc-btn-invisible tc-tiddlylink">
open the ''example edition'' in a new window open the ''example edition'' in a new window
</$button> </$button>
\end \end
\define wikitext-example(src) \procedure wikitext-example(src)
<div class="doc-example"> <div class="doc-example">
<$macrocall $name="copy-to-clipboard-above-right" src=<<src>>/>
<$macrocall $name="copy-to-clipboard-above-right" src=<<__src__>>/> <$codeblock code=<<src>>/>
<p>
<$codeblock code=<<__src__>>/> That renders as:
</p>
That renders as: <$transclude $variable="src" $mode="block"/>
<p>
<$macrocall $name="__src__"/> ... and the underlying HTML is:
</p>
... and the underlying HTML is: <$wikify name="html" text=<<src>> output="html">
<$codeblock code=<<html>>/>
<$wikify name="html" text=<<__src__>> output="html"> </$wikify>
<$codeblock code=<<html>>/>
</$wikify>
</div> </div>
\end \end
\define wikitext-example-without-html(src) \procedure wikitext-example-without-html(src)
<div class="doc-example"> <div class="doc-example">
<$macrocall $name="copy-to-clipboard-above-right" src=<<src>>/>
<$macrocall $name="copy-to-clipboard-above-right" src=<<__src__>>/> <$codeblock code=<<src>>/>
<p>
<$codeblock code=<<__src__>>/> That renders as:
</p>
That renders as: <$macrocall $name="src"/>
<$macrocall $name="__src__"/>
</div> </div>
\end \end
\define wikitext-example-table-header() <thead><tr><th/><th>wiki text</th><th>renders as</th></tr></thead> \procedure wikitext-example-table-header() <thead><tr><th/><th>wiki text</th><th>renders as</th></tr></thead>
\define wikitext-example-table-row(id, code) \procedure wikitext-example-table-row(id, code)
<tr> <tr>
<th><<__id__>></th><td><$codeblock code=<<__code__>>/></td><td> <th><<id>></th>
<td><$codeblock code=<<code>>/></td>
<<__code__>> <td><<code>></td>
</td>
</tr> </tr>
\end \end
\define tw-code(tiddler) \procedure tw-code(tiddler)
<$codeblock language={{$tiddler$!!type}} code={{$tiddler$}}/> <$codeblock language={{$tiddler$!!type}} code={{$tiddler$}}/>
\end \end
\define tw-code-link(tiddler) \procedure tw-code-link(tiddler)
[[$tiddler$]]: [[$tiddler$]]:
<<tw-code $tiddler$>> <<tw-code $tiddler$>>
\end \end
\define flex-card(class,bordercolor:"",backgroundcolor:"",textcolor:"",imageField:"image",captionField:"caption",subtitle:"",descriptionField:"description",linkField:"link") \procedure flex-card(class,bordercolor:"",backgroundcolor:"",textcolor:"",imageField:"image",captionField:"caption",subtitle:"",descriptionField:"description", inkField:"link")
\whitespace trim <$link class={{{ [<class>addprefix[tc-card ]] }}} to={{{ [<currentTiddler>get<linkField>else<currentTiddler>] }}}>
<$link class={{{ [<__class__>addprefix[tc-card ]] }}} to={{{ [<currentTiddler>get<__linkField__>else<currentTiddler>] }}}> <div class="tc-card-accent" style.borderTop={{{ [<bordercolor>!is[blank]addprefix[5px solid ]] }}} style.background={{!!background}} style.backgroundColor=<<backgroundcolor>> style.color=<<textcolor>> style.fill=<<textcolor>>>
<div class="tc-card-accent" style.borderTop={{{ [<__bordercolor__>!is[blank]addprefix[5px solid ]] }}} style.background={{!!background}} style.backgroundColor=<<__backgroundcolor__>> style.color=<<__textcolor__>> style.fill=<<__textcolor__>>>
<$list filter="[<currentTiddler>has[ribbon-text]]" variable="ignore"> <$list filter="[<currentTiddler>has[ribbon-text]]" variable="ignore">
<div class="tc-card-ribbon-wrapper"> <div class="tc-card-ribbon-wrapper">
<div class="tc-card-ribbon" style.backgroundColor={{{ [<currentTiddler>get[ribbon-color]else[red]] }}}> <div class="tc-card-ribbon" style.backgroundColor={{{ [<currentTiddler>get[ribbon-color]else[red]] }}}>
@ -108,21 +98,21 @@ That renders as:
</div> </div>
</div> </div>
</$list> </$list>
<$list filter="[<currentTiddler>has<__imageField__>]" variable="ignore"> <$list filter="[<currentTiddler>has<imageField>]" variable="ignore">
<div class="tc-card-image"> <div class="tc-card-image">
<$image source={{{ [<currentTiddler>get<__imageField__>] }}}/> <$image source={{{ [<currentTiddler>get<imageField>] }}}/>
</div> </div>
</$list> </$list>
<div class="tc-card-title"><$transclude field=<<__captionField__>>><$view field="title"/></$transclude></div> <div class="tc-card-title"><$transclude field=<<captionField>>><$view field="title"/></$transclude></div>
<$list filter="[<__subtitle__>!is[blank]]" variable="ignore"> <$list filter="[<subtitle>!is[blank]]" variable="ignore">
<div class="tc-card-subtitle"> <div class="tc-card-subtitle">
<$text text=<<__subtitle__>>/> <$text text=<<subtitle>>/>
</div> </div>
</$list> </$list>
<div class="tc-card-icon"><$transclude tiddler={{!!icon}}/></div> <div class="tc-card-icon"><$transclude tiddler={{!!icon}}/></div>
<div class="tc-card-body-wrapper"> <div class="tc-card-body-wrapper">
<div class="tc-card-body"> <div class="tc-card-body">
<$transclude field=<<__descriptionField__>> mode="block"/> <$transclude field=<<descriptionField>> mode="block"/>
</div> </div>
<div class="tc-card-body-clear"> <div class="tc-card-body-clear">
</div> </div>