Skip to content

Commit

Permalink
renamed and re-ordered method
Browse files Browse the repository at this point in the history
seems more appropriate this way
  • Loading branch information
FND committed Feb 24, 2014
1 parent 8ea5fb4 commit 320b923
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions markdown_checklist/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class ChecklistPostprocessor(Postprocessor):

pattern = re.compile(r'<li>\[([ Xx])\]')

def checklister(self, match):
state = match.group(1);
checked = ' checked' if state != ' ' else ''
return '<li><input type="checkbox" disabled%s>' % checked

def run(self, html):
html = re.sub(self.pattern, self.checklister, html)
html = re.sub(self.pattern, self._convert_checkbox, html)
before = '<ul>\n<li><input type="checkbox"'
after = before.replace('<ul>', '<ul class="checklist">')
return html.replace(before, after)

def _convert_checkbox(self, match):
state = match.group(1)
checked = ' checked' if state != ' ' else ''
return '<li><input type="checkbox" disabled%s>' % checked

0 comments on commit 320b923

Please sign in to comment.