diff options
Diffstat (limited to 'markdown/extensions/attr_list.py')
-rw-r--r-- | markdown/extensions/attr_list.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/markdown/extensions/attr_list.py b/markdown/extensions/attr_list.py index 9a67551..bc06786 100644 --- a/markdown/extensions/attr_list.py +++ b/markdown/extensions/attr_list.py @@ -3,7 +3,7 @@ Attribute List Extension for Python-Markdown ============================================ Adds attribute list syntax. Inspired by -[maruku](http://maruku.rubyforge.org/proposal.html#attribute_lists)'s +[Maruku](http://maruku.rubyforge.org/proposal.html#attribute_lists)'s feature of the same name. See <https://Python-Markdown.github.io/extensions/attr_list> @@ -77,33 +77,33 @@ class AttrListTreeprocessor(Treeprocessor): def run(self, doc): for elem in doc.iter(): if self.md.is_block_level(elem.tag): - # Block level: check for attrs on last line of text + # Block level: check for `attrs` on last line of text RE = self.BLOCK_RE if isheader(elem) or elem.tag in ['dt', 'td', 'th']: - # header, def-term, or table cell: check for attrs at end of element + # header, def-term, or table cell: check for attributes at end of element RE = self.HEADER_RE if len(elem) and elem.tag == 'li': - # special case list items. children may include a ul or ol. + # special case list items. children may include a `ul` or `ol`. pos = None - # find the ul or ol position + # find the `ul` or `ol` position for i, child in enumerate(elem): if child.tag in ['ul', 'ol']: pos = i break if pos is None and elem[-1].tail: - # use tail of last child. no ul or ol. + # use tail of last child. no `ul` or `ol`. m = RE.search(elem[-1].tail) if m: self.assign_attrs(elem, m.group(1)) elem[-1].tail = elem[-1].tail[:m.start()] elif pos is not None and pos > 0 and elem[pos-1].tail: - # use tail of last child before ul or ol + # use tail of last child before `ul` or `ol` m = RE.search(elem[pos-1].tail) if m: self.assign_attrs(elem, m.group(1)) elem[pos-1].tail = elem[pos-1].tail[:m.start()] elif elem.text: - # use text. ul is first child. + # use text. `ul` is first child. m = RE.search(elem.text) if m: self.assign_attrs(elem, m.group(1)) @@ -127,7 +127,7 @@ class AttrListTreeprocessor(Treeprocessor): # clean up trailing #s elem.text = elem.text.rstrip('#').rstrip() else: - # inline: check for attrs at start of tail + # inline: check for `attrs` at start of tail if elem.tail: m = self.INLINE_RE.match(elem.tail) if m: @@ -135,7 +135,7 @@ class AttrListTreeprocessor(Treeprocessor): elem.tail = elem.tail[m.end():] def assign_attrs(self, elem, attrs): - """ Assign attrs to element. """ + """ Assign `attrs` to element. """ for k, v in get_attrs(attrs): if k == '.': # add to class @@ -145,7 +145,7 @@ class AttrListTreeprocessor(Treeprocessor): else: elem.set('class', v) else: - # assign attr k with v + # assign attribute `k` with `v` elem.set(self.sanitize_name(k), v) def sanitize_name(self, name): |