Skip to content

Commit

Permalink
fix(yaml): not support $ prefix key (#20)
Browse files Browse the repository at this point in the history
Signed-off-by: Black-Hole1 <bh@bugs.cc>
  • Loading branch information
BlackHole1 committed Jul 14, 2023
1 parent ee01734 commit 8df1dce
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ data class Words(

fun parseYAML(file: File): List<String>? {
return try {
val data = Yaml.decodeFromString(Words.serializer(), file.readText())
val raw = file.readText()
// See: https://github.com/Him188/yamlkt/issues/52
val content = raw.replace(Regex("^\\$.+:.+$", setOf(RegexOption.MULTILINE, RegexOption.IGNORE_CASE)), "")

val data = Yaml.decodeFromString(Words.serializer(), content)
return data.words
} catch (e: Exception) {
null
Expand Down

0 comments on commit 8df1dce

Please sign in to comment.