Skip to content

Commit

Permalink
Add mechanism to prevent header ID counter resetting
Browse files Browse the repository at this point in the history
  • Loading branch information
Crozzers committed Dec 3, 2023
1 parent efd824f commit 71a7afd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ def __init__(self, html4tags=False, tab_width=4, safe_mode=None,
if not isinstance(self.extras['header-ids'], dict):
self.extras['header-ids'] = {
'mixed': False,
'prefix': self.extras['header-ids']
'prefix': self.extras['header-ids'],
'reset-count': True
}

if 'break-on-newline' in self.extras:
Expand Down Expand Up @@ -292,7 +293,8 @@ def _setup_extras(self):
self.footnotes = OrderedDict()
self.footnote_ids = []
if "header-ids" in self.extras:
self._count_from_header_id = defaultdict(int)
if not hasattr(self, '_count_from_header_id') or self.extras['header-ids'].get('reset-count', False):
self._count_from_header_id = defaultdict(int)
if "metadata" in self.extras:
self.metadata = {}

Expand Down

0 comments on commit 71a7afd

Please sign in to comment.