Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberZHG committed May 31, 2017
2 parents 968e0fe + a0a657a commit 343247f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
6 changes: 2 additions & 4 deletions markdown/parser/block_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ def check_indent(code, index, align=0):
return True, index + space_num

def get_unclosed(self, auxiliary):
"""
Get last unclosed element.
"""Get last unclosed element.
Args:
auxiliary: A dict.
Expand All @@ -65,8 +64,7 @@ def get_unclosed(self, auxiliary):
return auxiliary[self.AUX_UNCLOSED]

def is_interrupting(self, auxiliary):
"""
Whether it is interrupting a paragraph.
"""Whether it is interrupting a paragraph.
Args:
auxiliary: A dict.
Expand Down
3 changes: 2 additions & 1 deletion markdown/parser/container_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class ContainerElementParser(object):
AUX_ALIGN = 'align' # The align offset for lists.

def __init__(self, config):
super(ContainerElementParser, self).__init__(config)
super(ContainerElementParser, self).__init__()
self.config = config

def get_align(self, auxiliary):
"""
Expand Down
35 changes: 33 additions & 2 deletions markdown/parser/parser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/usr/bin/env python
# coding=utf-8

from markdown.parser.container_parsers import (ContainerElementParser,
BlockQuoteMarkerParser,
ListMarkerParser)
from markdown.parser.container_elements import (BlockQuoteElement,
ListElement)
from markdown.parser.block_parsers import (BlockElementParser,
ParagraphParser,
AtxHeadingParser,
Expand All @@ -23,8 +28,8 @@ def __init__(self, config=None):
self._blocks = [] # The parsed block elements.

self._paragraph_parser = ParagraphParser(config)
# self._block_quote_marker_parser = BlockQuoteMarkerParser(config)
# self._list_marker_parser = ListMarkerParser(config)
self._block_quote_marker_parser = BlockQuoteMarkerParser(config)
self._list_marker_parser = ListMarkerParser(config)
self._interrupt_parsers = []
self._container_parsers = []
self._block_parsers = []
Expand Down Expand Up @@ -104,6 +109,15 @@ def parse_container_markers(self, line):
return 0

def parse_continuation(self, line, index):
"""Continue parsing block elements that could span multiple lines.
Args:
line: line of code.
index: start index
Returns:
Returns true if succeed, otherwise false.
"""
if len(self._blocks) > 0 and not self._blocks[-1].closed:
if isinstance(self._blocks[-1], ParagraphElement):
has_interrupted = False
Expand All @@ -125,6 +139,15 @@ def parse_continuation(self, line, index):
return False

def parse_blocks(self, line, index):
"""Parse block elements.
Args:
line: line of code.
index: start index
Returns:
None
"""
for block_parser in self._block_parsers:
elem = block_parser.parse(line, index)
if elem is not None:
Expand All @@ -135,6 +158,14 @@ def parse_blocks(self, line, index):
break

def parse_subs(self, elem):
"""Parse span elements recursively.
Args:
elem: the elements that contain sub-elements.
Returns:
The parsed element.
"""
if isinstance(elem, TextualContentElement):
return elem
try:
Expand Down

0 comments on commit 343247f

Please sign in to comment.