Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 0.3.3 - 2022-12-06

🐛 FIX: span with end of inline before attrs

## 0.3.2 - 2022-12-05

- ✨ NEW: Port `admon` plugin by @KyleKing ([#53](https://github.com/executablebooks/mdit-py-plugins/pull/53))
Expand Down
2 changes: 1 addition & 1 deletion mdit_py_plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.2"
__version__ = "0.3.3"
9 changes: 7 additions & 2 deletions mdit_py_plugins/attrs/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def attrs_plugin(
*,
after=("image", "code_inline", "link_close", "span_close"),
spans=False,
span_after="link",
):
"""Parse inline attributes that immediately follow certain inline elements::

Expand Down Expand Up @@ -42,7 +43,7 @@ def attrs_plugin(
which all require post-parse processing.
:param spans: If True, also parse attributes after spans of text, encapsulated by `[]`.
Note Markdown link references take precedence over this syntax.

:param span_after: The name of an inline rule after which spans may be specified.
"""

def _attr_rule(state: StateInline, silent: bool):
Expand All @@ -67,7 +68,7 @@ def _attr_rule(state: StateInline, silent: bool):
return True

if spans:
md.inline.ruler.after("link", "span", _span_rule)
md.inline.ruler.after(span_after, "span", _span_rule)
md.inline.ruler.push("attr", _attr_rule)


Expand Down Expand Up @@ -98,6 +99,10 @@ def _span_rule(state: StateInline, silent: bool):

pos = labelEnd + 1

# check not at end of inline
if pos >= maximum:
return False

try:
new_pos, attrs = parse(state.src[pos:])
except ParseError:
Expand Down
7 changes: 7 additions & 0 deletions tests/fixtures/attrs.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ spans: simple
<p><span id="id" class="b">a</span>c</p>
.

spans: end of inline before attrs
.
[a]
.
<p>[a]</p>
.

spans: space between brace and attrs
.
[a] {.b}
Expand Down