pirave / postmarkup

Automatically exported from code.google.com/p/postmarkup
0 stars 0 forks source link

render unsupported tags as text #13

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
It would be nice to have an option to not swallow unsupported tags. For 
instance, if someone put [REDACTED] in a comment, it would disappear for no 
apparent reason. I've attached a patch that modifies the tokenizer to check 
for supported tags, and yield TOKEN_TEXT instead of TOKEN_TAG if a tag is not 
supported. The code could be refactored a bit, and be made an option, but it 
gets the job done.

The patch also allows you to pass tag_factory through create. My first 
approach was to use a custom tag factory, which didn't work, but it would 
probably still be a good addition.

Original issue reported on code.google.com by dcwat...@gmail.com on 26 Aug 2009 at 5:36

Attachments:

GoogleCodeExporter commented 8 years ago
This patch breaks the arguments in tags. e.g., [url=someurl]someurl[/url] does 
not render.

This functionality is a must. Please add this. Thanks.

Original comment by nasim.ha...@gmail.com on 11 Sep 2009 at 12:58

GoogleCodeExporter commented 8 years ago
Yeah, I've since fixed that. If you want, the _tag_name function should look 
like this:

+        def _tag_name(token):
+            token = token[1:-1].lstrip().lower()
+            if not token:
+                return u''
+            if token[0] == '/':
+                token = token[1:]
+            if u'=' in token:
+                token = token.split(u'=',1)[0]
+            if u' ' in token:
+                return token.split(u' ',1)[0]
+            return token

Original comment by dcwat...@gmail.com on 12 Sep 2009 at 4:02

GoogleCodeExporter commented 8 years ago
Thanks. There is still a little problem. It removes newline in between two 
<span>s.

Original comment by nasim.ha...@gmail.com on 13 Sep 2009 at 5:58

GoogleCodeExporter commented 8 years ago
I applied this patch, then img tag breaks.

Text:
[img]http://img580.imageshack.us/img580/6012/mytrapcard.jpg[/img]

Expected HTML output:
<img src="http://img580.imageshack.us/img580/6012/mytrapcard.jpg"></img>

What I get:
<img 
src="[url]http://img580.imageshack.us/img580/6012/mytrapcard.jpg[/url]"></img>

Original comment by pere...@gmail.com on 29 Aug 2010 at 12:58

GoogleCodeExporter commented 8 years ago
Fixed in trunk, using a different method from the patch, which should resolve 
the other issues.

Original comment by willmcgugan on 30 Dec 2010 at 1:14