Skip to content

Commit 273b0ca

Browse files
committed
🐛 FIX: Avoid fenced token mutation
implements: markdown-it/markdown-it@c9949dd
1 parent 3c98683 commit 273b0ca

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

markdown_it/renderer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def fence(self, tokens: Sequence[Token], idx: int, options, env) -> str:
239239
return highlighted + "\n"
240240

241241
# If language exists, inject class gently, without modifying original token.
242-
# May be, one day we will add .clone() for token and simplify this part, but
242+
# May be, one day we will add .deepClone() for token and simplify this part, but
243243
# now we prefer to keep things local.
244244
if info:
245245
i = token.attrIndex("class")
@@ -248,6 +248,7 @@ def fence(self, tokens: Sequence[Token], idx: int, options, env) -> str:
248248
if i < 0:
249249
tmpAttrs.append(["class", options.langPrefix + langName])
250250
else:
251+
tmpAttrs[i] = tmpAttrs[i][:]
251252
tmpAttrs[i][1] += " " + options.langPrefix + langName
252253

253254
# Fake token just to render attributes

0 commit comments

Comments
 (0)