Fossil

Update of ”branch/markdown-tagrefs”
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

Artifact ID: 5a0593111ecbdda6e19aa62146df03e3425754f2160f8384b08fb1adf1627052
Page Name:branch/markdown-tagrefs
Date: 2024-07-03 09:32:41
Original User: stephan
Mimetype:text/x-markdown
Parent: e45e9240c0aa3448552f68a4934e4553c4daaaf246d48518c397e63dbbf64015 (diff)
Next 77ed3704643b9525665bac7f39d80db9fc008d78f18307e44af96c3eef53cd6a
Content

The purpose of the markdown-refs branch is to experiment with adding hashtag and @username support into the markdown parser.

In short, it attempts to recognize hashtags and @username references and wraps those tokens in SPAN elements with well-defined class name so that they can be identified by downstream JavaScript code and context-specific features applied to them:

They have no outwardly-visible effect1 unless JS code is used to fetch the elements and apply features to them. The most obvious use for hashtags would be to apply them as filters in the forum and add a way to tag forum posts. Clicking on a hashtag in the forum would filter on messages which have that tag. (Note that containing the hashtag and "having that tag" are separate things: opaque text vs. a fossil tag artifact.) One issue we'd have for that use case, though, is that fossil tags are case-sensitive and hashtags are notoriously inconsistent in their casing, so any interface for adding tags for this purpose would need to lowercase them for consistency.

The core hashtag parsing seems to work well, including support for non-ASCII hashtags, and a demo of its use is integrated into the /chat page:

  1. Tapping a #nnnnn numeric hashtag will scroll to the given message if it's been loaded. It's common to reference other messages that way in chat, and this branch now makes it easier to refer back to such references.
  2. Tapping a hashtag will filter only on messages containing that hashtag.

Potential uses for these tags include:

Example input to feed to the test-markdown-render command:

___#tag___
hashtag: #1_2
numtag: #123.4
numtag: #1
numtag 2.3: #2.3.4
xyz
#_notValid_
hashtag: #tag_ok
#tag__not
#tagNOT#NotATag
hashtag w/ em: *#ValidTag*
hashtag: #äValidTÄg

  1. ^ bug: #N references in headers are rendered with their SPAN element HTML-escaped. Why headers get HTML-escaped is unclear.