Here is a patch.  I hope it OK.  I tested it on some of my image links and 
it seemed to be OK,  but I do not know how to run tests.
Thanks,  David


On Thursday, June 14, 2012 1:58:01 AM UTC+1, Massimo Di Pierro wrote:
>
> ok. send me a patch.
>
> On Wednesday, 13 June 2012 19:38:05 UTC-5, villas wrote:
>>
>> Hi Massimo,
>>  
>> I notice in markmin that an image is centered using P tags like this:
>>
>> <p align="center"><img......> </p>
>>
>> The problem is that HTML attributes are over-ruled by CSS.  Therefore 
>> this 'align' attribute is usually ignored.
>>
>> I am wondering therefore whether we could do something like this instead:
>>
>> <p style='text-align:center'> <img......> </p>
>>
>> I also noticed that the align attribute for img has been 
>> deprecated<http://www.w3schools.com/tags/att_img_align.asp>. 
>>  So, to float images to the left or right we should be doing this:
>>
>> <img..... style='float:left' />  or  <img..... style='float:right' />
>>
>> Pity that they won't float to the center too,  but that's probably asking 
>> too much  :-)
>>
>> Maybe one of the folks that knows more about CSS might give the above the 
>> thumbs-up (or otherwise).
>>
>> Regards, David
>>
>>
diff -r 7fc57d44edf7 gluon/contrib/markmin/markmin2html.py
--- a/gluon/contrib/markmin/markmin2html.py	Wed Jun 13 20:02:12 2012 -0500
+++ b/gluon/contrib/markmin/markmin2html.py	Thu Jun 14 13:06:58 2012 +0100
@@ -277,7 +277,7 @@
 regex_image_center_width = re.compile(r'\[\[(?P<t>[^\]]*?) +(?P<k>\S+) +center +(?P<w>\d+px)\]\]')
 regex_image_width = re.compile(r'\[\[(?P<t>[^\]]*?) +(?P<k>\S+) +(?P<p>left|right) +(?P<w>\d+px)\]\]')
 regex_image_center = re.compile(r'\[\[(?P<t>[^\]]*?) +(?P<k>\S+) +center\]\]')
-regex_image = re.compile(r'\[\[(?P<t>[^\]]*?) +(?P<k>\S+) +(?P<p>left|right|center)\]\]')
+regex_image = re.compile(r'\[\[(?P<t>[^\]]*?) +(?P<k>\S+) +(?P<p>left|right)\]\]')
 regex_video = re.compile(r'\[\[(?P<t>[^\]]*?) +(?P<k>\S+) +video\]\]')
 regex_audio = re.compile(r'\[\[(?P<t>[^\]]*?) +(?P<k>\S+) +audio\]\]')
 regex_link = re.compile(r'\[\[(?P<t>[^\]]*?) +(?P<k>\S+)\]\]')
@@ -422,10 +422,10 @@
     #############################################################
 
     text = regex_anchor.sub('<span id="\g<t>"><span>', text)
-    text = regex_image_center_width.sub('<p align="center"><img src="\g<k>" alt="\g<t>" width="\g<w>" /></p>', text)
-    text = regex_image_width.sub('<img src="\g<k>" alt="\g<t>" align="\g<p>" width="\g<w>" />', text)
-    text = regex_image_center.sub('<p align="center"><img src="\g<k>" alt="\g<t>" /></p>', text)
-    text = regex_image.sub('<img src="\g<k>" alt="\g<t>" align="\g<p>" />', text)
+    text = regex_image_center_width.sub('<p style="text-align:center"><img src="\g<k>" alt="\g<t>" width="\g<w>" /></p>', text)
+    text = regex_image_width.sub('<img src="\g<k>" alt="\g<t>" style="float:\g<p>" width="\g<w>" />', text)
+    text = regex_image_center.sub('<p style="text-align:center"><img src="\g<k>" alt="\g<t>" /></p>', text)
+    text = regex_image.sub('<img src="\g<k>" alt="\g<t>" style="float:\g<p>" />', text)
     text = regex_video.sub('<video controls="controls"><source src="\g<k>" /></video>', text)
     text = regex_audio.sub('<audio controls="controls"><source src="\g<k>" /></audio>', text)
     text = regex_link_popup.sub('<a href="\g<k>" target="_blank">\g<t></a>', text)

Reply via email to