def list_pages(pages): logging.debug(u'Listing %u pages.' % len(pages)) def link_line(title): return (' ' * title.count('/')) + '- ' + ( '[' + title + '](/' + title + ')' if ':' in title else '[[' + title + ']]') lines = [] for page in pages: title = page.title if '/' in title: parent = title[:title.rfind('/')] if not lines or lines[-1][0] != parent: parent_path = parent.split('/') for depth in xrange(1, len(parent_path) + 1): target = '/'.join(parent_path[:depth]) if not lines or not lines[-1][0].startswith(target): lines.append((target, link_line(target))) lines.append((title, link_line(title))) return render( 'index.html', { 'pages': pages, 'html': util.wikify( util.parse_markdown('\n'.join(line[1] for line in lines))), })
def list_pages(pages): logging.debug(u"Listing %u pages." % len(pages)) def link_line(title): return ( (" " * title.count("/")) + "- " + ("[" + title + "](/" + title + ")" if ":" in title else "[[" + title + "]]") ) lines = [] for page in pages: title = page.title if "/" in title: parent = title[: title.rfind("/")] if not lines or lines[-1][0] != parent: parent_path = parent.split("/") for depth in xrange(1, len(parent_path) + 1): target = "/".join(parent_path[:depth]) if not lines or not lines[-1][0].startswith(target): lines.append((target, link_line(target))) lines.append((title, link_line(title))) return render( "index.html", {"pages": pages, "html": util.wikify(util.parse_markdown("\n".join(line[1] for line in lines)))} )
def list_pages(pages): logging.debug(u'Listing %u pages.' % len(pages)) def link_line(title): return (' ' * title.count('/')) + '- ' + ('[' + title + '](/' + title + ')' if ':' in title else '[[' + title + ']]') lines = [] for page in pages: title = page.title if '/' in title: parent = title[:title.rfind('/')] if not lines or lines[-1][0] != parent: parent_path = parent.split('/') for depth in xrange(1, len(parent_path)+1): target = '/'.join(parent_path[:depth]) if not lines or not lines[-1][0].startswith(target): lines.append((target, link_line(target))) lines.append((title, link_line(title))) return render('index.html', { 'pages': pages, 'html': util.wikify(util.parse_markdown('\n'.join(line[1] for line in lines))), })
def markdown(text): return util.parse_markdown(text)
def test_empty_links(self): text = util.parse_markdown("[]()") self.assertEquals(text, "<p>[]()</p>")
def test_markdown_extensions(self): self.assertEquals(util.parse_markdown('# foo'), '<h1>foo</h1>')
def get_trade_partners_wiki(self): profile_md = self.get_wiki().content_md return parse_markdown(profile_md, Source())
def get_author_points(pkl_name="current_records"): author_points = load_obj(pkl_name) if author_points: return author_points print('Generating author points') return parse_markdown(get_records_page().content_md, Trader())