diff --git a/app/src/main/java/com/discord/simpleast/sample/SampleTexts.kt b/app/src/main/java/com/discord/simpleast/sample/SampleTexts.kt index 80a9988..9839b64 100644 --- a/app/src/main/java/com/discord/simpleast/sample/SampleTexts.kt +++ b/app/src/main/java/com/discord/simpleast/sample/SampleTexts.kt @@ -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``` @@ -314,6 +326,7 @@ object SampleTexts { $CODE_BLOCK_CRYSTAL $CODE_BLOCK_JAVASCRIPT $CODE_BLOCK_TYPESCRIPT + $CODE_BLOCK_DIFF That should do it.... """ diff --git a/simpleast-core/src/main/java/com/discord/simpleast/code/CodeRules.kt b/simpleast-core/src/main/java/com/discord/simpleast/code/CodeRules.kt index 4748b2c..5fc71ce 100644 --- a/simpleast-core/src/main/java/com/discord/simpleast/code/CodeRules.kt +++ b/simpleast-core/src/main/java/com/discord/simpleast/code/CodeRules.kt @@ -214,6 +214,15 @@ object CodeRules { keywords = TypeScript.KEYWORDS, types = TypeScript.TYPES ) + + val diffRules = listOf, 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, @@ -242,7 +251,9 @@ object CodeRules { "javascript" to javascriptRules, "ts" to typescriptRules, - "typescript" to typescriptRules + "typescript" to typescriptRules, + + "diff" to diffRules ) }