aboutsummaryrefslogtreecommitdiffstats
path: root/markdown.py
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2007-11-05 20:49:57 +0000
committerWaylan Limberg <waylan@gmail.com>2007-11-05 20:49:57 +0000
commit6a80c768c9c2e16efe7d7ed6f7235131b13e60ba (patch)
tree5b1c05307c9c09a0e32c5c587247fbe812a260c4 /markdown.py
parentb00e20122e06c6065eb3eaa987e7854a2503c3f4 (diff)
downloadmarkdown-6a80c768c9c2e16efe7d7ed6f7235131b13e60ba.tar.gz
markdown-6a80c768c9c2e16efe7d7ed6f7235131b13e60ba.tar.bz2
markdown-6a80c768c9c2e16efe7d7ed6f7235131b13e60ba.zip
safe_mode now has three options: "replace", "remove" and "escape". Setting safe_mode to True gets the old behavior - "replace".
Diffstat (limited to 'markdown.py')
-rw-r--r--markdown.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/markdown.py b/markdown.py
index 6b7b09f..1ffe9de 100644
--- a/markdown.py
+++ b/markdown.py
@@ -47,7 +47,7 @@ TAB_LENGTH = 4 # expand tabs to this many spaces
ENABLE_ATTRIBUTES = True # @id = xyz -> <... id="xyz">
SMART_EMPHASIS = 1 # this_or_that does not become this<i>or</i>that
HTML_REMOVED_TEXT = "[HTML_REMOVED]" # text used instead of HTML in safe mode
- # If blank, html will be escaped.
+
RTL_BIDI_RANGES = ( (u'\u0590', u'\u07FF'),
# from Hebrew to Nko (includes Arabic, Syriac and Thaana)
(u'\u2D30', u'\u2D7F'),
@@ -912,12 +912,14 @@ class RawHtmlTextPostprocessor(Postprocessor) :
def run(self, text):
for i in range(self.stash.html_counter) :
html, safe = self.stash.rawHtmlBlocks[i]
- if self.safeMode and not safe:
- if HTML_REMOVED_TEXT:
- html = HTML_REMOVED_TEXT
- else:
+ if self.safeMode and not safe :
+ if str(self.safeMode).lower() == 'escape' :
html = self.escape(html)
-
+ elif str(self.safeMode).lower() == 'remove' :
+ html = ''
+ else :
+ html = HTML_REMOVED_TEXT
+
text = text.replace("<p>%s\n</p>" % (HTML_PLACEHOLDER % i),
html + "\n")
text = text.replace(HTML_PLACEHOLDER % i, html)