#!/usr/bin/env python
# Copyright (c) 2012 Trent Mick.
# Copyright (c) 2007-2008 ActiveState Corp.
# License: MIT (http://www.opensource.org/licenses/mit-license.php)
from __future__ import generators
r"""A fast and complete Python implementation of Markdown.
[from http://daringfireball.net/projects/markdown/]
> Markdown is a text-to-HTML filter; it translates an easy-to-read /
> easy-to-write structured text format into HTML. Markdown's text
> format is most similar to that of plain text email, and supports
> features such as headers, *emphasis*, code blocks, blockquotes, and
> links.
>
> Markdown's syntax is designed not as a generic markup language, but
> specifically to serve as a front-end to (X)HTML. You can use span-level
> HTML tags anywhere in a Markdown document, and you can use block level
> HTML tags (like <div> and <table> as well).
Module usage:
>>> import markdown2
>>> markdown2.markdown("*boo!*") # or use `html = markdown_path(PATH)`
u'<p><em>boo!</em></p>\n'
>>> markdowner = Markdown()
>>> markdowner.convert("*boo!*")
u'<p><em>boo!</em></p>\n'
>>> markdowner.convert("**boom!**")
u'<p><strong>boom!</strong></p>\n'
This implementation of Markdown implements the full "core" syntax plus a
number of extras (e.g., code syntax coloring, footnotes) as described on
<https://github.com/trentm/python-markdown2/wiki/Extras>.
"""
cmdln_desc = """A fast and complete Python implementation of Markdown, a
text-to-HTML conversion tool for web writers.
Supported extra syntax options (see -x|--extras option below and
see <https://github.com/trentm/python-markdown2/wiki/Extras> for details):
* code-friendly: Disable _ and __ for em and strong.
* cuddled-lists: Allow lists to be cuddled to the preceding paragraph.
* fenced-code-blocks: Allows a code block to not have to be indented
by fencing it with '```' on a line before and after. Based on
<http://github.github.com/github-flavored-markdown/> with support for
syntax highlighting.
* footnotes: Support footnotes as in use on daringfireball.net and
implemented in other Markdown processors (tho not in Markdown.pl v1.0.1).
* header-ids: Adds "id" attributes to headers. The id value is a slug of
the header text.
* html-classes: Takes a dict mapping html tag names (lowercase) to a
string to use for a "class" tag attribute. Currently only supports
"pre" and "code" tags. Add an issue if you require this for other tags.
* markdown-in-html: Allow the use of `markdown="1"` in a block HTML tag to
have markdown processing be done on its contents. Similar to
<http://michelf.com/projects/php-markdown/extra/#markdown-attr> but with
some limitations.
* metadata: Extract metadata from a leading '---'-fenced block.
See <https://github.com/trentm/python-markdown2/issues/77> for details.
* nofollow: Add `rel="nofollow"` to add `<a>` tags with an href. See
<http://en.wikipedia.org/wiki/Nofollow>.
* pyshell: Treats unindented Python interactive shell sessions as <code>
blocks.
* link-patterns: Auto-link given regex patterns in text (e.g. bug number
references, revision number references).
* smarty-pants: Replaces ' and " with curly quotation marks or curly
apostrophes. Replaces --, ---, ..., and . . . with en dashes, em dashes,
and ellipses.
* toc: The returned HTML string gets a new "toc_html" attribute which is
a Table of Contents for the document. (experimental)
* xml: Passes one-liner processing instructions and namespaced XML tags.
* wiki-tables: Google Code Wiki-style tables. See
<http://code.google.com/p/support/wiki/WikiSyntax#Tables>.
"""
# Dev Notes:
# - Python's regex syntax doesn't have '\z', so I'm using '\Z'. I'm
# not yet sure if there implications with this. Compare 'pydoc sre'
# and 'perldoc perlre'.
__version_info__ = (2, 1, 0)
__version__ = '.'.join(map(str, __version_info__))
__author__ = "Trent Mick"
import os
import sys
from pprint import pprint
import re
import logging
try:
from hashlib import md5
except ImportError:
from md5 import md5
import optparse
from random import random, randint
import codecs
#---- Python version compat
try:
from urllib.parse import quote # python3
except ImportError:
from urllib import quote # python2
if sys.version_info[:2] < (2,4):
from sets import Set as set
def reversed(sequence):
for i in sequence[::-1]:
yield i
# Use `bytes` for byte strings and `unicode` for unicode strings (str in Py3).
if sys.version_info[0] <= 2:
py3 = False
try:
bytes
except NameError:
bytes = str
base_string_type = basestring
elif sys.version_info[0] >= 3:
py3 = True
unicode = str
base_string_type = str
#---- globals
DEBUG = False
log = logging.getLogger("markdown")
DEFAULT_TAB_WIDTH = 4
SECRET_SALT = bytes(randint(0, 1000000))
def _hash_text(s):
return 'md5-' + md5(SECRET_SALT + s.encode("utf-8")).hexdigest()
# Table of hash values for escaped characters:
g_escape_table = dict([(ch, _hash_text(ch))
for ch in '\\`*_{}[]()>#+-.!'])
#---- exceptions
class MarkdownError(Exception):
pass
#---- public api
def markdown_path(path, encoding="utf-8",
html4tags=False, tab_width=DEFAULT_TAB_WIDTH,
safe_mode=None, extras=None, link_patterns=None,
use_file_vars=False):
fp = codecs.open(path, 'r', encoding)
text = fp.read()
fp.close()
return Markdown(html4tags=html4tags, tab_width=tab_width,
safe_mode=safe_mode, extras=extras,
link_patterns=link_patterns,
use_file_vars=use_file_vars).convert(text)
def markdown(text, html4tags=False, tab_width=DEFAULT_TAB_WIDTH,
safe_mode=None, extras=None, link_patterns=None,
use_file_vars=False):
return Markdown(html4tags=html4tags, tab_width=tab_width,
safe_mode=safe_mode, extras=extras,
link_patterns=link_patterns,
use_file_vars=use_file_vars).convert(text)
class Markdown(object):
# The dict of "extras" to enable in processing -- a mapping of
# extra name to argument for the extra. Most extras do not have an
# argument, in which case the value is None.
#
# This can be set via (a) subclassing and (b) the constructor
# "extras" argument.
extras = None
urls = None
titles = None
html_blocks = None
html_spans = None
html_removed_text = "[HTML_REMOVED]" # for compat with markdown.py
# Used to track when we're inside an ordered or unordered list
# (see _ProcessListItems() for details):
list_level = 0
_ws_only_line_re = re.compile(r"^[ \t]+$", re.M)
def __init__(self, html4tags=False, tab_width=4, safe_mode=None,
extras=None, link_patterns=None, use_file_vars=False):
if html4tags:
self.empty_element_suffix = ">"
else:
self.empty_element_suffix = " />"
self.tab_width = tab_width
# For compatibility with earlier markdown2.py and with
# markdown.py's safe_mode being a boolean,
# safe_mode == True -> "replace"
if safe_mode is True:
self.safe_mode = "replace"
else:
self.safe_mode = safe_mode
# Massaging and building the "extras" info.
if self.extras is None:
self.extras = {}
elif not isinstance(self.extras, dict):
self.extras = dict([(e, None) for e in self.extras])
if extras:
if not isinstance(extras, dict):
extras = dict([(e, None) for e in extras])
self.extras.update(extras)
assert isinstance(self.extras, dict)
if "toc" in self.extras and not "header-ids" in self.extras:
self.extras["header-ids"] = None # "toc" implies "header-ids"
self._instance_extras = self.extras.copy()
self.link_patterns = link_patterns
self.
没有合适的资源?快使用搜索试试~ 我知道了~
python+mysql开发的后台管理系统.zip
共291个文件
js:89个
py:65个
css:46个
需积分: 0 0 下载量 149 浏览量
2024-01-09
17:57:43
上传
评论
收藏 2.89MB ZIP 举报
温馨提示
Python使用技巧,实战应用开发小系统参考资料,源码参考。经测试可运行。 详细介绍了一些Python框架的各种功能和模块,以及如何使用Python进行GUI开发、网络编程和跨平台应用开发等。 适用于初学者和有经验的开发者,能够帮助你快速上手JPython并掌握其高级特性。
资源推荐
资源详情
资源评论
收起资源包目录
python+mysql开发的后台管理系统.zip (291个子文件)
summernote-bs3.css 143KB
style.css 126KB
bootstrap.min.css 115KB
uikit.gradient.min.css 77KB
uikit.almost-flat.min.css 74KB
uikit.min.css 68KB
animate.css 64KB
datepicker3.css 33KB
font-awesome.css 28KB
style.min.css 25KB
ambiance.css 25KB
simditor.css 17KB
jquery-ui-1.10.4.custom.min.css 14KB
jasny-bootstrap.min.css 14KB
chosen.css 13KB
ui.jqgrid.css 13KB
uikit.gradient.addons.min.css 12KB
uikit.almost-flat.addons.min.css 12KB
dropzone.css 11KB
layim.css 11KB
fullcalendar.css 11KB
summernote.css 10KB
uikit.addons.min.css 10KB
webuploader-demo.css 8KB
codemirror.css 7KB
toastr.min.css 7KB
login.css 6KB
layer.css 6KB
jquery.steps.css 6KB
jquery.fancybox.css 5KB
dataTables.bootstrap.css 5KB
basic.css 4KB
bootstrap-colorpicker.min.css 3KB
ion.rangeSlider.css 3KB
jquery.nouislider.css 3KB
bootstrap-markdown.min.css 3KB
jquery.gritter.css 3KB
ion.rangeSlider.skinFlat.css 2KB
custom.css 1KB
bootstrap-treeview.css 1KB
fullcalendar.print.css 668B
switchery.css 610B
webuploader.css 515B
morris-0.4.3.min.css 442B
awesome.css 70B
ipverify.css 40B
fontawesome-webfont.eot 59KB
fontawesome-webfont.eot 37KB
fancybox_loading@2x.gif 14KB
fancybox_loading.gif 6KB
xubox_loading0.gif 6KB
xubox_loading3.gif 2KB
xubox_loading2.gif 2KB
xubox_loading1.gif 701B
loading.gif 166B
blank.gif 43B
ie-spacer.gif 43B
.gitignore 22B
newwriter_list.html 16KB
detail.html 15KB
ippool_list.html 15KB
detail.html 14KB
blacklist.html 14KB
verify_list.html 12KB
verify_list.html 10KB
agency_list.html 10KB
list.html 10KB
verify_list.html 8KB
package_list.html 8KB
my_sampling_ip.html 7KB
user_list.html 7KB
sidebar.html 7KB
vote_result.html 6KB
vote_list.html 6KB
agency_detail.html 6KB
manage_blog_list.html 4KB
home.html 4KB
manage_comment_list.html 4KB
blog.html 4KB
all_sampling_ip.html 3KB
register.html 3KB
signin.html 3KB
__base__.html 3KB
manage_user_list.html 3KB
manage_blog_edit.html 3KB
login.html 3KB
list.html 3KB
header.html 2KB
score.html 2KB
verify_result.html 2KB
blogs.html 2KB
export_layer.html 2KB
task_allot.html 2KB
layout.html 2KB
verify_result.html 1021B
footer.html 214B
index-bg.jpg 345KB
echarts-all.js 887KB
jquery.dataTables.js 400KB
codemirror.js 306KB
共 291 条
- 1
- 2
- 3
资源评论
白话Learning
- 粉丝: 3196
- 资源: 2464
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- levigo-jbig2-imageio-6.13
- 基于ArkTS的校园通app.zip
- 汉诺塔python实现.zip
- 【Springboot开发】资源springboot-plus-v2.7.18.zip
- 编译原理 C语言编译器(包括词法/语法/语义分析器等)
- 电子设计项目毕业设计及产品设计资料开关电源论文资料
- 模型预测控制(MPC)基准测试问题的开放集合Open collection of model predictive contro
- 基于用户的协同过滤算法实现的商品推荐系统
- TI杯大奖赛本科组+研究生组论文+源代码+PCB自学习式走迷宫智能小车
- TI杯大奖赛本科组+研究生组论文+源代码+PCB专业组-仪器仪表类-兰州大学-基于MSP430的心电监控系统
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功