Skip to content

Commit

Permalink
Fix cast crash that could happen in markdown blockquote
Browse files Browse the repository at this point in the history
After 0.19.1, this started crashing:

```
> *Note*
> ...
```

due to a force cast I was doing foolishly (which broke because "*Note*" is an
EmphasisNode, not a Text node)

Changed logic from `child as Text` to `child as? Text`
  • Loading branch information
bitspittle committed Dec 29, 2024
1 parent e5d3477 commit 0eb5c3d
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ fun SilkCalloutBlockquoteHandler(
): NodeScope.(BlockQuote) -> String {
return { blockQuote ->
val silkCallout = blockQuote.firstChild.firstChild?.let { firstChild ->
firstChild as Text
val regex = """\[!([^ ]+)( "(.*)")?]""".toRegex()
@Suppress("NAME_SHADOWING")
val firstChild = firstChild as? Text ?: return@let null
val regex = """\[!([^ ]+)( "(.*)")?]""".toRegex() // [!TYPE "LABEL"]
val typeMatch = regex.find(firstChild.literal) ?: return@let null
firstChild.literal = firstChild.literal.substringAfter(typeMatch.value)

Expand Down

0 comments on commit 0eb5c3d

Please sign in to comment.