Last active
April 3, 2018 23:21
-
-
Save AndyG/30cb22c1fcfbb8400c19e483a6bcb3f3 to your computer and use it in GitHub Desktop.
Old Bold Rule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Matches: **This text should be bold.** | |
val PATTERN_BOLD = Pattern.compile("^\\*\\*([\\s\\S]+?)\\*\\*(?!\\*)") | |
class BoldRule : Parser.Rule(PATTERN_BOLD) { | |
override fun parse(matcher: Matcher, parser: Parser): Node { | |
val boldSpan = StyleSpan(Typeface.BOLD) | |
// Recursively parse inside the **delimiters** | |
val childNodes = parser.parse(matcher.group(1)) | |
return StyleNode(StyleSpan(Typeface.BOLD, childNodes)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment