Notepad icon indicating copy to clipboard operation
Notepad copied to clipboard

Change Markdown syntax colours

Open danielmekis opened this issue 7 years ago • 3 comments

Is there any way to use different colours for markdown symbols? Like: **, *, #, etc? (I know, for example the bold has a different colour from the body colour but I would like to set only the markdown syntax's alpha value or it's colour)

danielmekis avatar Nov 22 '17 08:11 danielmekis

This is currently not supported. It is definitely possible and would include reconfiguring the matching groups on the regex parsing, and thus, in turn, the styling of the attributed strings. Any interest in a pull request to implement this feature?

ruddfawcett avatar Dec 02 '17 17:12 ruddfawcett

I've got this working using named capturing groups in the regex, and matching those names to styles using a new property in the style class.

        "handle": {
            "regex": "(?<handleHead>[@@])(?<handleTail>[a-zA-Z0-9_]{1,20})",
            "groups": ["handleHead", "handleTail"]
        },
        "handleHead": {
            "color": "#FF0000"
        },
        "handleTail": {
            "color": "#00FF00"
        },

Named capturing groups are only supported by NSRegularExpression from iOS11 & macOS10.13 (https://developer.apple.com/documentation/foundation/nstextcheckingresult/2915200-range), but we can easily just ignore it in older versions.

This approach seems very flexible, and requires quite minimal changes to the system as a whole. Will polish it up and submit a PR in case you like this direction.

siburb avatar Jul 14 '20 13:07 siburb

Hi, @siburb thanks so much. Definitely open to reviewing a PR!

ruddfawcett avatar Jul 14 '20 14:07 ruddfawcett