@@ -12,6 +12,7 @@ def attrs_plugin(
1212 * ,
1313 after = ("image" , "code_inline" , "link_close" , "span_close" ),
1414 spans = False ,
15+ span_after = "link" ,
1516):
1617 """Parse inline attributes that immediately follow certain inline elements::
1718
@@ -42,7 +43,7 @@ def attrs_plugin(
4243 which all require post-parse processing.
4344 :param spans: If True, also parse attributes after spans of text, encapsulated by `[]`.
4445 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.
4647 """
4748
4849 def _attr_rule (state : StateInline , silent : bool ):
@@ -67,7 +68,7 @@ def _attr_rule(state: StateInline, silent: bool):
6768 return True
6869
6970 if spans :
70- md .inline .ruler .after ("link" , "span" , _span_rule )
71+ md .inline .ruler .after (span_after , "span" , _span_rule )
7172 md .inline .ruler .push ("attr" , _attr_rule )
7273
7374
@@ -98,6 +99,10 @@ def _span_rule(state: StateInline, silent: bool):
9899
99100 pos = labelEnd + 1
100101
102+ # check not at end of inline
103+ if pos >= maximum :
104+ return False
105+
101106 try :
102107 new_pos , attrs = parse (state .src [pos :])
103108 except ParseError :
0 commit comments