mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-05 23:10:28 +00:00
Avoid redefining the colour function by adding a configuration variable
This commit is contained in:
parent
f88915728f
commit
4e2f2bebd0
@ -3,25 +3,24 @@ tags: $:/tags/Macro
|
||||
|
||||
\procedure actions-compile-palette(inputTitle,outputTitle)
|
||||
<!-- Redefine colour function to use the input palette -->
|
||||
\function colour(name)
|
||||
[<inputTitle>getindex<name>] :else[[$:/config/DefaultColourMappings/]addsuffix<name>get[text]]
|
||||
\end colour
|
||||
<!-- Process modern filter-based palettes -->
|
||||
<%if [<inputTitle>get[palette-type]match[modern]] %>
|
||||
<$list filter="[<inputTitle>indexes[]sort[]]" variable="colour-name">
|
||||
<$let colour-filter={{{ [<inputTitle>getindex<colour-name>] }}}>
|
||||
<!-- Note the join, needed to cope with palette entries containing spaces -->
|
||||
<$action-setfield $tiddler=<<outputTitle>> $index=<<colour-name>> $value={{{ [subfilter<colour-filter>join[ ]] }}}/>
|
||||
</$let>
|
||||
</$list>
|
||||
<%else%>
|
||||
<!-- Process legacy wikified palettes -->
|
||||
<$list filter="[<inputTitle>indexes[]sort[]]" variable="colour-name">
|
||||
<$wikify name="colour-value" text={{{ [<inputTitle>getindex<colour-name>] }}} mode="inline">
|
||||
<$action-setfield $tiddler=<<outputTitle>> $index=<<colour-name>> $value=<<colour-value>>/>
|
||||
</$wikify>
|
||||
</$list>
|
||||
<%endif%>
|
||||
<$let tv-palette-name=<<inputTitle>>>
|
||||
<!-- Process modern filter-based palettes -->
|
||||
<%if [<inputTitle>get[palette-type]match[modern]] %>
|
||||
<$list filter="[<inputTitle>indexes[]sort[]]" variable="colour-name">
|
||||
<$let colour-filter={{{ [<inputTitle>getindex<colour-name>] }}}>
|
||||
<!-- Note the join, needed to cope with palette entries containing spaces -->
|
||||
<$action-setfield $tiddler=<<outputTitle>> $index=<<colour-name>> $value={{{ [subfilter<colour-filter>join[ ]] }}}/>
|
||||
</$let>
|
||||
</$list>
|
||||
<%else%>
|
||||
<!-- Process legacy wikified palettes -->
|
||||
<$list filter="[<inputTitle>indexes[]sort[]]" variable="colour-name">
|
||||
<$wikify name="colour-value" text={{{ [<inputTitle>getindex<colour-name>] }}} mode="inline">
|
||||
<$action-setfield $tiddler=<<outputTitle>> $index=<<colour-name>> $value=<<colour-value>>/>
|
||||
</$wikify>
|
||||
</$list>
|
||||
<%endif%>
|
||||
</$let>
|
||||
\end actions-compile-palette
|
||||
|
||||
\procedure actions-switch-colour-palette(paletteTitle)
|
||||
@ -32,8 +31,10 @@ tags: $:/tags/Macro
|
||||
<$transclude $variable="actions-compile-palette" inputTitle=<<paletteTitle>> outputTitle="$:/temp/palette-colours"/>
|
||||
\end actions-switch-colour-palette
|
||||
|
||||
\procedure tv-palette-name() $:/temp/palette-colours
|
||||
|
||||
\function colour(name)
|
||||
[[$:/temp/palette-colours]getindex<name>] :else[[$:/config/DefaultColourMappings/]addsuffix<name>get[text]]
|
||||
[<tv-palette-name>getindex<name>] :else[[$:/config/DefaultColourMappings/]addsuffix<name>get[text]]
|
||||
\end colour
|
||||
|
||||
\function color(name)
|
||||
|
Loading…
Reference in New Issue
Block a user