mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-04-16 15:53:14 +00:00
Proper recursion detection for palettes
This commit is contained in:
parent
c1fd82f50f
commit
139b61fff1
@ -29,6 +29,19 @@ tags: $:/tags/Macro
|
||||
</$list>
|
||||
\end actions-compile-palette-wikified
|
||||
|
||||
\procedure actions-compile-palette-import(inputTitle,outputTitle,exclusions:"")
|
||||
<%if [enlist<exclusions>!match<inputTitle>count[]] :map[enlist<exclusions>count[]compare:number:eq<currentTiddler>] +[!match[]] %>
|
||||
<$set name="exclusions" filter="[enlist<exclusions>] [<inputTitle>]">
|
||||
<%if [<inputTitle>get[palette-import]has[title]] %>
|
||||
<$transclude $variable="actions-compile-palette-import" inputTitle={{{ [<inputTitle>get[palette-import]] }}} outputTitle=<<outputTitle>> exclusions=<<exclusions>>/>
|
||||
<%endif%>
|
||||
<$list filter="[<inputTitle>indexes[]sort[]]" variable="colour-name">
|
||||
<$action-setfield $tiddler=<<outputTitle>> $index=<<colour-name>> $value={{{ [<inputTitle>getindex<colour-name>] }}}/>
|
||||
</$list>
|
||||
</$set>
|
||||
<%endif%>
|
||||
\end actions-compile-palette-import
|
||||
|
||||
\procedure actions-compile-palette(inputTitle,outputTitle,defaultImport="$:/palettes/Vanilla")
|
||||
\procedure tv-action-refresh-policy() always
|
||||
<$let
|
||||
@ -36,18 +49,8 @@ tags: $:/tags/Macro
|
||||
>
|
||||
<!-- Clear the temporary consolidated palette -->
|
||||
<$action-deletetiddler $tiddler=<<tempPalette>>/>
|
||||
<!-- Consolidate the imported palette -->
|
||||
<$let importTitle={{{ [<inputTitle>get[palette-import]else<defaultImport>] }}}>
|
||||
<%if [<importTitle>!match[]] %>
|
||||
<$list filter="[<importTitle>indexes[]sort[]]" variable="colour-name">
|
||||
<$action-setfield $tiddler=<<tempPalette>> $index=<<colour-name>> $value={{{ [<importTitle>getindex<colour-name>] }}}/>
|
||||
</$list>
|
||||
<%endif%>
|
||||
</$let>
|
||||
<!-- Consolidate the main palette -->
|
||||
<$list filter="[<inputTitle>indexes[]sort[]]" variable="colour-name">
|
||||
<$action-setfield $tiddler=<<tempPalette>> $index=<<colour-name>> $value={{{ [<inputTitle>getindex<colour-name>] }}}/>
|
||||
</$list>
|
||||
<!-- Consolidate the chain of palettes -->
|
||||
<$transclude $variable="actions-compile-palette-import" inputTitle=<<inputTitle>> outputTitle=<<tempPalette>>/>
|
||||
<!-- Compile the temporary palette to the output palette -->
|
||||
<%if [<inputTitle>get[palette-type]match[modern]] %>
|
||||
<$transclude $variable="actions-compile-palette-filtered" tempPalette=<<tempPalette>> outputTitle=<<outputTitle>>/>
|
||||
|
@ -0,0 +1,61 @@
|
||||
|
||||
title: Operators/Palettes/RecursivePalettes
|
||||
description: Palettes that import each other in a circular toop
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
||||
+<<colour page-background>>
|
||||
+<<colour background>>
|
||||
+<<colour custom>>
|
||||
+<<colour foreground>>
|
||||
+
|
||||
title: Actions
|
||||
|
||||
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
||||
<<actions-recompile-current-palette>>
|
||||
+
|
||||
title: $:/palette
|
||||
|
||||
MyPalette
|
||||
+
|
||||
title: MyPalette
|
||||
name: My Palette
|
||||
description: My custom palette
|
||||
tags: $:/tags/Palette
|
||||
type: application/x-tiddler-dictionary
|
||||
palette-import: MyOtherPalette
|
||||
color-scheme: light
|
||||
|
||||
page-background: <<colour custom>>
|
||||
custom: #f4e4d4
|
||||
+
|
||||
title: MyOtherPalette
|
||||
name: My Other Palette
|
||||
description: My other custom palette
|
||||
tags: $:/tags/Palette
|
||||
type: application/x-tiddler-dictionary
|
||||
palette-import: MyFurtherPalette
|
||||
color-scheme: light
|
||||
|
||||
page-background: #d4e4f4
|
||||
background: red
|
||||
+
|
||||
title: MyFurtherPalette
|
||||
name: My Further Palette
|
||||
description: My further custom palette
|
||||
tags: $:/tags/Palette
|
||||
type: application/x-tiddler-dictionary
|
||||
xpalette-import: MyPalette
|
||||
color-scheme: light
|
||||
|
||||
foreground: green
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>+#f4e4d4
|
||||
+red
|
||||
+#f4e4d4
|
||||
+green</p>
|
Loading…
x
Reference in New Issue
Block a user