Skip to content
This repository has been archived by the owner on Aug 7, 2020. It is now read-only.

Commit

Permalink
Add TokenSet.insert_before
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Mar 10, 2020
1 parent 88fdead commit baa9d33
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion mistletoe/parse_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ def insert_after(self, token, after_token):
token_list.insert(indx, (token, token.__name__))
self._tokens = OrderedDict(token_list)

def insert_before(self, token, before_token):
assert before_token in self._tokens
indx = list(self._tokens.keys()).index(before_token)
token_list = list(self._tokens.items())
token_list.insert(indx, (token, token.__name__))
self._tokens = OrderedDict(token_list)


class ParseContext:
def __init__(
Expand Down Expand Up @@ -86,7 +93,7 @@ def __init__(
else:
self._link_definitions = link_definitions
if foot_definitions is None:
self._foot_definitions = {}
self._foot_definitions = OrderedDict()
else:
self._foot_definitions = foot_definitions

Expand Down

0 comments on commit baa9d33

Please sign in to comment.