Skip to content

Instantly share code, notes, and snippets.

@AndyG
Last active April 3, 2018 23:21
Show Gist options
  • Save AndyG/30cb22c1fcfbb8400c19e483a6bcb3f3 to your computer and use it in GitHub Desktop.
Save AndyG/30cb22c1fcfbb8400c19e483a6bcb3f3 to your computer and use it in GitHub Desktop.
Old Bold Rule
// 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