Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Markdown syntax colours #28

Open
danielmekis opened this issue Nov 22, 2017 · 3 comments
Open

Change Markdown syntax colours #28

danielmekis opened this issue Nov 22, 2017 · 3 comments

Comments

@danielmekis
Copy link

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)

@ruddfawcett
Copy link
Owner

ruddfawcett commented Dec 2, 2017

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?

@siburb
Copy link

siburb commented Jul 14, 2020

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.

@ruddfawcett
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants