blockquote: Fix invalid access

This commit is contained in:
Manuel Rüger 2024-10-05 23:56:07 +02:00
parent d5c41f6f1f
commit 33e5d1ff19
5 changed files with 18 additions and 3 deletions

View File

@ -118,13 +118,12 @@ func ParseBlockQuoteType(node ast.Node, source []byte) BlockQuoteType {
// Classifying the next text type node (midNode) will confirm that.
if t == None {
midNode := node.NextSibling()
rightNode := midNode.NextSibling()
if midNode.Kind() == ast.KindText {
if midNode != nil && midNode.Kind() == ast.KindText {
rightNode := midNode.NextSibling()
midTextNode := midNode.(*ast.Text)
if rightNode != nil && rightNode.Kind() == ast.KindText {
rightTextNode := rightNode.(*ast.Text)
if string(n.Text(source)) == "[" && string(rightTextNode.Text(source)) == "]" {
t = ghAlertsClassifier.ClassifyingBlockQuote(string(midTextNode.Text(source)))
}

View File

@ -98,3 +98,7 @@ b</p>
<blockquote>
<p>[NOTE]</p>
</blockquote>
<blockquote>
<p><strong>TL;DR:</strong> Thingy!
More stuff</p>
</blockquote>

View File

@ -96,3 +96,6 @@
<blockquote>
<p>[NOTE]</p>
</blockquote>
<blockquote>
<p><strong>TL;DR:</strong> Thingy! More stuff</p>
</blockquote>

View File

@ -99,3 +99,7 @@ b</p>
<blockquote>
<p>[NOTE]</p>
</blockquote>
<blockquote>
<p><strong>TL;DR:</strong> Thingy!
More stuff</p>
</blockquote>

5
testdata/quotes.md vendored
View File

@ -88,3 +88,8 @@
> [Hey !NOTE]
> [NOTE]
> **TL;DR:** Thingy!
> More stuff