def handle_ex(ex): result = '\n'.join([handle_line(x) for x in (';##' + ex).splitlines()]) if eval_md: return md(result) else: return result
def Creating(): with open('content/sidebar.md') as files: side = md(files.read(), extras=['metadata']) POSTS = {} for markdown_post in os.listdir('content/posts'): file_path = os.path.join('content/posts', markdown_post) with open(file_path, 'r') as file: q = Unicode(file.read()) POSTS[markdown_post] = md(q, extras=['metadata', 'wiki-tables']) env = Environment(loader=PackageLoader('main', 'templates')) home_template = env.get_template('index.html') post_template = env.get_template('post.html') about_template = env.get_template('about.html') posts_metadata = [POSTS[post].metadata for post in POSTS] text = create_temp(home_template, posts_metadata, side.metadata) with open('output/index.html', 'w+') as file: file.write(text) for post in POSTS: post_meta = POSTS[post].metadata post_data = { 'content': POSTS[post], 'title': post_meta['title'], 'data': post_meta['date'], 'img': post_meta['thumbnail'], 'slug': post_meta['slug'], 'summary': post_meta['summary'], } text = create_temp(post_template, post_data, side.metadata) post_file_path = 'output/posts/{slug}.html'.format( slug=post_meta['slug']) print(post_file_path) os.makedirs(os.path.dirname(post_file_path), exist_ok=True) with open(post_file_path, 'w') as file: file.write(text) file.close() with open('content/info.md') as file: info = md(file.read(), extras=['metadata']) info = info.metadata text = create_temp(about_template, info, side.metadata) with open('output/about.html', 'w+') as file: file.write(text)
def md_2_html(md_text): """ converts markdown to html parameters: md_text: markdown str as input returns: str, as html markup """ markdowner = md() html = markdowner.convert(md_text) return html
def pretty_fine_print(self): if '<' in self.fine_print: return self.fine_print from markdown2 import markdown as md return md(self.fine_print)
def get_validation_info(self): from markdown2 import markdown as md if self.validation_info is not None: return md(self.validation_info) return ''
def markdown(s): return md(s)