@@ -12,6 +12,7 @@ def attrs_plugin(
12
12
* ,
13
13
after = ("image" , "code_inline" , "link_close" , "span_close" ),
14
14
spans = False ,
15
+ span_after = "link" ,
15
16
):
16
17
"""Parse inline attributes that immediately follow certain inline elements::
17
18
@@ -42,7 +43,7 @@ def attrs_plugin(
42
43
which all require post-parse processing.
43
44
:param spans: If True, also parse attributes after spans of text, encapsulated by `[]`.
44
45
Note Markdown link references take precedence over this syntax.
45
-
46
+ :param span_after: The name of an inline rule after which spans may be specified.
46
47
"""
47
48
48
49
def _attr_rule (state : StateInline , silent : bool ):
@@ -67,7 +68,7 @@ def _attr_rule(state: StateInline, silent: bool):
67
68
return True
68
69
69
70
if spans :
70
- md .inline .ruler .after ("link" , "span" , _span_rule )
71
+ md .inline .ruler .after (span_after , "span" , _span_rule )
71
72
md .inline .ruler .push ("attr" , _attr_rule )
72
73
73
74
@@ -98,6 +99,10 @@ def _span_rule(state: StateInline, silent: bool):
98
99
99
100
pos = labelEnd + 1
100
101
102
+ # check not at end of inline
103
+ if pos >= maximum :
104
+ return False
105
+
101
106
try :
102
107
new_pos , attrs = parse (state .src [pos :])
103
108
except ParseError :
0 commit comments