Skip to content

Commit

Permalink
blockquote: Fix invalid access
Browse files Browse the repository at this point in the history
  • Loading branch information
mrueg committed Oct 5, 2024
1 parent d5c41f6 commit 33e5d1f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
5 changes: 2 additions & 3 deletions renderer/blockquote.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}
Expand Down
4 changes: 4 additions & 0 deletions testdata/quotes-droph1.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,7 @@ <h3 id="should-not-be-picked-up-and-converted-into-blockquote-macro">Should not
<blockquote>
<p>[NOTE]</p>
</blockquote>
<blockquote>
<p><strong>TL;DR:</strong> Thingy!
More stuff</p>
</blockquote>
3 changes: 3 additions & 0 deletions testdata/quotes-stripnewlines.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,6 @@ <h3 id="should-not-be-picked-up-and-converted-into-blockquote-macro">Should not
<blockquote>
<p>[NOTE]</p>
</blockquote>
<blockquote>
<p><strong>TL;DR:</strong> Thingy! More stuff</p>
</blockquote>
4 changes: 4 additions & 0 deletions testdata/quotes.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,7 @@ <h3 id="should-not-be-picked-up-and-converted-into-blockquote-macro">Should not
<blockquote>
<p>[NOTE]</p>
</blockquote>
<blockquote>
<p><strong>TL;DR:</strong> Thingy!
More stuff</p>
</blockquote>
5 changes: 5 additions & 0 deletions testdata/quotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,8 @@
> [Hey !NOTE]
> [NOTE]


> **TL;DR:** Thingy!
> More stuff

0 comments on commit 33e5d1f

Please sign in to comment.