mirror of
https://github.com/python/cpython.git
synced 2025-08-23 18:24:46 +00:00
v 0.8.3 -- add an option to suppress URL processing inside <PRE>,
by Scott <scott@chronis.icgroup.com>
This commit is contained in:
parent
fc5d8b198a
commit
b1823ad83f
3 changed files with 15 additions and 9 deletions
|
@ -70,7 +70,7 @@ def emit(format, *args, **kw):
|
|||
|
||||
translate_prog = None
|
||||
|
||||
def translate(text):
|
||||
def translate(text, pre=0):
|
||||
global translate_prog
|
||||
if not translate_prog:
|
||||
url = '\(http\|ftp\|https\)://[^ \t\r\n]*'
|
||||
|
@ -90,10 +90,13 @@ def translate(text):
|
|||
while url[-1] in ');:,.?\'"':
|
||||
url = url[:-1]
|
||||
url = escape(url)
|
||||
if ':' in url:
|
||||
repl = '<A HREF="%s">%s</A>' % (url, url)
|
||||
if not pre or (pre and PROCESS_PREFORMAT):
|
||||
if ':' in url:
|
||||
repl = '<A HREF="%s">%s</A>' % (url, url)
|
||||
else:
|
||||
repl = '<A HREF="mailto:%s"><%s></A>' % (url, url)
|
||||
else:
|
||||
repl = '<A HREF="mailto:%s"><%s></A>' % (url, url)
|
||||
repl = url
|
||||
list.append(repl)
|
||||
i = i + len(url)
|
||||
j = len(text)
|
||||
|
@ -292,7 +295,7 @@ class FaqEntry:
|
|||
print '<PRE>'
|
||||
pre = 1
|
||||
if '/' in line or '@' in line:
|
||||
line = translate(line)
|
||||
line = translate(line, pre)
|
||||
elif '<' in line or '&' in line:
|
||||
line = escape(line)
|
||||
if not pre and '*' in line:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue