Add inline image in Markdown syntax

Change default font for my blog
This commit is contained in:
Gregory Soutade 2014-05-19 18:20:25 +02:00
parent 86d2b83ed9
commit c468ea92b0
5 changed files with 62 additions and 19 deletions

View File

@ -1118,6 +1118,11 @@ class Markdown(object):
if is_img:
start_idx -= 1
is_inline_img = start_idx > 0 and text[start_idx-1] == "#"
if is_inline_img:
start_idx -= 1
is_img = 1
url, title = match.group("url"), match.group("title")
if url and url[0] == '<':
url = url[1:-1] # '<url>' -> 'url'
@ -1133,10 +1138,16 @@ class Markdown(object):
else:
title_str = ''
if is_img:
result = '<img src="%s" alt="%s"%s%s' \
% (url.replace('"', '&quot;'),
_xml_escape_attr(link_text),
title_str, self.empty_element_suffix)
if is_inline_img:
result = '<img class="inlineimage" src="%s" alt="%s"%s%s' \
% (url.replace('"', '&quot;'),
_xml_escape_attr(link_text),
title_str, self.empty_element_suffix)
else:
result = '<img src="%s" alt="%s"%s%s' \
% (url.replace('"', '&quot;'),
_xml_escape_attr(link_text),
title_str, self.empty_element_suffix)
if "smarty-pants" in self.extras:
result = result.replace('"', self._escape_table['"'])
curr_pos = start_idx + len(result)

View File

@ -1,5 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<ljdc>
<entry>
<id>84208887361</id>
<address>http://thecodinglove.com/post/84208887361/when-the-intern-modifies-my-code</address>
<title>when the intern modifies my code</title>
<img>http://i.imgur.com/8jw2zLm.gif</img>
</entry>
<entry>
<id>83611569882</id>
<address>http://thecodinglove.com/post/83611569882/when-its-finally-time-to-leave-work</address>

View File

@ -42,7 +42,7 @@ div.body
z-index:12;
display:inline;
color:black;
font-family: Verdana,Geneva,Arial,Helvetica,Sans-Serif;
font-family: Sans-Serif;
font-size: 50px;
padding-left:180px;
}
@ -97,7 +97,7 @@ div.menu div.menu_content
div.menu div.menu_content div.menu_content_header
{
font-family: Tahoma,Arial,Helvetica,Sans-Serif;
font-family: Sans-Serif;
font-size: 17px;
background-image: url("/images/BlockHeaderIcon.png");
background-repeat: no-repeat;
@ -114,7 +114,7 @@ div.menu div.menu_content div.menu_content_content
div.menu_content_content a
{
font-family: Tahoma,Arial,Helvetica,Sans-Serif;
font-family: Sans-Serif;
color: #5e6a34;
font-weight: normal;
font-style: normal;
@ -122,7 +122,7 @@ div.menu_content_content a
div.menu div.menu_content div.menu_content_content a:link
{
font-family: Tahoma,Arial,Helvetica,Sans-Serif;
font-family: Sans-Serif;
color: #5e6a34;
font-weight: normal;
font-style: normal;
@ -130,7 +130,7 @@ div.menu div.menu_content div.menu_content_content a:link
div.menu div.menu_content div.menu_content_content a:hover
{
font-family: Tahoma,Arial,Helvetica,Sans-Serif;
font-family: Sans-Serif;
color: #5e6a34;
font-weight: normal;
font-style: normal;
@ -146,6 +146,11 @@ div.menu div.menu_content div.menu_content_content li
list-style-image: url("/images/BlockContentBullets.png");
}
div.menu a img
{
display:inline;
}
div.footer
{
width:100%;
@ -163,7 +168,7 @@ div.post
div.post div.post_header
{
display:block;
font-family: Tahoma,Arial,Helvetica,Sans-Serif;
font-family: Sans-Serif;
color: #3c3e2d;
padding-bottom:5px;
}
@ -185,7 +190,7 @@ div.post div.post_header div.title
text-align:left;
text-indent:0;
line-height:inherit;
font-family: Verdana, Geneva, Arial, Helvetica, Sans-Serif;
font-family: Sans-Serif;
font-size: 26px;
color: #181B0D;
}
@ -207,7 +212,7 @@ div.post_header div.title > a
text-align:left;
text-indent:0;
line-height:inherit;
font-family: Verdana, Geneva, Arial, Helvetica, Sans-Serif;
font-family: Sans-Serif;
font-size: 26px;
color: #181B0D;
}
@ -229,7 +234,7 @@ div.post_header div.title > a:hover
text-align:left;
text-indent:0;
line-height:inherit;
font-family: Verdana, Geneva, Arial, Helvetica, Sans-Serif;
font-family: Sans-Serif;
font-size: 26px;
color: #181B0D;
}
@ -259,7 +264,7 @@ div.post_header div.post_sub_header > div.author_icon div.author
div.post_header div.post_sub_header div.date
{
display:inline;
font-family: Tahoma,Arial,Helvetica,Sans-Serif;
font-family: Sans-Serif;
background-image: url('/images/dateicon.png');
background-repeat: no-repeat;
background-position: left center;
@ -270,7 +275,7 @@ div.post div.post_content
{
display:block;
margin-top:1%;
font-family: Tahoma, Arial, Helvetica, Sans-Serif;
font-family: Sans-Serif;
color: #171811;
}
@ -318,11 +323,30 @@ div.navigation
a, a:link, a:hover
{
font-family: Tahoma,Arial,Helvetica,Sans-Serif;
font-family: Sans-Serif;
color: #818f00;
text-decoration:none;
}
a img
{
margin-left: auto;
margin-right: auto;
display:block;
}
.inlineimage
{
display:inline;
margin-right: 50px;
}
a .inlineimage
{
display:inline;
margin-right: 50px;
}
h1, h2, h3, h4, h5, h6, h1 a, h2 a, h3 a, h4 a, h5 a, h6 a h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited
{
font-weight: normal;
@ -331,7 +355,7 @@ h1, h2, h3, h4, h5, h6, h1 a, h2 a, h3 a, h4 a, h5 a, h6 a h1 a:hover, h2 a:hove
h1, h1 a, h1 a:link, h1 a:visited, h1 a:hover
{
font-family: Verdana,Geneva,Arial,Helvetica,Sans-Serif;
font-family: Sans-Serif;
padding-top:20px;
font-size: 28px;
color: #818f00;
@ -339,7 +363,7 @@ h1, h1 a, h1 a:link, h1 a:visited, h1 a:hover
h2, h2 a, h2 a:link, h2 a:visited, h2 a:hover
{
font-family: Verdana,Geneva,Arial,Helvetica,Sans-Serif;
font-family: Sans-Serif;
padding-top:18px;
font-size: 26px;
color: #8c9d4d;
@ -347,7 +371,7 @@ h2, h2 a, h2 a:link, h2 a:visited, h2 a:hover
h3, h3 a, h3 a:link, h3 a:visited, h3 a:hover
{
font-family: Verdana,Geneva,Arial,Helvetica,Sans-Serif;
font-family: Sans-Serif;
padding-top:15px;
font-size: 21px;
color: #65684b;

View File

@ -65,6 +65,7 @@ Available tags:
<li>Second element
</ol>
<pre style="display:inline">![Picture](https://bits.wikimedia.org/images/wikimedia-button.png)</pre><img src="https://bits.wikimedia.org/images/wikimedia-button.png" alt="Picture"/><br/>
<pre style="display:inline">#[Inline Picture](https://bits.wikimedia.org/images/wikimedia-button.png)</pre><img src="https://bits.wikimedia.org/images/wikimedia-button.png" alt="Picture"/><br/>
<pre style="display:inline">[Link](http://www.wikipedia.org)</pre> <a href="http://www.wikipedia.org">Link</a><br/><br/>
</td>
<td>

View File

@ -77,6 +77,7 @@ Available tags:
<li>Second element
</ol>
<pre style="display:inline">![Picture](https://bits.wikimedia.org/images/wikimedia-button.png)</pre><img src="https://bits.wikimedia.org/images/wikimedia-button.png" alt="Picture"/><br/>
<pre style="display:inline">#[Inline Picture](https://bits.wikimedia.org/images/wikimedia-button.png)</pre><img src="https://bits.wikimedia.org/images/wikimedia-button.png" alt="Picture"/><br/>
<pre style="display:inline">[Link](http://www.wikipedia.org)</pre> <a href="http://www.wikipedia.org">Link</a><br/><br/>
</td>
<td>