def assertMarkdownIgnoreWS(self, markdown, output): markdown = self.dedent(markdown) try: self.assertEqual(self.ignoreWhitespace(output), self.ignoreWhitespace(convert(markdown))) except AssertionError: raise
def assertMarkdown(self, markdown, output): markdown = self.dedent(markdown) output = self.dedent(output) try: self.assertEqual(output + '\n', convert(markdown) + '\n') except AssertionError: raise
def assertMarkdownNotEqual(self, markdown, output): markdown = self.dedent(markdown) output = self.dedent(output) try: self.assertNotEqual(output, convert(markdown)) except AssertionError: raise
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))
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)
def apply(self, content): # TODO(wualbert): rewrite markdown parser, or use a library. return markdown.convert(content)