Пример #1
0
 def assertMarkdownIgnoreWS(self, markdown, output):
     markdown = self.dedent(markdown)
     try:
         self.assertEqual(self.ignoreWhitespace(output),
                          self.ignoreWhitespace(convert(markdown)))
     except AssertionError:
         raise
Пример #2
0
 def assertMarkdown(self, markdown, output):
     markdown = self.dedent(markdown)
     output = self.dedent(output)
     try:
         self.assertEqual(output + '\n', convert(markdown) + '\n')
     except AssertionError:
         raise
Пример #3
0
 def assertMarkdownNotEqual(self, markdown, output):
     markdown = self.dedent(markdown)
     output = self.dedent(output)
     try:
         self.assertNotEqual(output, convert(markdown))
     except AssertionError:
         raise
Пример #4
0
 def assertMarkdownNotEqual(self, markdown, output):
     markdown = self.dedent(markdown)
     output = self.dedent(output)
     try:
         self.assertNotEqual(output, convert(markdown))
     except AssertionError:
         raise
Пример #5
0
 def assertMarkdownIgnoreWS(self, markdown, output):
     markdown = self.dedent(markdown)
     try:
         self.assertEqual(self.ignoreWhitespace(output),
                          self.ignoreWhitespace(convert(markdown)))
     except AssertionError:
         raise
Пример #6
0
 def assertMarkdown(self, markdown, output):
     markdown = self.dedent(markdown)
     output = self.dedent(output)
     try:
         self.assertEqual(output + '\n', convert(markdown) + '\n')
     except AssertionError:
         raise
Пример #7
0
    def testWhitespace(self):
        simple = """
        Lots       of  whitespace
        =
        """
        expect = '<h1 id="lots-of-whitespace">Lots       of  whitespace</h1>'
        self.assertMarkdown(simple, expect)

        simple = '   leading whitespace\n='
        expect = '<h1 id="leading-whitespace">leading whitespace</h1>'
        self.assertEqual(expect, convert(simple))
Пример #8
0
    def testWhitespace(self):
        simple = """
        Lots       of  whitespace
        =
        """
        expect = '<h1 id="lots-of-whitespace">Lots       of  whitespace</h1>'
        self.assertMarkdown(simple, expect)

        simple = '   leading whitespace\n='
        expect = '<h1 id="leading-whitespace">leading whitespace</h1>'
        self.assertEqual(expect, convert(simple))
Пример #9
0
def main(args, configs):
    if not os.path.exists(args.source):
        log.warn('File ' + args.source + ' does not exist.')
        exit(1)
    elif not os.path.isfile(args.source):
        log.warn(args.source + ' is not a valid file')
        exit(1)
    result = link(args.source)
    if args.markdown:
        result = convert(result)
    result = substitutions(result,
                           configs.get('SUBSTITUTIONS', []),
                           args)
    result, cache = retrieve_blocks(result)
    if args.destination:
        file_write(args.destination, result)
        log.info('Result can be found in ' + args.destination)
    else:
        log.log('--- BEGIN RESULT ---', args.quiet)
        log.log(result)
        log.log('--- END RESULT ---', args.quiet)
Пример #10
0
 def apply(self, content):
     # TODO(wualbert): rewrite markdown parser, or use a library.
     return markdown.convert(content)