mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-30 13:29:56 +00:00
Revert changes to parse tree preview
This implementation requires #6666
This commit is contained in:
parent
15ea3ffa9a
commit
389330436d
@ -3,121 +3,13 @@ tags: $:/tags/EditPreview
|
|||||||
list-after: $:/core/ui/EditTemplate/body/preview/output
|
list-after: $:/core/ui/EditTemplate/body/preview/output
|
||||||
caption: parse tree
|
caption: parse tree
|
||||||
|
|
||||||
\whitespace trim
|
\define preview(mode)
|
||||||
|
<$wikify name="preview-text" text={{!!text}} type={{!!type}} mode="$mode$" output="parsetree">
|
||||||
\procedure preview-node-properties(node)
|
<pre>
|
||||||
<$let excludeProperties="text type tag children attributes orderedAttributes">
|
<code>
|
||||||
<$list filter="[<node>jsonindexes[]] -[subfilter<excludeProperties>] +[limit[1]]" variable="ignore">
|
<$text text=<<preview-text>>/>
|
||||||
<table>
|
</code>
|
||||||
<tbody>
|
</pre>
|
||||||
<$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>jsonget[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>jsonget[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>jsonget<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>>/>
|
|
||||||
</$wikify>
|
</$wikify>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user