From 44cf2e3c701c1bfa0e1a62c2e848fd3f3b018e5f Mon Sep 17 00:00:00 2001 From: Mario Pietsch Date: Wed, 30 Oct 2024 10:19:01 +0100 Subject: [PATCH] Add new classes to wikitext created emphasised elements to make them easily stylable (#8163) * allow internal link to be wikitex formatted as bold * fix typo * add new classes to all emphasis and inline-code elements * fix tests for new STRONG classes --- core/modules/parsers/wikiparser/rules/codeinline.js | 3 +++ core/modules/parsers/wikiparser/rules/emphasis/bold.js | 3 +++ core/modules/parsers/wikiparser/rules/emphasis/italic.js | 4 ++++ .../parsers/wikiparser/rules/emphasis/strikethrough.js | 3 +++ core/modules/parsers/wikiparser/rules/emphasis/subscript.js | 3 +++ .../parsers/wikiparser/rules/emphasis/superscript.js | 3 +++ .../modules/parsers/wikiparser/rules/emphasis/underscore.js | 3 +++ .../tiddlers/tests/data/functions/WikifiedFunctions.tid | 2 +- .../tiddlers/tests/data/pragmas/Parsermode-indented.tid | 4 ++-- editions/test/tiddlers/tests/data/pragmas/Parsermode.tid | 4 ++-- editions/test/tiddlers/tests/data/transclude/Typed.tid | 6 +++--- themes/tiddlywiki/vanilla/base.tid | 5 +++++ 12 files changed, 35 insertions(+), 8 deletions(-) diff --git a/core/modules/parsers/wikiparser/rules/codeinline.js b/core/modules/parsers/wikiparser/rules/codeinline.js index 048fc051c..139f07f08 100644 --- a/core/modules/parsers/wikiparser/rules/codeinline.js +++ b/core/modules/parsers/wikiparser/rules/codeinline.js @@ -48,6 +48,9 @@ exports.parse = function() { tag: "code", children: [{ type: "text", + attributes: { + class: {type: "string", value: "tc-emphasis tc-code"} + }, text: text, start: start, end: this.parser.pos diff --git a/core/modules/parsers/wikiparser/rules/emphasis/bold.js b/core/modules/parsers/wikiparser/rules/emphasis/bold.js index 3799feeb5..473e85d9b 100644 --- a/core/modules/parsers/wikiparser/rules/emphasis/bold.js +++ b/core/modules/parsers/wikiparser/rules/emphasis/bold.js @@ -43,6 +43,9 @@ exports.parse = function() { return [{ type: "element", tag: "strong", + attributes: { + class: {type: "string", value: "tc-emphasis tc-strong"} + }, children: tree }]; }; diff --git a/core/modules/parsers/wikiparser/rules/emphasis/italic.js b/core/modules/parsers/wikiparser/rules/emphasis/italic.js index 3e0744c4d..4e8840433 100644 --- a/core/modules/parsers/wikiparser/rules/emphasis/italic.js +++ b/core/modules/parsers/wikiparser/rules/emphasis/italic.js @@ -43,6 +43,10 @@ exports.parse = function() { return [{ type: "element", tag: "em", + attributes: { + class: {type: "string", value: "tc-emphasis tc-italic"} + }, + children: tree }]; }; diff --git a/core/modules/parsers/wikiparser/rules/emphasis/strikethrough.js b/core/modules/parsers/wikiparser/rules/emphasis/strikethrough.js index 0fb34fc52..0619b6558 100644 --- a/core/modules/parsers/wikiparser/rules/emphasis/strikethrough.js +++ b/core/modules/parsers/wikiparser/rules/emphasis/strikethrough.js @@ -43,6 +43,9 @@ exports.parse = function() { return [{ type: "element", tag: "strike", + attributes: { + class: {type: "string", value: "tc-emphasis tc-strike"} + }, children: tree }]; }; diff --git a/core/modules/parsers/wikiparser/rules/emphasis/subscript.js b/core/modules/parsers/wikiparser/rules/emphasis/subscript.js index 12be0fbbc..7a3e8f8ec 100644 --- a/core/modules/parsers/wikiparser/rules/emphasis/subscript.js +++ b/core/modules/parsers/wikiparser/rules/emphasis/subscript.js @@ -43,6 +43,9 @@ exports.parse = function() { return [{ type: "element", tag: "sub", + attributes: { + class: {type: "string", value: "tc-emphasis tc-sub"} + }, children: tree }]; }; diff --git a/core/modules/parsers/wikiparser/rules/emphasis/superscript.js b/core/modules/parsers/wikiparser/rules/emphasis/superscript.js index 5a5330d8c..ecb8564b9 100644 --- a/core/modules/parsers/wikiparser/rules/emphasis/superscript.js +++ b/core/modules/parsers/wikiparser/rules/emphasis/superscript.js @@ -43,6 +43,9 @@ exports.parse = function() { return [{ type: "element", tag: "sup", + attributes: { + class: {type: "string", value: "tc-emphasis tc-sup"} + }, children: tree }]; }; diff --git a/core/modules/parsers/wikiparser/rules/emphasis/underscore.js b/core/modules/parsers/wikiparser/rules/emphasis/underscore.js index d36bd242d..2b3d680da 100644 --- a/core/modules/parsers/wikiparser/rules/emphasis/underscore.js +++ b/core/modules/parsers/wikiparser/rules/emphasis/underscore.js @@ -43,6 +43,9 @@ exports.parse = function() { return [{ type: "element", tag: "u", + attributes: { + class: {type: "string", value: "tc-emphasis tc-underscore"} + }, children: tree }]; }; diff --git a/editions/test/tiddlers/tests/data/functions/WikifiedFunctions.tid b/editions/test/tiddlers/tests/data/functions/WikifiedFunctions.tid index 36b64e4a3..6ecd60f2a 100644 --- a/editions/test/tiddlers/tests/data/functions/WikifiedFunctions.tid +++ b/editions/test/tiddlers/tests/data/functions/WikifiedFunctions.tid @@ -33,4 +33,4 @@ $param$ with a ''buffalo'' + title: ExpectedResult -

Going to lunch with a ''buffalo''

Going to breakfastwith abuffalo

Going to dinner with a buffalo

Going to lunch with a ''buffalo''Going to breakfastwith abuffaloGoing to dinner with a buffalo \ No newline at end of file +

Going to lunch with a ''buffalo''

Going to breakfastwith abuffalo

Going to dinner with a buffalo

Going to lunch with a ''buffalo''Going to breakfastwith abuffaloGoing to dinner with a buffalo \ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/pragmas/Parsermode-indented.tid b/editions/test/tiddlers/tests/data/pragmas/Parsermode-indented.tid index 10747735f..639f0a785 100644 --- a/editions/test/tiddlers/tests/data/pragmas/Parsermode-indented.tid +++ b/editions/test/tiddlers/tests/data/pragmas/Parsermode-indented.tid @@ -30,7 +30,7 @@ title: ExpectedResult ! Not Heading -Text with bold

Heading

Text with bold

! Not Heading +Text with bold

Heading

Text with bold

! Not Heading -Text with bold

Heading

Text with bold

+Text with bold

Heading

Text with bold

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/pragmas/Parsermode.tid b/editions/test/tiddlers/tests/data/pragmas/Parsermode.tid index 57869e37a..0a953edc1 100644 --- a/editions/test/tiddlers/tests/data/pragmas/Parsermode.tid +++ b/editions/test/tiddlers/tests/data/pragmas/Parsermode.tid @@ -30,7 +30,7 @@ title: ExpectedResult ! Not Heading -Text with bold

Heading

Text with bold

! Not Heading +Text with bold

Heading

Text with bold

! Not Heading -Text with bold

Heading

Text with bold

+Text with bold

Heading

Text with bold

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/transclude/Typed.tid b/editions/test/tiddlers/tests/data/transclude/Typed.tid index c99664b59..65e3987ac 100644 --- a/editions/test/tiddlers/tests/data/transclude/Typed.tid +++ b/editions/test/tiddlers/tests/data/transclude/Typed.tid @@ -29,10 +29,10 @@ testindex: This is ''wikitext'' + title: ExpectedResult -

This is wikitext +

This is wikitext - -

This is ''wikitext''

This is wikitext +

This is ''wikitext''

This is wikitext - -

This is ''wikitext''

This is wikitext +

This is ''wikitext''

This is wikitext -

This is ''wikitext''

\ No newline at end of file diff --git a/themes/tiddlywiki/vanilla/base.tid b/themes/tiddlywiki/vanilla/base.tid index c795ad362..98345d6ce 100644 --- a/themes/tiddlywiki/vanilla/base.tid +++ b/themes/tiddlywiki/vanilla/base.tid @@ -493,6 +493,11 @@ a.tc-tiddlylink-external:hover { color: <>; } +/* wikitext bold for ''[[internal link]]'' */ +strong.tc-strong .tc-tiddlylink { + font-weight: bolder; +} + /* ** Drag and drop styles */