def test_long_path(self): '''Tests that long paths with less than 31 characters work. ''' test_string = self.read_test_file(self.processor_name, 'long_path.md') processor = RelativeLinkPattern(self.ext, self.md.parser) self.assertIsNotNone(re.search(processor.compiled_re, test_string)) converted_test_string = markdown.markdown( test_string, extensions=[self.verto_extension]) expected_string = self.read_test_file(self.processor_name, 'long_path_expected.html', strip=True).strip() self.assertEqual(expected_string, converted_test_string)
def test_ignore_ftp_schema(self): '''Tests that non-relative links are not matched. ''' test_string = self.read_test_file(self.processor_name, 'ftp_schema.md') processor = RelativeLinkPattern(self.ext, self.md.parser) self.assertIsNone(re.search(processor.compiled_re, test_string)) converted_test_string = markdown.markdown( test_string, extensions=[self.verto_extension]) expected_string = self.read_test_file(self.processor_name, 'ftp_schema_expected.html', strip=True).strip() self.assertEqual(expected_string, converted_test_string)
def test_www_text(self): '''Tests that text that is similiar to an ignore is not ignored. ''' test_string = self.read_test_file(self.processor_name, 'www_text.md') processor = RelativeLinkPattern(self.ext, self.md.parser) self.assertIsNotNone(re.search(processor.compiled_re, test_string)) converted_test_string = markdown.markdown( test_string, extensions=[self.verto_extension]) expected_string = self.read_test_file(self.processor_name, 'www_text_expected.html', strip=True).strip() self.assertEqual(expected_string, converted_test_string)
def test_multiple_links(self): '''Tests that multiple links are processed. ''' test_string = self.read_test_file(self.processor_name, 'multiple_links.md') processor = RelativeLinkPattern(self.ext, self.md.parser) self.assertIsNotNone(re.search(processor.compiled_re, test_string)) converted_test_string = markdown.markdown( test_string, extensions=[self.verto_extension]) expected_string = self.read_test_file(self.processor_name, 'multiple_links_expected.html', strip=True).strip() self.assertEqual(expected_string, converted_test_string)
def test_trailing_question_mark(self): '''Tests that paths with trailing question marks. ''' test_string = self.read_test_file(self.processor_name, 'trailing_question_mark.md') processor = RelativeLinkPattern(self.ext, self.md.parser) self.assertIsNotNone(re.search(processor.compiled_re, test_string)) converted_test_string = markdown.markdown( test_string, extensions=[self.verto_extension]) expected_string = self.read_test_file( self.processor_name, 'trailing_question_mark_expected.html', strip=True).strip() self.assertEqual(expected_string, converted_test_string)
def test_basic_usage(self): '''Test common usage case. ''' test_string = self.read_test_file(self.processor_name, 'doc_example_basic_usage.md') processor = RelativeLinkPattern(self.ext, self.md.parser) self.assertIsNotNone(re.search(processor.compiled_re, test_string)) converted_test_string = markdown.markdown( test_string, extensions=[self.verto_extension]) expected_string = self.read_test_file( self.processor_name, 'doc_example_basic_usage_expected.html', strip=True).strip() self.assertEqual(expected_string, converted_test_string)
def buildProcessors(self, md, md_globals): ''' Populates internal variables for processors. This should not be called externally, this is used by the extendMarkdown method. Args: md: An instance of the markdown object being extended. md_globals: Global variables in the markdown module namespace. ''' self.preprocessors = [ ['comment', CommentPreprocessor(self, md), '_begin'], ['save-title', SaveTitlePreprocessor(self, md), '_end'], ['remove-title', RemoveTitlePreprocessor(self, md), '_end'], ] self.blockprocessors = [ # Markdown overrides ['heading', HeadingBlockProcessor(self, md.parser), '<hashheader'], # Single line (in increasing complexity) [ 'interactive-tag', InteractiveTagBlockProcessor(self, md.parser), '<paragraph' ], [ 'interactive-container', InteractiveContainerBlockProcessor(self, md.parser), '<paragraph' ], [ 'image-container', ImageContainerBlockProcessor(self, md.parser), '<paragraph' ], [ 'image-tag', ImageTagBlockProcessor(self, md.parser), '<paragraph' ], ['video', VideoBlockProcessor(self, md.parser), '<paragraph'], [ 'conditional', ConditionalProcessor(self, md.parser), '<paragraph' ], ['panel', PanelBlockProcessor(self, md.parser), '<paragraph'], [ 'blockquote', BlockquoteBlockProcessor(self, md.parser), '<paragraph' ], # Multiline ] self.inlinepatterns = [ # A special treeprocessor ['relative-link', RelativeLinkPattern(self, md), '_begin'], ['glossary-link', GlossaryLinkPattern(self, md), '_begin'], ['image-inline', ImageInlinePattern(self, md), '_begin'] ] scratch_ordering = '>inline' if 'hilite' not in self.compatibility else '<hilite' self.treeprocessors = [ ['scratch', ScratchTreeprocessor(self, md), scratch_ordering], [ 'scratch-inline', ScratchInlineTreeprocessor(self, md), '>inline' ], ] self.postprocessors = [] self.buildGenericProcessors(md, md_globals)