Skip to content

Commit

Permalink
feat(code): add syntax highlighting for Diff (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
VoltrexKeyva authored Feb 24, 2022
1 parent d8987f0 commit 567b61c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
13 changes: 13 additions & 0 deletions app/src/main/java/com/discord/simpleast/sample/SampleTexts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,18 @@ object SampleTexts {
```
"""

private const val CODE_BLOCK_DIFF = """
Diff code block:
```diff
- "This car is amzing!"
+ "This car is amazing!"
- 1
+ 100
- This house is not cheap.
+ This house is expensive.
```
"""

const val CODE_BLOCKS = """
# Code block samples
inlined:```py language code blocks need newline```
Expand All @@ -314,6 +326,7 @@ object SampleTexts {
$CODE_BLOCK_CRYSTAL
$CODE_BLOCK_JAVASCRIPT
$CODE_BLOCK_TYPESCRIPT
$CODE_BLOCK_DIFF
That should do it....
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,15 @@ object CodeRules {
keywords = TypeScript.KEYWORDS,
types = TypeScript.TYPES
)

val diffRules = listOf<Rule<R, Node<R>, S>>(
Pattern.compile("""^-.*""")
.toMatchGroupRule(stylesProvider = codeStyleProviders.keywordStyleProvider),
Pattern.compile("""^\+.*""")
.toMatchGroupRule(stylesProvider = codeStyleProviders.typesStyleProvider),
PATTERN_LEADING_WS_CONSUMER.toMatchGroupRule(),
PATTERN_TEXT.toMatchGroupRule()
)

return mapOf(
"kt" to kotlinRules,
Expand Down Expand Up @@ -242,7 +251,9 @@ object CodeRules {
"javascript" to javascriptRules,

"ts" to typescriptRules,
"typescript" to typescriptRules
"typescript" to typescriptRules,

"diff" to diffRules
)
}

Expand Down

0 comments on commit 567b61c

Please sign in to comment.