Fossil Forum

No title on markdown wiki/forum links
Login

No title on markdown wiki/forum links

No title on markdown wiki/forum links

(1) By OgunFossil on 2020-11-01 23:02:32 [source]

It looks like if you create a markdown link with a title on a wiki page or forum post, the title gets eaten/isn't displayed - so for:

[Markdown Formatting Rules](https://fossil-scm.org/fossil/md_rules "Title")

..you get:

<a href="https://fossil-scm.org/fossil/md_rules">Markdown Formatting Rules</a>

..rather than:

<a href="https://fossil-scm.org/fossil/md_rules" title="Title">Markdown Formatting Rules</a>

For markdown documents that are in the repo and being viewed in the UI, titles on links appear as expected.

(2) By OgunFossil on 2020-11-03 19:53:12 in reply to 1 [link] [source]

This is happening because of a new feature (Safe HTML) which is enabled for all UI content by default.

To work around it, you can enable unsafe HTML for the wiki/forum/tickets - but obviously that's a lot of exposure just to get titles on links.

It feels like the title attribute for links is one that should be allowed by default (at least for the wiki), unless it's excluded/disallowed by design.

Something like this seems to fix it (as in it looks like it makes titles appear on UI markdown content links without disabling safe html):

Index: src/wikiformat.c
==================================================================
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -67,2 +67,3 @@
   ATTR_TARGET,
+  ATTR_TITLE, // o
   ATTR_TYPE,
@@ -100,2 +101,3 @@
   AMSK_TARGET       = 0x01000000,
+  AMSK_TITLE        = 0x03000000, // o - Don't know what this means, but it didn't crash
   AMSK_TYPE         = 0x02000000,
@@ -139,2 +141,3 @@
   { "target",        AMSK_TARGET         },
+  { "title",         AMSK_TITLE          }, // o
   { "type",          AMSK_TYPE           },
@@ -277,3 +280,3 @@
  { "a",             MARKUP_A,            MUTYPE_HYPERLINK,
-                    AMSK_HREF|AMSK_NAME|AMSK_CLASS|AMSK_TARGET|AMSK_STYLE },
+                    AMSK_HREF|AMSK_NAME|AMSK_CLASS|AMSK_TARGET|AMSK_TITLE|AMSK_STYLE }, // o
  { "address",       MARKUP_ADDRESS,      MUTYPE_BLOCK,         AMSK_STYLE },

..but I'm not a developer/programmer and don't know what I'm doing so may well be poking at the wrong thing or may have broken something else in the process. I just wanted to show that I'd at least had a crack at it :)

(3) By anonymous on 2020-11-06 06:28:48 in reply to 2 [link] [source]

It does seem to be the correct place to enable the title attribute for the anchors. Just tested it too.

I'm not sure if there're other reasons to not allow the title attribute...

However patch-wise, the mask-value needs to be set power of 2. Best option is to insert the title's mask value after the "target" attribute's mask, such that the listed alphabetical order is kept on. But move the subsequent mask values up.

Leaving the choice of how to patch it to the maintainers:

Index: src/wikiformat.c
==================================================================
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -63,10 +63,11 @@
   ATTR_SIZE,
   ATTR_SRC,
   ATTR_START,
   ATTR_STYLE,
   ATTR_TARGET,
+  ATTR_TITLE,
   ATTR_TYPE,
   ATTR_VALIGN,
   ATTR_VALUE,
   ATTR_VSPACE,
   ATTR_WIDTH
@@ -96,15 +97,16 @@
   AMSK_SIZE         = 0x00100000,
   AMSK_SRC          = 0x00200000,
   AMSK_START        = 0x00400000,
   AMSK_STYLE        = 0x00800000,
   AMSK_TARGET       = 0x01000000,
-  AMSK_TYPE         = 0x02000000,
-  AMSK_VALIGN       = 0x04000000,
-  AMSK_VALUE        = 0x08000000,
-  AMSK_VSPACE       = 0x10000000,
-  AMSK_WIDTH        = 0x20000000
+  AMSK_TITLE        = 0x02000000,
+  AMSK_TYPE         = 0x04000000,
+  AMSK_VALIGN       = 0x08000000,
+  AMSK_VALUE        = 0x10000000,
+  AMSK_VSPACE       = 0x20000000,
+  AMSK_WIDTH        = 0x40000000
 };
 
 static const struct AllowedAttribute {
   const char *zName;
   unsigned int iMask;
@@ -135,10 +137,11 @@
   { "size",          AMSK_SIZE           },
   { "src",           AMSK_SRC            },
   { "start",         AMSK_START          },
   { "style",         AMSK_STYLE          },
   { "target",        AMSK_TARGET         },
+  { "title",         AMSK_TITLE          },
   { "type",          AMSK_TYPE           },
   { "valign",        AMSK_VALIGN         },
   { "value",         AMSK_VALUE          },
   { "vspace",        AMSK_VSPACE         },
   { "width",         AMSK_WIDTH          },
@@ -273,11 +276,12 @@
   short int iType;         /* The MUTYPE_* code */
   int allowedAttr;         /* Allowed attributes on this markup */
 } aMarkup[] = {
  { 0,               MARKUP_INVALID,      0,                    0  },
  { "a",             MARKUP_A,            MUTYPE_HYPERLINK,
-                    AMSK_HREF|AMSK_NAME|AMSK_CLASS|AMSK_TARGET|AMSK_STYLE },
+                    AMSK_HREF|AMSK_NAME|AMSK_CLASS|AMSK_TARGET|AMSK_TITLE|
+                    AMSK_STYLE },
  { "address",       MARKUP_ADDRESS,      MUTYPE_BLOCK,         AMSK_STYLE },
  { "article",       MARKUP_HTML5_ARTICLE, MUTYPE_BLOCK,
                                             AMSK_ID|AMSK_CLASS|AMSK_STYLE },
  { "aside",         MARKUP_HTML5_ASIDE,  MUTYPE_BLOCK,
                                             AMSK_ID|AMSK_CLASS|AMSK_STYLE },


(4) By Richard Hipp (drh) on 2020-11-07 12:56:07 in reply to 1 [link] [source]

Should be fixed by check-in b8078aefef9cac95.

(5) By OgunFossil on 2020-11-08 21:19:54 in reply to 4 [link] [source]

Thank you - and thank you, as always, for Fossil and SQLite :)