Open danielmekis opened 7 years ago
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?
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.
Hi, @siburb thanks so much. Definitely open to reviewing a PR!
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)