Skip to content

Commit

Permalink
Update boxed text related files with processor term (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
JackMorganNZ committed Feb 14, 2017
1 parent 11612d5 commit 0883a03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions kordac/processors/BoxedTextBlockProcessor.py
Expand Up @@ -7,10 +7,10 @@
class BoxedTextBlockProcessor(BlockProcessor):
def __init__(self, ext, *args, **kwargs):
super().__init__(*args, **kwargs)
self.tag = 'boxed-text'
self.p_start = re.compile(ext.tag_patterns[self.tag]['pattern_start'])
self.p_end = re.compile(ext.tag_patterns[self.tag]['pattern_end'])
self.template = ext.jinja_templates[self.tag]
self.processor = 'boxed-text'
self.p_start = re.compile(ext.processor_patterns[self.processor]['pattern_start'])
self.p_end = re.compile(ext.processor_patterns[self.processor]['pattern_end'])
self.template = ext.jinja_templates[self.processor]

def test(self, parent, block):
return self.p_start.search(block) is not None or self.p_end.search(block) is not None
Expand All @@ -23,7 +23,7 @@ def run(self, parent, blocks):

# Found an end tag without processing a start tag first
if start_tag is None and end_tag is not None:
raise TagNotMatchedError(self.tag, block, 'end tag found before start tag')
raise TagNotMatchedError(self.processor, block, 'end tag found before start tag')

# Put left overs back on blocks, should be empty though
blocks.insert(0, block[start_tag.end():])
Expand Down Expand Up @@ -61,7 +61,7 @@ def run(self, parent, blocks):
# Error if we reached the end without closing the start tag
# or not all inner boxed-text tags were closed
if end_tag is None or inner_start_tags != inner_end_tags:
raise TagNotMatchedError(self.tag, block, 'no end tag found to close start tag')
raise TagNotMatchedError(self.processor, block, 'no end tag found to close start tag')

# Parse all the inner content of the boxed-text tags
content_tree = etree.Element('content')
Expand Down
6 changes: 3 additions & 3 deletions tests/BoxedTextTest.py
Expand Up @@ -12,10 +12,10 @@ class BoxedTextTest(BaseTestCase):

def __init__(self, *args, **kwargs):
BaseTestCase.__init__(self, *args, **kwargs)
self.tag_name = 'boxed-text'
self.processor_name = 'boxed-text'
self.ext = Mock()
self.ext.tag_patterns = BaseTestCase.loadTagPatterns(self)
self.ext.jinja_templates = {self.tag_name: BaseTestCase.loadJinjaTemplate(self, self.tag_name)}
self.ext.processor_patterns = BaseTestCase.loadProcessorPatterns(self)
self.ext.jinja_templates = {self.processor_name: BaseTestCase.loadJinjaTemplate(self, self.processor_name)}

def test_no_boxed_text(self):
test_string = self.read_test_file('no_boxed_text')
Expand Down

0 comments on commit 0883a03

Please sign in to comment.