fixed a bug and replace div anchor with span anchor, as suggested by Vladyslav

This commit is contained in:
mdipierro
2012-09-09 09:14:50 -05:00
parent c42ebc92fe
commit d82f91c0ec
2 changed files with 16 additions and 15 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.0.8 (2012-09-08 23:22:37) stable Version 2.0.8 (2012-09-09 09:14:46) stable
+14 -13
View File
@@ -643,7 +643,7 @@ def render(text,
- class_prefix is a prefix for ALL classes in markmin text. E.g. if class_prefix='my_' - class_prefix is a prefix for ALL classes in markmin text. E.g. if class_prefix='my_'
then for ``test``:cls class will be changed to "my_cls" (default value is '') then for ``test``:cls class will be changed to "my_cls" (default value is '')
- id_prefix is prefix for ALL ids in markmin text (default value is 'markmin_'). E.g.: - id_prefix is prefix for ALL ids in markmin text (default value is 'markmin_'). E.g.:
-- [[id]] will be converted to <div class="anchor" id="markmin_id"></div> -- [[id]] will be converted to <span class="anchor" id="markmin_id"></span>
-- [[link #id]] will be converted to <a href="#markmin_id">link</a> -- [[link #id]] will be converted to <a href="#markmin_id">link</a>
-- ``test``:cls[id] will be converted to <code class="cls" id="markmin_id">test</code> -- ``test``:cls[id] will be converted to <code class="cls" id="markmin_id">test</code>
@@ -774,19 +774,19 @@ def render(text,
'<p>[[probe]]</p>' '<p>[[probe]]</p>'
>>> render(r"\\\\[[probe]]") >>> render(r"\\\\[[probe]]")
'<p>\\\\<div class="anchor" id="markmin_probe"></div></p>' '<p>\\\\<span class="anchor" id="markmin_probe"></span></p>'
>>> render(r"\\\\\\[[probe]]") >>> render(r"\\\\\\[[probe]]")
'<p>\\\\[[probe]]</p>' '<p>\\\\[[probe]]</p>'
>>> render(r"\\\\\\\\[[probe]]") >>> render(r"\\\\\\\\[[probe]]")
'<p>\\\\\\\\<div class="anchor" id="markmin_probe"></div></p>' '<p>\\\\\\\\<span class="anchor" id="markmin_probe"></span></p>'
>>> render(r"\\\\\\\\\[[probe]]") >>> render(r"\\\\\\\\\[[probe]]")
'<p>\\\\\\\\[[probe]]</p>' '<p>\\\\\\\\[[probe]]</p>'
>>> render(r"\\\\\\\\\\\[[probe]]") >>> render(r"\\\\\\\\\\\[[probe]]")
'<p>\\\\\\\\\\\\<div class="anchor" id="markmin_probe"></div></p>' '<p>\\\\\\\\\\\\<span class="anchor" id="markmin_probe"></span></p>'
>>> render("``[[ [\\[[probe\]\\]] URL\\[x\\]]]``:red[dummy_params]") >>> render("``[[ [\\[[probe\]\\]] URL\\[x\\]]]``:red[dummy_params]")
'<span style="color: red"><a href="URL[x]" title="[[probe]]">URL[x]</a></span>' '<span style="color: red"><a href="URL[x]" title="[[probe]]">URL[x]</a></span>'
@@ -834,16 +834,16 @@ def render(text,
'<p><strong>test 1</strong></p>' '<p><strong>test 1</strong></p>'
>>> render('[[id1 [span **messag** in ''markmin''] ]] ... [[**link** to id [link\\\'s title] #mark1]]') >>> render('[[id1 [span **messag** in ''markmin''] ]] ... [[**link** to id [link\\\'s title] #mark1]]')
'<p><div class="anchor" id="markmin_id1">span <strong>messag</strong> in markmin</div> ... <a href="#markmin_mark1" title="link\\\'s title"><strong>link</strong> to id</a></p>' '<p><span class="anchor" id="markmin_id1">span <strong>messag</strong> in markmin</span> ... <a href="#markmin_mark1" title="link\\\'s title"><strong>link</strong> to id</a></p>'
>>> render('# Multiline[[NEWLINE]]\\n title\\nParagraph[[NEWLINE]]\\nwith breaks[[NEWLINE]]\\nin it') >>> render('# Multiline[[NEWLINE]]\\n title\\nParagraph[[NEWLINE]]\\nwith breaks[[NEWLINE]]\\nin it')
'<h1>Multiline<br /> title</h1><p>Paragraph<br /> with breaks<br /> in it</p>' '<h1>Multiline<br /> title</h1><p>Paragraph<br /> with breaks<br /> in it</p>'
>>> render("anchor with name 'NEWLINE': [[NEWLINE [ ] ]]") >>> render("anchor with name 'NEWLINE': [[NEWLINE [ ] ]]")
'<p>anchor with name \\'NEWLINE\\': <div class="anchor" id="markmin_NEWLINE"></div></p>' '<p>anchor with name \\'NEWLINE\\': <span class="anchor" id="markmin_NEWLINE"></span></p>'
>>> render("anchor with name 'NEWLINE': [[NEWLINE [newline] ]]") >>> render("anchor with name 'NEWLINE': [[NEWLINE [newline] ]]")
'<p>anchor with name \\'NEWLINE\\': <div class="anchor" id="markmin_NEWLINE">newline</div></p>' '<p>anchor with name \\'NEWLINE\\': <span class="anchor" id="markmin_NEWLINE">newline</span></p>'
""" """
if autolinks=="default": autolinks = autolinks_simple if autolinks=="default": autolinks = autolinks_simple
if protolinks=="default": protolinks = protolinks_simple if protolinks=="default": protolinks = protolinks_simple
@@ -895,7 +895,7 @@ def render(text,
text = regex_proto.sub(lambda m: protolinks(*m.group('p','k')), text) text = regex_proto.sub(lambda m: protolinks(*m.group('p','k')), text)
if autolinks: if autolinks:
text = replace_autolinks(text,lambda m: autolinks(m.group('k'))) text = replace_autolinks(text,autolinks)
############################################################# #############################################################
# normalize spaces # normalize spaces
@@ -1260,11 +1260,12 @@ def render(text,
% dict(k=k, title=title, target=target, t=t) % dict(k=k, title=title, target=target, t=t)
if t == 'NEWLINE' and not a: if t == 'NEWLINE' and not a:
return '<br />'+pp return '<br />'+pp
return '<div class="anchor" id="%s">%s</div>' % (escape(id_prefix+t), return '<span class="anchor" id="%s">%s</span>' % (
render(a, {},{},'br', URL, escape(id_prefix+t),
environment, latex, autolinks, render(a, {},{},'br', URL,
protolinks, class_prefix, environment, latex, autolinks,
id_prefix, pretty_print)) protolinks, class_prefix,
id_prefix, pretty_print))
parts = text.split(LINK) parts = text.split(LINK)
text = parts[0] text = parts[0]