From 23e0eeb556d1933f4fedfa3225ea733c7a0aa260 Mon Sep 17 00:00:00 2001 From: Mario Pietsch Date: Fri, 7 Oct 2022 19:05:49 +0200 Subject: [PATCH] Add default settings for styled inline SPANs (#6877) * add default settings for styled inline SPANs * change color names in palettes and vanilla-base * change parser behaviour if custom class is used * tc-inline-style will only be set if no other custom setting is appliead * Add tests for inline-styles * add one more test * remove space after if --- .../parsers/wikiparser/rules/styleinline.js | 6 +++--- core/palettes/Blanca.tid | 2 ++ core/palettes/Blue.tid | 2 ++ core/palettes/BrightMute.tid | 2 ++ core/palettes/ContrastDark.tid | 2 ++ core/palettes/ContrastLight.tid | 2 ++ core/palettes/CupertinoDark.tid | 2 ++ core/palettes/DarkPhotos.tid | 2 ++ core/palettes/DesertSand.tid | 2 ++ core/palettes/GruvBoxDark.tid | 2 ++ core/palettes/Nord.tid | 2 ++ core/palettes/Rocker.tid | 2 ++ core/palettes/SolarFlare.tid | 2 ++ core/palettes/SolarizedDark.tid | 2 ++ core/palettes/SolarizedLight.tid | 2 ++ core/palettes/SpartanDay.tid | 2 ++ core/palettes/SpartanNight.tid | 2 ++ core/palettes/Twilight.tid | 2 ++ core/palettes/Vanilla.tid | 2 ++ .../tiddlers/$__editions_tw5.com_doc-macros.tid | 2 +- editions/test/tiddlers/tests/test-wikitext.js | 16 ++++++++++++++++ editions/tw5.com/tiddlers/system/doc-macros.tid | 2 +- themes/tiddlywiki/vanilla/base.tid | 5 +++++ 23 files changed, 62 insertions(+), 5 deletions(-) diff --git a/core/modules/parsers/wikiparser/rules/styleinline.js b/core/modules/parsers/wikiparser/rules/styleinline.js index cd42d8f00..653e48986 100644 --- a/core/modules/parsers/wikiparser/rules/styleinline.js +++ b/core/modules/parsers/wikiparser/rules/styleinline.js @@ -41,9 +41,6 @@ exports.parse = function() { var node = { type: "element", tag: "span", - attributes: { - "class": {type: "string", value: "tc-inline-style"} - }, children: tree }; if(classString) { @@ -52,6 +49,9 @@ exports.parse = function() { if(stylesString) { $tw.utils.addAttributeToParseTreeNode(node,"style",stylesString); } + if(!classString && !stylesString) { + $tw.utils.addClassToParseTreeNode(node,"tc-inline-style"); + } return [node]; }; diff --git a/core/palettes/Blanca.tid b/core/palettes/Blanca.tid index f86705443..0fd8e2da3 100644 --- a/core/palettes/Blanca.tid +++ b/core/palettes/Blanca.tid @@ -34,6 +34,8 @@ external-link-foreground-hover: inherit external-link-foreground-visited: #0000aa external-link-foreground: #0000ee foreground: #333333 +highlight-background: #ffff00 +highlight-foreground: #000000 message-background: #ecf2ff message-border: #cfd6e6 message-foreground: #547599 diff --git a/core/palettes/Blue.tid b/core/palettes/Blue.tid index e3aa21952..cc3846b50 100644 --- a/core/palettes/Blue.tid +++ b/core/palettes/Blue.tid @@ -34,6 +34,8 @@ external-link-foreground-hover: inherit external-link-foreground-visited: #0000aa external-link-foreground: #0000ee foreground: #333353 +highlight-background: #ffff00 +highlight-foreground: #000000 message-background: #ecf2ff message-border: #cfd6e6 message-foreground: #547599 diff --git a/core/palettes/BrightMute.tid b/core/palettes/BrightMute.tid index 64193c1ce..ddbd6b3cd 100644 --- a/core/palettes/BrightMute.tid +++ b/core/palettes/BrightMute.tid @@ -34,6 +34,8 @@ external-link-foreground-hover: inherit external-link-foreground-visited: #0000aa external-link-foreground: #0000ee foreground: #333333 +highlight-background: #ffff00 +highlight-foreground: #000000 message-background: #ecf2ff message-border: #cfd6e6 message-foreground: #547599 diff --git a/core/palettes/ContrastDark.tid b/core/palettes/ContrastDark.tid index ded11b835..850a5863b 100644 --- a/core/palettes/ContrastDark.tid +++ b/core/palettes/ContrastDark.tid @@ -34,6 +34,8 @@ external-link-foreground-hover: inherit external-link-foreground-visited: #00a external-link-foreground: #00e foreground: #000 +highlight-background: #ffff00 +highlight-foreground: #000000 message-background: <> message-border: <> message-foreground: <> diff --git a/core/palettes/ContrastLight.tid b/core/palettes/ContrastLight.tid index d3eb2f731..ade9f43f8 100644 --- a/core/palettes/ContrastLight.tid +++ b/core/palettes/ContrastLight.tid @@ -34,6 +34,8 @@ external-link-foreground-hover: inherit external-link-foreground-visited: #00a external-link-foreground: #00e foreground: #fff +highlight-background: #ffff00 +highlight-foreground: #000000 message-background: <> message-border: <> message-foreground: <> diff --git a/core/palettes/CupertinoDark.tid b/core/palettes/CupertinoDark.tid index c956561ed..7f08f4100 100644 --- a/core/palettes/CupertinoDark.tid +++ b/core/palettes/CupertinoDark.tid @@ -32,6 +32,8 @@ external-link-foreground-hover: external-link-foreground-visited: #BF5AF2 external-link-foreground: #32D74B foreground: #FFFFFF +highlight-background: #ffff78 +highlight-foreground: #000000 menubar-background: #464646 menubar-foreground: #ffffff message-background: <> diff --git a/core/palettes/DarkPhotos.tid b/core/palettes/DarkPhotos.tid index 4e1949c04..71fa40f2f 100644 --- a/core/palettes/DarkPhotos.tid +++ b/core/palettes/DarkPhotos.tid @@ -36,6 +36,8 @@ external-link-foreground-hover: inherit external-link-foreground-visited: #0000aa external-link-foreground: #0000ee foreground: #333333 +highlight-background: #ffff00 +highlight-foreground: #000000 message-background: #ecf2ff message-border: #cfd6e6 message-foreground: #547599 diff --git a/core/palettes/DesertSand.tid b/core/palettes/DesertSand.tid index 40056962b..ddce80e27 100644 --- a/core/palettes/DesertSand.tid +++ b/core/palettes/DesertSand.tid @@ -40,6 +40,8 @@ external-link-foreground-hover: inherit external-link-foreground-visited: #313163 external-link-foreground: #555592 foreground: #2D2A23 +highlight-background: #ffff00 +highlight-foreground: #000000 menubar-background: #CDC2A6 menubar-foreground: #5A5446 message-background: #ECE5CF diff --git a/core/palettes/GruvBoxDark.tid b/core/palettes/GruvBoxDark.tid index 840d8683e..3b62eb311 100644 --- a/core/palettes/GruvBoxDark.tid +++ b/core/palettes/GruvBoxDark.tid @@ -41,6 +41,8 @@ external-link-foreground-hover: inherit external-link-foreground-visited: #d3869b external-link-foreground: #8ec07c foreground: #fbf1c7 +highlight-background: #ffff79 +highlight-foreground: #000000 menubar-background: #504945 menubar-foreground: <> message-background: #83a598 diff --git a/core/palettes/Nord.tid b/core/palettes/Nord.tid index f825f45f2..b296ba783 100644 --- a/core/palettes/Nord.tid +++ b/core/palettes/Nord.tid @@ -41,6 +41,8 @@ external-link-foreground-hover: inherit external-link-foreground-visited: #5E81AC external-link-foreground: #8FBCBB foreground: #d8dee9 +highlight-background: #ffff78 +highlight-foreground: #000000 menubar-background: #2E3440 menubar-foreground: #d8dee9 message-background: #2E3440 diff --git a/core/palettes/Rocker.tid b/core/palettes/Rocker.tid index bc7d2ded6..a91cd1b5f 100644 --- a/core/palettes/Rocker.tid +++ b/core/palettes/Rocker.tid @@ -34,6 +34,8 @@ external-link-foreground-hover: inherit external-link-foreground-visited: #0000aa external-link-foreground: #0000ee foreground: #333333 +highlight-background: #ffff00 +highlight-foreground: #000000 message-background: #ecf2ff message-border: #cfd6e6 message-foreground: #547599 diff --git a/core/palettes/SolarFlare.tid b/core/palettes/SolarFlare.tid index e72815657..4d81bf531 100644 --- a/core/palettes/SolarFlare.tid +++ b/core/palettes/SolarFlare.tid @@ -131,6 +131,8 @@ external-link-background-hover: inherit external-link-background-visited: inherit external-link-background: inherit external-link-foreground-hover: inherit +highlight-background: #ffff00 +highlight-foreground: #000000 message-border: #cfd6e6 modal-border: #999999 select-tag-background: diff --git a/core/palettes/SolarizedDark.tid b/core/palettes/SolarizedDark.tid index f193bff1c..eea273c30 100644 --- a/core/palettes/SolarizedDark.tid +++ b/core/palettes/SolarizedDark.tid @@ -35,6 +35,8 @@ external-link-foreground: #268bd2 external-link-foreground-hover: external-link-foreground-visited: #268bd2 foreground: #839496 +highlight-background: #ffff78 +highlight-foreground: #000000 message-background: #002b36 message-border: #586e75 message-foreground: #839496 diff --git a/core/palettes/SolarizedLight.tid b/core/palettes/SolarizedLight.tid index 4bcec81d6..3cf954bb5 100644 --- a/core/palettes/SolarizedLight.tid +++ b/core/palettes/SolarizedLight.tid @@ -35,6 +35,8 @@ external-link-foreground: #268bd2 external-link-foreground-hover: inherit external-link-foreground-visited: #268bd2 foreground: #657b83 +highlight-background: #ffff00 +highlight-foreground: #000000 message-background: #fdf6e3 message-border: #93a1a1 message-foreground: #657b83 diff --git a/core/palettes/SpartanDay.tid b/core/palettes/SpartanDay.tid index 3cd8337a7..cc197144e 100644 --- a/core/palettes/SpartanDay.tid +++ b/core/palettes/SpartanDay.tid @@ -34,6 +34,8 @@ external-link-foreground-hover: external-link-foreground-visited: external-link-foreground: foreground: rgba(0, 0, 0, 0.87) +highlight-background: #ffff00 +highlight-foreground: #000000 message-background: <> message-border: <> message-foreground: rgba(0, 0, 0, 0.54) diff --git a/core/palettes/SpartanNight.tid b/core/palettes/SpartanNight.tid index 1962c4782..dc47a0774 100644 --- a/core/palettes/SpartanNight.tid +++ b/core/palettes/SpartanNight.tid @@ -34,6 +34,8 @@ external-link-foreground-hover: external-link-foreground-visited: #7c318c external-link-foreground: #9e3eb3 foreground: rgba(255, 255, 255, 0.7) +highlight-background: #ffff78 +highlight-foreground: #000000 message-background: <> message-border: <> message-foreground: rgba(255, 255, 255, 0.54) diff --git a/core/palettes/Twilight.tid b/core/palettes/Twilight.tid index ff8a0b956..4c127f822 100644 --- a/core/palettes/Twilight.tid +++ b/core/palettes/Twilight.tid @@ -43,6 +43,8 @@ external-link-foreground: rgb(179, 179, 255) external-link-foreground-hover: inherit external-link-foreground-visited: rgb(153, 153, 255) foreground: rgb(179, 179, 179) +highlight-background: #ffff78 +highlight-foreground: #000000 message-background: <> message-border: #96ccff message-foreground: <> diff --git a/core/palettes/Vanilla.tid b/core/palettes/Vanilla.tid index d3c7b1441..d84b4ec83 100644 --- a/core/palettes/Vanilla.tid +++ b/core/palettes/Vanilla.tid @@ -42,6 +42,8 @@ external-link-foreground-hover: inherit external-link-foreground-visited: #0000aa external-link-foreground: #0000ee foreground: #333333 +highlight-background: #ffff00 +highlight-foreground: #000000 message-background: #ecf2ff message-border: #cfd6e6 message-foreground: #547599 diff --git a/editions/fr-FR/tiddlers/$__editions_tw5.com_doc-macros.tid b/editions/fr-FR/tiddlers/$__editions_tw5.com_doc-macros.tid index de6376218..fcf3ddb80 100644 --- a/editions/fr-FR/tiddlers/$__editions_tw5.com_doc-macros.tid +++ b/editions/fr-FR/tiddlers/$__editions_tw5.com_doc-macros.tid @@ -117,7 +117,7 @@ C'est un exemple de tiddler. Voir [[Macros Table des matières (Exemples)|Table- - +
Attention :
Ne faites pas comme ça !
Attention :
Ne faites pas comme ça !
$eg$ diff --git a/editions/test/tiddlers/tests/test-wikitext.js b/editions/test/tiddlers/tests/test-wikitext.js index 3213f6abf..4cab566da 100644 --- a/editions/test/tiddlers/tests/test-wikitext.js +++ b/editions/test/tiddlers/tests/test-wikitext.js @@ -63,6 +63,22 @@ describe("WikiText tests", function() { expect(wiki.renderText("text/html","text/vnd-tiddlywiki","@@color:red;\n
\n\nContent
\n@@")).toBe("

Content

"); expect(wiki.renderText("text/html","text/vnd-tiddlywiki","@@color:red;\n---\n@@")).toBe("
"); }); + it("handles inline style wikitext notation", function() { + expect(wiki.renderText("text/html","text/vnd-tiddlywiki", + "some @@highlighted@@ text")).toBe('

some highlighted text

'); + expect(wiki.renderText("text/html","text/vnd-tiddlywiki", + "some @@color:green;.tc-inline-style 1 style and 1 class@@ text")).toBe('

some 1 style and 1 class text

'); + expect(wiki.renderText("text/html","text/vnd-tiddlywiki", + "some @@background-color:red;red@@ text")).toBe('

some red text

'); + expect(wiki.renderText("text/html","text/vnd-tiddlywiki", + "some @@.myClass class@@ text")).toBe('

some class text

'); + expect(wiki.renderText("text/html","text/vnd-tiddlywiki", + "some @@.myClass.secondClass 2 classes@@ text")).toBe('

some 2 classes text

'); + expect(wiki.renderText("text/html","text/vnd-tiddlywiki", + "some @@background:red;.myClass style and class@@ text")).toBe('

some style and class text

'); + expect(wiki.renderText("text/html","text/vnd-tiddlywiki", + "some @@background:red;color:white;.myClass 2 style and 1 class@@ text")).toBe('

some 2 style and 1 class text

'); + }); }); })(); diff --git a/editions/tw5.com/tiddlers/system/doc-macros.tid b/editions/tw5.com/tiddlers/system/doc-macros.tid index d4c4b9506..a264198a9 100644 --- a/editions/tw5.com/tiddlers/system/doc-macros.tid +++ b/editions/tw5.com/tiddlers/system/doc-macros.tid @@ -117,7 +117,7 @@ This is an example tiddler. See [[Table-of-Contents Macros (Examples)]]. - +
Warning:
Don't do it this way!
Warning:
Don't do it this way!
$eg$ diff --git a/themes/tiddlywiki/vanilla/base.tid b/themes/tiddlywiki/vanilla/base.tid index 9c4a342ff..17d3ebb39 100644 --- a/themes/tiddlywiki/vanilla/base.tid +++ b/themes/tiddlywiki/vanilla/base.tid @@ -290,6 +290,11 @@ kbd { color: <>; } +.tc-inline-style { + background: <>; + color: <>; +} + form.tc-form-inline { display: inline; }