Skip to content

Commit

Permalink
Added support for attr_lists on definition list terms.
Browse files Browse the repository at this point in the history
Like headers (h1-6) dt's can only be on one line, so we need to use
the header regex on dt's. This was implemented after considering a recent
[discussion](http://six.pairlist.net/pipermail/markdown-discuss/2013-July/002859.html)
on the markdown mailing list. Prior to that discussion, I never considered
that it was impossable to set block level attrs on dt's. Now it is.
  • Loading branch information
Waylan Limberg committed Jul 20, 2013
1 parent fbfa42d commit a9ca973
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions markdown/extensions/attr_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def run(self, doc):
if isBlockLevel(elem.tag):
# Block level: check for attrs on last line of text
RE = self.BLOCK_RE
if isheader(elem):
# header: check for attrs at end of line
if isheader(elem) or elem.tag == 'dt':
# header or def-term: check for attrs at end of line
RE = self.HEADER_RE
if len(elem) and elem.tag == 'li':
# special case list items. children may include a ul or ol.
Expand Down
11 changes: 10 additions & 1 deletion tests/extensions/attr_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,13 @@ <h1>And ordered lists <em class="inline">too</em></h1>
</ol>
</li>
<li>Item5</li>
</ol>
</ol>
<h1 class="block">Definition <em>lists</em></h1>
<dl>
<dt class="term">DT1</dt>
<dt class="term">DT2</dt>
<dd class="def">Some dd</dd>
<dd><em class="inline">dd</em></dd>
<dt><em class="inline">DT3</em></dt>
<dd>Some dd</dd>
</dl>
11 changes: 11 additions & 0 deletions tests/extensions/attr_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,14 @@ Also a codespan: `{: .someclass}`{: .foo}.
1. Item4-1
5. Item5

# Definition *lists* {.block}

DT1 {.term}
DT2 {.term}
: Some dd
{.def}
: *dd*{.inline}

*DT3*{.inline}
: Some dd

2 changes: 1 addition & 1 deletion tests/extensions/test.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[attr_list]
extensions=attr_list
extensions=attr_list,def_list

[codehilite]
extensions=codehilite
Expand Down

0 comments on commit a9ca973

Please sign in to comment.