2016-02-15 12:02:37 +00:00
|
|
|
title: $:/plugins/tiddlywiki/internals/EditTemplate/body/preview/parse-tree
|
2016-02-15 11:38:55 +00:00
|
|
|
tags: $:/tags/EditPreview
|
2016-02-15 12:02:37 +00:00
|
|
|
list-after: $:/core/ui/EditTemplate/body/preview/output
|
2016-02-15 11:38:55 +00:00
|
|
|
caption: parse tree
|
|
|
|
|
2022-05-23 15:32:19 +00:00
|
|
|
\whitespace trim
|
|
|
|
|
2022-05-23 09:24:51 +00:00
|
|
|
\procedure preview-node-properties(node)
|
|
|
|
<$let excludeProperties="text type tag children attributes orderedAttributes">
|
|
|
|
<$list filter="[<node>jsonindexes[]] -[subfilter<excludeProperties>] +[limit[1]]" variable="ignore">
|
|
|
|
<table>
|
|
|
|
<tbody>
|
|
|
|
<$list filter="[<node>jsonindexes[]] -[subfilter<excludeProperties>] +[sort[]]" variable="index">
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<$text text=<<index>>/>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<$text text={{{ [<node>jsonget<index>] }}}/>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</$list>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</$list>
|
|
|
|
</$let>
|
|
|
|
\end
|
|
|
|
|
|
|
|
\procedure preview-node-attribute-string(attribute)
|
|
|
|
<$text text={{{ [<attribute>jsonget[value]] }}}/>
|
|
|
|
\end
|
|
|
|
|
|
|
|
\procedure preview-node-attribute-indirect(attribute)
|
|
|
|
{{<$text text={{{ [<attribute>jsonget[textReference]] }}}/>}}
|
|
|
|
\end
|
|
|
|
|
|
|
|
\procedure preview-node-attribute-macro(attribute)
|
|
|
|
<<
|
|
|
|
<$text text={{{ [<attribute>jsonget[value],[name]] }}}/>
|
|
|
|
<$list filter="[<attribute>jsonindexes[value],[params]]" variable="index">
|
|
|
|
|
|
|
|
<$list filter="[<attribute>jsonget[value],[params],<index>,[name]]" variable="ignore">
|
|
|
|
<$text text={{{ [<attribute>jsonget[value],[params],<index>,[name]] }}}/>
|
|
|
|
:
|
|
|
|
</$list>
|
|
|
|
<$text text={{{ [<attribute>jsonget[value],[params],<index>,[value]] }}}/>
|
|
|
|
</$list>
|
|
|
|
>>
|
|
|
|
\end
|
|
|
|
|
|
|
|
\procedure preview-node-attributes(node)
|
|
|
|
<$list filter="[<node>jsonindexes[attributes]limit[1]]" variable="ignore">
|
|
|
|
<table>
|
|
|
|
<tbody>
|
|
|
|
<$list filter="[<node>jsonindexes[attributes]sort[]]" variable="index">
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<$text text=<<index>>/>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<$let type={{{ [<node>jsonget[attributes],<index>,[type]] }}}>
|
|
|
|
<$transclude $variable={{{ [<type>match[string]then[preview-node-attribute-string]] :else[<type>match[indirect]then[preview-node-attribute-indirect]] :else[<type>match[macro]then[preview-node-attribute-macro]] }}} attribute={{{ [<node>jsonextract[attributes],<index>] }}}/>
|
|
|
|
</$let>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</$list>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</$list>
|
|
|
|
\end
|
|
|
|
|
|
|
|
\procedure preview-node-children(node)
|
|
|
|
<div style="padding:4px 4px 0 4px;">
|
|
|
|
<$transclude $variable="preview-node-properties" node=<<node>>/>
|
|
|
|
<$transclude $variable="preview-node-attributes" node=<<node>>/>
|
|
|
|
<$transclude $variable="preview-node-list" nodeList={{{ [<node>jsonextract[children]] }}}/>
|
|
|
|
</div>
|
|
|
|
\end
|
|
|
|
|
|
|
|
\procedure preview-node-title-widget(node)
|
|
|
|
<div style="border:2px solid red;margin:4px;">
|
|
|
|
<div style="background:red;color:white;padding:4px;">
|
|
|
|
<$<$text text={{{ [<node>jsonget[type]] }}}/>>
|
|
|
|
</div>
|
|
|
|
<$transclude $variable="preview-node-children" node=<<node>>/>
|
|
|
|
</div>
|
|
|
|
\end
|
|
|
|
|
|
|
|
\procedure preview-node-title-element(node)
|
|
|
|
<div style="border:2px solid purple;margin:4px;">
|
|
|
|
<div style="background:purple;color:white;padding:4px;">
|
|
|
|
<<$text text={{{ [<node>jsonget[tag]] }}}/>>
|
|
|
|
</div>
|
|
|
|
<$transclude $variable="preview-node-children" node=<<node>>/>
|
|
|
|
</div>
|
|
|
|
\end
|
|
|
|
|
|
|
|
\procedure preview-node-title-text(node)
|
|
|
|
<div style="border:2px solid green;margin:4px;">
|
|
|
|
<div style="background:green;color:white;padding:4px;">
|
|
|
|
<span style="color:#ff0;font-weight:bold;">"</span><span style="white-space:pre-wrap;"><$text text={{{ [<node>jsonget[text]] }}}/></span><span style="color:#ff0;font-weight:bold;">"</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
\end
|
|
|
|
|
|
|
|
\procedure preview-node(node)
|
|
|
|
<$let type={{{ [<node>jsonget[type]] }}}>
|
|
|
|
<$transclude $variable={{{ [<type>match[element]then[preview-node-title-element]] :else[<type>match[text]then[preview-node-title-text]] :else[[preview-node-title-widget]] }}} node=<<node>>/>
|
|
|
|
</$let>
|
|
|
|
\end
|
|
|
|
|
|
|
|
\procedure preview-node-list(nodeList)
|
|
|
|
<$list filter="[<nodeList>jsonindexes[]]" variable="index">
|
|
|
|
<$transclude $variable="preview-node" node={{{ [<nodeList>jsonextract<index>] }}}/>
|
|
|
|
</$list>
|
|
|
|
\end
|
|
|
|
|
|
|
|
\procedure preview(mode)
|
|
|
|
<$wikify name="preview-json" text={{!!text}} type={{!!type}} mode=<<mode>> output="parsetree">
|
|
|
|
<$transclude $variable="preview-node-list" nodeList=<<preview-json>>/>
|
2016-04-22 07:36:29 +00:00
|
|
|
</$wikify>
|
2016-02-15 11:38:55 +00:00
|
|
|
\end
|
|
|
|
|
2016-02-15 12:02:37 +00:00
|
|
|
{{||$:/plugins/tiddlywiki/internals/EditTemplate/body/preview/shared}}
|