本文整理汇总了Python中markdown2.markdown函数的典型用法代码示例。如果您正苦于以下问题:Python markdown函数的具体用法?Python markdown怎么用?Python markdown使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了markdown函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: render
def render(
self,
jobtype="",
location="",
title="",
description="",
skills="",
about="",
company="",
image="",
template="job_post.html",
job_id=1,
):
template_values = {
"jobtype": jobtype,
"location": location,
"title": title,
"description": markdown2.markdown(description),
"skills": markdown2.markdown(skills),
"about": markdown2.markdown(about),
"company": company,
"image": image,
"job_id": job_id,
}
template = jinja_environment.get_template(template)
self.response.out.write(template.render(template_values))
开发者ID:sandeeprv,项目名称:Udacity,代码行数:26,代码来源:anawesomewebappproject.py
示例2: get_object
def get_object(self, queryset=None):
obj = super(ATDDDetailView, self).get_object()
obj.suitename = markdown2.markdown(self.convert_markdown_split_line(obj.suitename), extras=['fenced-code-blocks'], )
obj.testname = markdown2.markdown(self.convert_markdown_split_line(obj.testname), extras=['fenced-code-blocks'], )
#obj.question = markdown2.markdown(self.convert_markdown_split_line(obj.question), extras=['fenced-code-blocks'], )
#obj.assumption = markdown2.markdown(self.convert_markdown_split_line(obj.assumption), extras=['fenced-code-blocks'], )
return obj
开发者ID:pigxo,项目名称:one-webtool-for-scrum,代码行数:7,代码来源:views.py
示例3: show_post
def show_post(id=None):
if id:
db = get_db()
cur = db.execute('select id, title, content from blog where id = ?', [id])
row = cur.fetchone()
if row:
result = []
content = markdown2.markdown(row["content"], extras=["code-friendly","code-color", "cuddled-lists","tables","footnotes","pyshell","toc"])
#content = Markup(markdown.markdown(row["content"]))
result.append((row["id"], row["title"],content))
return render_template('blog.html', result=result)
#return render_template('show_blog.html', **locals())
else:
abort(404)
else:
db = get_db()
cur = db.execute('select id, title, content from blog where navigation=0 order by id desc')
rows = cur.fetchall()
#content = Markup(markdown.markdown(entries))
#print entries
result = []
for row in rows:
content = markdown2.markdown(row["content"], extras=["code-friendly","code-color", "cuddled-lists","tables","footnotes","pyshell","toc"])
result.append((row["id"], row["title"], content))
return render_template('blog.html', result=result)
开发者ID:hacklogic,项目名称:PyMarkBlog,代码行数:27,代码来源:pymark.py
示例4: convert
def convert():
markdownInput = open(args.markdown).read() # Read markdown file into markdownInput
title = markdownInput.split('\n')[:2] # Take the first line and make it the <title>
block = markdownInput.split('\n')[2:] # Strip the title out of the entry
block = '\n'.join(block)
markdownHTML = markdown2.markdown(block) # Convert markdown to HTML
if args.template:
title = str(title[0])
template = open('templates/' + args.template).read() # Load template specified by -t flag
else:
title = str(title[0]) + '\n' + str(title[1])
title = markdown2.markdown(title)
template = "{{title}}\n{{block}}"
htmlOutput = ''
for line in template:
htmlOutput += line # Turns converted read template html to a multi line string, helps for regex subs
htmlOutput = re.sub("{{title}}", title, htmlOutput) # Sets <title> if not index
htmlOutput = re.sub("{{datetime}}", datetime.datetime.now().ctime(), htmlOutput) # Insert date and time i.e., Wed Apr 16 17:18:56 2014
htmlOutput = re.sub("{{block}}", markdownHTML, htmlOutput) # Insert converted markdown to location of {{block}} in template
try:
open('webserver/' + args.markdown.strip(".md") + ".html", "w").write(htmlOutput) # Create html and write it
print "Generated %s" % (args.markdown.strip('.md') + '.html')
except IOError:
print """Path could not be found. Please make sure the folder hierarchy matches in
开发者ID:BlastarIndia,项目名称:squirrel,代码行数:30,代码来源:squirrel.py
示例5: article_publish
def article_publish(request):
if request.method == "POST":
user_name = request.session['username']
user = User.objects.get(name=user_name)
article_title = request.POST.get("title")
abstract = request.POST.get("abstract")
article_body = request.POST.get("content")
catogory_name = request.POST.get("category")
category = Category.objects.get(name=catogory_name)
article_status = request.POST.get("status")
article_body = markdown2.markdown(article_body)
Article.objects.create(title=article_title,body=article_body,status=article_status,abstract=abstract,auther=user,category=category)
article_list = Article.objects.filter(status = 'p')
for articles in article_list:
articles.body = markdown2.markdown(articles.body,)
user_count = User.objects.all().count()
article_count = Article.objects.all().count()
latest_login_user = User.objects.all().order_by('-last_login_time')[:5]
category_list = Category.objects.all().order_by('name')
popular_article = Article.objects.all().order_by('-likes')[:5]
views_article = Article.objects.all().order_by('views')[:5]
new_comment_list = []
new_comment_list = Comment.objects.filter(comment_reminder=user,comment_status="N")
comment_count_user = len(new_comment_list)
return render(request,"index.html",{"comment_list_user":new_comment_list,"comment_count_user":comment_count_user,"latest_login_user":latest_login_user,"user_count":user_count,"article_count":article_count,"article_list":article_list,"category_list":category_list,"popular_article":popular_article,"views_article":views_article})
开发者ID:jimforit,项目名称:JimBlog,代码行数:26,代码来源:views.py
示例6: rebuild_cache
def rebuild_cache(f):
#Grab data from the spreadsheet in one request
#Comes back as a list of lists
gdocAsLists = open_spreadsheet()
#Parse this data into layerName: {'metadata info': 'value'} format
md = gdoc_lists_to_layer_dict(gdocAsLists)
with io.open(f, 'w', encoding='utf8') as cache:
cache.write(u'{')
i = 0
for layer in md.keys():
if i > 0:
cache.write(u', ')
cache.write(u'"{0!s}": {{'.format(layer))
j = 0
for field in md[layer].keys():
if j > 0:
cache.write(u', ')
if field in ['title', 'translated_title', 'subtitle', 'tags', 'learn_more', 'download_data', 'agol_id', 'map_service', 'amazon_link']:
cache.write(u'"{0!s}": "{1!s}"'.format(field, markdown2.markdown(md[layer][field], extras=["code-friendly"]).strip().replace('{', '\\{').replace('}', '\\}').replace('"', '\\"').replace(u'\n', u'<br>').replace(u'</p><br>', u'</p>').replace(u'<br><p>', u'<p>').replace(u'<p>', u'').replace(u'</p>', u'')))
else:
cache.write(u'"{0!s}": "{1!s}"'.format(field, markdown2.markdown(md[layer][field], extras=["code-friendly"]).strip().replace('{', '\\{').replace('}', '\\}').replace('"', '\\"').replace(u'\n', u'<br>').replace(u'</p><br>', u'</p>').replace(u'<br><p>', u'<p>').replace(u'<p></p>', u'')))
j += 1
cache.write(u'}')
i += 1
cache.write(u'}')
print 'done rebuild'
开发者ID:wri,项目名称:gfw-sync,代码行数:33,代码来源:metadata_api.py
示例7: comment_commit
def comment_commit(request,article_id):
article = Article.objects.get(id=article_id)
article_url = article.get_absolute_url()
comment_error = ""
if request.method == "POST":
user_name = request.session["username"]
user = User.objects.get(name=user_name)
comment_content = request.POST.get("comment")
if comment_content != "":
subject = '您有一条来自JimBlog的评论'
text_content = '#Comment:'+article.title+'\n\n'+user.name+":"+'\n'+comment_content+'\n'+\
'---------------------------------------------------------------------------'+'\n'+\
'URL:'+'http://127.0.0.0.1:8000'+article_url
comment_content = markdown2.markdown(comment_content)
comment_reminder = User.objects.get(name=article.auther.name)
from_email = settings.DEFAULT_FROM_EMAIL
msg = EmailMultiAlternatives(subject, text_content, from_email, [comment_reminder.email])
msg.send()
comment_obj = Comment.objects.create(comment_user = user,comment_content = comment_content,article=article,comment_status='N',comment_reminder=comment_reminder)
comment_count = Comment.objects.all().count()
article.body = markdown2.markdown(article.body)
category_list = Category.objects.all().order_by('name')
popular_article = Article.objects.all().order_by('-likes')[:5]
views_article = Article.objects.all().order_by('views')[:5]
return HttpResponseRedirect(article_url)
开发者ID:jimforit,项目名称:JimBlog,代码行数:29,代码来源:views.py
示例8: preheat
def preheat():
index = requests.get('%s/INDEX.md' % base_url)
soup = BeautifulSoup(md.markdown(index.content))
links = [a for a in soup.find_all('a') if a.get('href').endswith('.md')]
full_tacos = [f.get('href') for f in links if 'full_tacos/' in f.get('href')]
base_layers = [b.get('href') for b in links if 'base_layers/' in b.get('href')]
mixins = [m.get('href') for m in links if 'mixins/' in m.get('href')]
condiments = [c.get('href') for c in links if 'condiments/' in c.get('href')]
seasonings = [s.get('href') for s in links if 'seasonings/' in s.get('href')]
shells = [s.get('href') for s in links if 'shells/' in s.get('href')]
bases = get_cookin(BaseLayer, base_layers)
conds = get_cookin(Condiment, condiments)
seas = get_cookin(Seasoning, seasonings)
mix = get_cookin(Mixin, mixins)
shell = get_cookin(Shell, shells)
for full_taco in get_cookin(FullTaco, full_tacos):
soup = BeautifulSoup(md.markdown(full_taco.recipe))
ingredient_links = [l.get('href') for l in soup.find_all('a') if l.get('href').endswith('.md')]
for link in ingredient_links:
parts = urlparse(link).path.split('/')[-2:]
kind = MAPPER[parts[0]]
scrubbed_link = '/'.join(parts)
full_link = '%s/%s' % (base_url, scrubbed_link)
ingredient = db.session.query(kind).get(full_link)
if ingredient:
setattr(full_taco, ingredient.__tablename__, ingredient)
db.session.add(full_taco)
db.session.commit()
return None
开发者ID:evz,项目名称:tacofancy-api,代码行数:29,代码来源:app.py
示例9: _create_html_content_from
def _create_html_content_from(self, story):
"""Return an html representation of this story."""
html = StringIO.StringIO()
html.write('<html><body>')
html.write('<a href="' + self.link + '">Story details</a><br />')
html.write('<b>' + markdown(story['text']) + '</b>')
if story['details']:
html.write(markdown(story['details']))
html.write('<hr />')
if not story['color'] == 'grey':
html.write('Color: <span style="color:' + story['color'] + '">'
+ story['color'] + '</span><br />')
html.write('Phase: ' + story['phase']['name'] + '<br />')
html.write('Status: ' + story['status'] + '<br />')
if 'blockedReason' in story.keys():
html.write('<span style="color:red">Block reason: '
+ story['blockedReason'] + '</span><br />')
html.write('Creator: ' + story['creator']['name'] + '<br />')
if 'owner' in story.keys():
html.write('Owner: ' + story['owner']['name'] + '<br />')
if 'deadline' in story.keys():
html.write('Deadline: '
+ re.sub('T00:00:00', '', story['deadline']) + '<br />')
if story['comments']:
html.write('<hr /><br />')
for comment in story['comments']:
html.write(' <i>' + comment['author']['name'] + '</i> said (')
html.write(_convert_gmt(comment['createTime']) + '):')
comment = re.sub('(\n)', '<br />', comment['text'])
html.write('<p>' + markdown(comment) + '</p>')
html.write("<br />")
html.write('</body></html>')
content = html.getvalue()
html.close()
return content
开发者ID:alienhard,项目名称:notify,代码行数:35,代码来源:message.py
示例10: save
def save(self, **kwargs):
new_revision = not self.id
silent_update = kwargs.has_key('silent_update')
if silent_update:
kwargs.pop('silent_update')
if new_revision and self.pub_date is None:
self.pub_date = datetime.datetime.now()
if not silent_update:
self.updated_date = datetime.datetime.now()
# Use safe_mode in Markdown to prevent arbitrary input
# and strip all html tags from CharFields
self.version = strip_tags(self.version)
self.authors = strip_tags(self.authors)
self.changes_html = markdown(self.changes, safe_mode=True)
self.description_html = markdown(self.description, safe_mode=True)
self.tags = strip_tags(self.tags)
self.language = strip_tags(self.language)
self.os_license = strip_tags(self.os_license)
self.paper_bib = strip_tags(self.paper_bib)
self.operating_systems = strip_tags(self.operating_systems)
self.dataformats = strip_tags(self.dataformats)
super(Revision, self).save(kwargs)
# Update authorlist, taglist, licenselist, langaugelist, opsyslist
self.update_list('authorlist','Author','authors')
self.update_list('taglist','Tag','tags')
self.update_list('licenselist','License','os_license')
self.update_list('languagelist','Language','language')
self.update_list('opsyslist','OpSys','operating_systems')
self.update_list('dataformatlist','DataFormat','dataformats')
# send out notifications on updates
if not silent_update:
self.software.notify_update()
开发者ID:open-machine-learning,项目名称:mloss,代码行数:35,代码来源:models.py
示例11: post
def post(self):
if not self.get_user['admin']:
self.render('status.html', message=u'对不起你没有权限!')
return
title = self.get_argument('title')
content = self.get_argument('content')
new_content = []
# markdown转成html并转义
title = unicode(markdown2.markdown(escape.html_escape(title)))
content = unicode(markdown2.markdown(escape.html_escape(content),
extras=['fenced-code-blocks']))
# 反转义代码块中的"&"
m = re.compile('\<pre\>[\s\S]*\<\/pre\>')
content = m.sub(escape.code_unescape, content)
for span_content in content.split(' '):
new_content.append(tool.insert_span(span_content))
content = ' '.join(new_content)
create_time = datetime.datetime.now()
news = models.News(title=title, content=content, create_time=create_time)
news.insert()
self.render('status.html', message=u'发布新闻成功!')
开发者ID:wanglong,项目名称:holleworld,代码行数:28,代码来源:news.py
示例12: info
def info(job_id, slug=None):
job = Job.query.filter(Job.id == job_id).first_or_404()
job.nb_viewed += 1
job.save()
# convert markdown to html
job_description, job_motivation = markdown2.markdown(job.description), markdown2.markdown(job.motivation)
return render_template('jobs/job.html', job=job, html_description=job_description, html_motivation=job_motivation)
开发者ID:jerkos,项目名称:metabo-match,代码行数:8,代码来源:views.py
示例13: loadCourse
def loadCourse(coursefilename):
currentSelectedCourse = coursename
tmp=''
with open(coursesRoot + coursefilename, 'r') as data:
tmp = data.read()
#print htmlStartString+markdown2.markdown(tmp)+htmlEndString
wv.load_html_string(htmlStartString+markdown2.markdown(tmp)+htmlEndString, "file:///")
print htmlStartString+markdown2.markdown(tmp)+htmlEndString
开发者ID:voidcode,项目名称:howtoapp,代码行数:8,代码来源:main.py
示例14: print_post
def print_post(title, body, date=None):
"""Formats and prints a post"""
print '<div class="blogpost">'
print '<h1>%s</h1>' % title
if date:
print '<h3>%s</h3>' % time.ctime(date)
print markdown2.markdown(body)
print '</div>'
开发者ID:drguildo,项目名称:bloggy,代码行数:8,代码来源:common.py
示例15: OnCommit
def OnCommit(self, **kw):
if self.useCache:
self.data["tcache"] = markdown2.markdown(self.data.get("textblock"))
text = ConvertHTMLToText(self.data["tcache"], removeReST=True)
else:
temp = markdown2.markdown(self.data.get("textblock"))
text = ConvertHTMLToText(temp, removeReST=True)
self.meta["title"] = CutText(text, self.titleLen, postfix=u"")
return True
开发者ID:nive,项目名称:cms-modules,代码行数:9,代码来源:mtext.py
示例16: gen_html
def gen_html(self):
import markdown2
mkd = self.parse()
if self.pyg:
logger.debug("Parser.gen_html() codehilite\n mkd:%s" % (mkd,))
return markdown2.markdown(mkd, extras={'code-color': None})
else:
logger.debug("Parser.gen_html()\n mkd:%s" % (mkd,))
return markdown2.markdown(mkd)
开发者ID:jeffbuttars,项目名称:Vimdown,代码行数:9,代码来源:parser.py
示例17: md2
def md2(value):
'''
目前markdown2 无法处理井号(####)标题
'''
return mark_safe(markdown2.markdown(
force_unicode(value),
safe_mode=True)
)
return mark_safe(markdown2.markdown(value))
开发者ID:imlyj,项目名称:django_blog,代码行数:9,代码来源:myapp_markup.py
示例18: md
def md(value, arg=None):
try:
if not arg:
return mark_safe(markdown(value))
else:
mded = markdown(value)
rep = '<p class="%s">'%(arg)
return mark_safe(mded.replace('<p>', rep))
except Exception:
return value
开发者ID:osp,项目名称:osp.work.404.www,代码行数:10,代码来源:md.py
示例19: clean
def clean(self):
try:
if markdown is not None:
extras = ['fenced-code-blocks']
self.content_html = markdown(self.content, extras=extras)
self.description_html = markdown(wrap_description(self.content),
extras=extras)
except:
raise self.ValidationError("Player42, try again")
super(Post, self).clean()
开发者ID:bougie,项目名称:pybrief,代码行数:11,代码来源:models.py
示例20: render
def render(self, this, template_name, **kwargs):
if 'post' in kwargs:
kwargs['post'].text = markdown2.markdown( kwargs['post'].text )
elif 'page' in kwargs:
kwargs['page'].text = markdown2.markdown( kwargs['page'].text )
return {
'this' : this ,
'template_name' : template_name ,
'kwargs' : kwargs
}
开发者ID:zcong,项目名称:qcoreblog,代码行数:11,代码来源:editMarkdown.py
注:本文中的markdown2.markdown函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论