@@ -219,21 +219,18 @@ func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc pa
219
219
v .SetAttributeString ("class" , []byte ("gt-py-3 attention attention-" + attentionType ))
220
220
221
221
// create an emphasis to make it bold
222
+ attentionParagraph := ast .NewParagraph ()
222
223
emphasis := ast .NewEmphasis (2 )
223
224
emphasis .SetAttributeString ("class" , []byte ("attention-" + attentionType ))
224
- firstParagraph .InsertBefore (firstParagraph , firstTextNode , emphasis )
225
225
226
226
// capitalize first letter
227
227
attentionText := ast .NewString ([]byte (strings .ToUpper (string (attentionType [0 ])) + attentionType [1 :]))
228
228
229
- // replace the ![TYPE] with icon+Type
229
+ // replace the ![TYPE] with a dedicated paragraph of icon+Type
230
230
emphasis .AppendChild (emphasis , attentionText )
231
- for i := 0 ; i < 2 ; i ++ {
232
- lineBreak := ast .NewText ()
233
- lineBreak .SetSoftLineBreak (true )
234
- firstParagraph .InsertAfter (firstParagraph , emphasis , lineBreak )
235
- }
236
- firstParagraph .InsertBefore (firstParagraph , emphasis , NewAttention (attentionType ))
231
+ attentionParagraph .AppendChild (attentionParagraph , NewAttention (attentionType ))
232
+ attentionParagraph .AppendChild (attentionParagraph , emphasis )
233
+ firstParagraph .Parent ().InsertBefore (firstParagraph .Parent (), firstParagraph , attentionParagraph )
237
234
firstParagraph .RemoveChild (firstParagraph , firstTextNode )
238
235
firstParagraph .RemoveChild (firstParagraph , secondTextNode )
239
236
firstParagraph .RemoveChild (firstParagraph , thirdTextNode )
0 commit comments