Skip to content

Commit

Permalink
Fix: Code Blocks with no immediate text (#23)
Browse files Browse the repository at this point in the history
See test `CodeRulesTest.noLanguageBlocked`
  • Loading branch information
lytefast authored Nov 11, 2020
1 parent f6a1758 commit f3c5142
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion simpleast-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
minSdkVersion 21
targetSdkVersion 30
versionCode 28
versionName "2.1.2"
versionName "2.1.3"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object CodeRules {
* Examples:
* inlined ```test```
* inlined ```kt language code blocks need newline```
* inlined block start ```kt
* inlined block start ```
* fun test()
* ```
*
Expand All @@ -38,7 +38,7 @@ object CodeRules {
* ```
*/
val PATTERN_CODE_BLOCK: Pattern =
Pattern.compile("""^```(?:([\w+\-.]+?)(\s*\n))?([^\n].*?)\n*```""", Pattern.DOTALL)
Pattern.compile("""^```(?:([\w+\-.]+?)?(\s*\n))?([^\n].*?)\n*```""", Pattern.DOTALL)

val PATTERN_CODE_INLINE: Pattern =
Pattern.compile("""^`(?:\s*)([^\n].*?)\n*`""", Pattern.DOTALL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ class CodeRulesTest {
ast.assertNodeContents<CodeNode<*>>("code", "spaces ", "some text")
}

@Test
fun noLanguageBlocked() {
val ast = parser.parse("""
Sample: ```
**block text**
```
""".trimIndent(), TestState())

ast.assertNodeContents<CodeNode<*>>("**block text**")
}

@Test
fun commentsRust() {
val ast = parser.parse("""
Expand Down

0 comments on commit f3c5142

Please sign in to comment.