How to use Markdown - 10 common examples

To help you get started, we’ve selected a few Markdown examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vulndb / data / tests / test_valid_markdown.py View on Github external
def test_valid_markdown(self):
        invalid = []

        for language, _file, db_data in self.get_all_json():
            description = self.get_description(language, db_data['description']['$ref'])
            try:
                markdown(description)
            except:
                invalid.append(_file)

            guidance = self.get_fix(language, db_data['fix']['guidance']['$ref'])
            try:
                markdown(guidance)
            except:
                invalid.append(_file)

        self.assertEqual(invalid, [])
github django-wiki / django-wiki / tests / core / test_markdown.py View on Github external
def setUp(self):
        super().setUp()
        self.md = markdown.Markdown(extensions=[
            'extra',
            ResponsiveTableExtension()
        ])
        self.md_without = markdown.Markdown(extensions=['extra'])
github Python-Markdown / markdown / tests / test_apis.py View on Github external
def setUp(self):
        # Create comment node
        self.comment = markdown.util.etree.Comment('foo')
        if hasattr(markdown.util.etree, 'test_comment'):
            self.test_comment = markdown.util.etree.test_comment
        else:
            self.test_comment = markdown.util.etree.Comment
github Python-Markdown / markdown / tests / test_apis.py View on Github external
def testBaseExtention(self):
        """ Test that the base Extension class will raise NotImplemented. """
        self.assertRaises(
            NotImplementedError,
            markdown.Markdown, extensions=[markdown.extensions.Extension()]
        )
github Python-Markdown / markdown / tests / test_apis.py View on Github external
def buildExtension(self):
        """ Build an extension which registers fakeSerializer. """
        def fakeSerializer(elem):
            # Ignore input and return hardcoded output
            return '<div><p>foo</p></div>'

        class registerFakeSerializer(markdown.extensions.Extension):
            def extendMarkdown(self, md):
                md.output_formats['fake'] = fakeSerializer

        return registerFakeSerializer()
github dataiap / dataiap / resources / hacco / hacco.py View on Github external
raise TypeError("Missing the required 'outdir' keyword argument.")
    language = get_language(source)

    output = pygments.highlight(language["divider_text"].join(section["code_text"] for section in sections),
                                language["lexer"],
                                formatters.get_formatter_by_name("html"))

    output = output.replace(highlight_start, "").replace(highlight_end, "")
    fragments = re.split(language["divider_html"], output)
    for i, section in enumerate(sections):
        section["code_html"] = highlight_start + shift(fragments, "") + highlight_end
        try:
            docs_text = unicode(section["docs_text"])
        except UnicodeError:
            docs_text = unicode(section["docs_text"].decode('utf-8'))
        dh = markdown(preprocess(docs_text,
                                 i,
                                 preserve_paths=preserve_paths,
                                 outdir=outdir))
        section["docs_html"] = [{'text':dh}] if dh != '' else []
        section["num"] = i
github maciejczyzewski / hyhyhy / src / 3.x / collector.py View on Github external
def parse(self, content=[], html='', id=''):
        for file in config.sections:
            print (prf('OK'), 'Parsing file', file, '...')

            id = file.split('.')[-2].split('/')[-1]

            if file.split('.')[-1] == 'md':
                html = markdown.markdown(open(file, 'r').read(), extensions=['markdown.extensions.fenced_code'])
            elif file.split('.')[-1] == 'html':
                html = open(file, 'r').read()

            if config.settings.has_option('sections', id):
                content.append([html, config.settings.get('sections', id)])
            else:
                content.append([html, ' '])

        return content
github kianby / stacosys / stacosys / core / rss.py View on Github external
def generate_site(token):

    site = Site.select().where(Site.token == token).get()
    rss_title = get_template('rss_title_message').render(site=site.name)
    md = markdown.Markdown()

    items = []
    for row in (
        Comment.select()
        .join(Site)
        .where(Site.token == token, Comment.published)
        .order_by(-Comment.published)
        .limit(10)
    ):
        item_link = '%s://%s%s' % (config.get(config.RSS_PROTO), site.url, row.url)
        items.append(
            PyRSS2Gen.RSSItem(
                title='%s - %s://%s%s'
                % (config.get(config.RSS_PROTO), row.author_name, site.url, row.url),
                link=item_link,
                description=md.convert(row.content),
github ogom / python-mcider / mcider / converter.py View on Github external
def _get_slide_io2012(self, contents=None, extensions=[]):
        """ io-2012 style """
        md = Markdown(extensions=extensions)
        splits = [
            {'horizon': '----', 'style': 'none'},
            {'horizon': '____', 'style': 'smaller'},
            {'horizon': '****', 'style': 'fill'}
        ]

        styles = []
        for split in splits:
            styles.append(split['style'])
            horizon = '\n' + split['horizon'] + '\n'
            contents = contents.replace(horizon, '\n---\n' + split['style'] + '\n')

        pages = contents.split('\n---\n')

        # from pages to slides
        slides = []
github dragondjf / QMarkdowner / markdown / extensions / def_list.py View on Github external
state = 'looselist'
            terms = sibling.text.split('\n')
            parent.remove(sibling)
            # Aquire new sibling
            sibling = self.lastChild(parent)
        else:
            state = 'list'

        if sibling and sibling.tag == 'dl':
            # This is another item on an existing list
            dl = sibling
            if len(dl) and dl[-1].tag == 'dd' and len(dl[-1]):
                state = 'looselist'
        else:
            # This is a new list
            dl = etree.SubElement(parent, 'dl')
        # Add terms
        for term in terms:
            dt = etree.SubElement(dl, 'dt')
            dt.text = term
        # Add definition
        self.parser.state.set(state)
        dd = etree.SubElement(dl, 'dd')
        self.parser.parseBlocks(dd, [d])
        self.parser.state.reset()

        if theRest:
            blocks.insert(0, theRest)