From 4e4f515ef10f99628e6b5ef6abf07c90bcae90b8 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Mon, 15 Oct 2012 07:43:23 -0500 Subject: [PATCH] better markmin with links in links, thanks Vladyslav --- Makefile | 2 +- VERSION | 2 +- gluon/contrib/markmin/markmin2html.py | 31 +++++++++++++++++++-------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 6df4f910..8b7bb471 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ update: wget -O gluon/contrib/simplejsonrpc.py http://rad2py.googlecode.com/hg/ide2py/simplejsonrpc.py echo "remember that pymysql was tweaked" src: - echo 'Version 2.1.1 ('`date +%Y-%m-%d\ %H:%M:%S`') stable' > VERSION + echo 'Version 2.1.1 ('`date +%Y-%m-%d\ %H:%M:%S`') dev' > VERSION ### rm -f all junk files make clean ### clean up baisc apps diff --git a/VERSION b/VERSION index 8413750a..c7420dbe 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.1.1 (2012-10-15 06:40:52) stable +Version 2.1.1 (2012-10-15 07:43:19) dev diff --git a/gluon/contrib/markmin/markmin2html.py b/gluon/contrib/markmin/markmin2html.py index 78b29748..94084b0b 100755 --- a/gluon/contrib/markmin/markmin2html.py +++ b/gluon/contrib/markmin/markmin2html.py @@ -545,14 +545,14 @@ regex_bq_headline=re.compile('^(?:(\.+|\++|\-+)(\.)?\s+)?(-{3}-*)$') regex_tq=re.compile('^(-{3}-*)(?::(?P[a-zA-Z][_a-zA-Z\-\d]*)(?:\[(?P

[a-zA-Z][_a-zA-Z\-\d]*)\])?)?$') regex_proto = re.compile(r'(?/=])(?P

\w+):(?P\w+://[\w\d\-+=?%&/:.]+)', re.M) regex_auto = re.compile(r'(?/=])(?P\w+://[\w\d\-+_=?%&/:.]+)',re.M) -regex_link=re.compile(r'('+LINK+r')|\[\[(?P.+?)\]\]') -regex_link_level2=re.compile(r'^(?P\S.*?)?(?:\s+\[(?P.+?)\])?(?:\s+(?P\S+))?(?:\s+(?P

popup))?\s*$') -regex_media_level2=re.compile(r'^(?P\S.*?)?(?:\s+\[(?P.+?)\])?(?:\s+(?P\S+))?\s+(?P

img|IMG|left|right|center|video|audio)(?:\s+(?P\d+px))?\s*$') +regex_link=re.compile(r'('+LINK+r')|\[\[(?P.+?)\]\]',re.S) +regex_link_level2=re.compile(r'^(?P\S.*?)?(?:\s+\[(?P.+?)\])?(?:\s+(?P\S+))?(?:\s+(?P

popup))?\s*$',re.S) +regex_media_level2=re.compile(r'^(?P\S.*?)?(?:\s+\[(?P.+?)\])?(?:\s+(?P\S+))?\s+(?P

img|IMG|left|right|center|video|audio)(?:\s+(?P\d+px))?\s*$',re.S) -regex_markmin_escape = re.compile(r"(\\*)(['`:*~\\[\]{}@\$+\-.#])") -regex_backslash = re.compile(r"\\(['`:*~\\[\]{}@\$+\-.#])") -ttab_in = maketrans("'`:*~\\[]{}@$+-.#", '\x0b\x0c\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b') -ttab_out = maketrans('\x0b\x0c\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b',"'`:*~\\[]{}@$+-.#") +regex_markmin_escape = re.compile(r"(\\*)(['`:*~\\[\]{}@\$+\-.#\n])") +regex_backslash = re.compile(r"\\(['`:*~\\[\]{}@\$+\-.#\n])") +ttab_in = maketrans("'`:*~\\[]{}@$+-.#\n", '\x0b\x0c\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x05') +ttab_out = maketrans('\x0b\x0c\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x05',"'`:*~\\[]{}@$+-.#\n") def markmin_escape(text): """ insert \\ before markmin control characters: '`:*~[]{}@$ """ @@ -686,6 +686,15 @@ def render(text, >>> render("----\\nhello world\\n----\\n") '

hello world
' + >>> render('[[http://example.com]]') + '

' + + >>> render('[[ http://example.com]]') + '

http://example.com

' + + >>> render('[[bookmark [http://example.com] ]]') + '

http://example.com

' + >>> render('[[this is a link http://example.com]]') '

this is a link

' @@ -701,6 +710,9 @@ def render(text, >>> render("[[Your browser doesn't support