I\'m using Jekyll and all my posts are in .md format for convenience.
The problem is that the generator is automatically wrapping every line in paragraph tags.
As other's have said, images are inline elements and Markdown parsers will force them to be wrapped in block level elements. The currently accepted answer is hacky: it looks messy in your markdown, is not robust/extensible, and is not easily modifiable. I use Middleman for my blog and created a partial for my images that does everything I could want an image to do. I assume/hope Jekyll has partials as well and that this answer, although varying from Jekyll in syntax, will still be relevant to you.
Note that I prefix my image links if they don't begin with "http://", "https:/" or "/". This is because I have a solid organizational structure for my blog's images, and makes it simpler when using this partial, I just need the image name and no other parts of its path.
Here is the partial:
partials/_image.erb
<%
#initialize local variables in case they were not included
caption ||= ""
alt ||= ""
classes ||= ""
#strip '.html' extension off article link to get name of folder
url = current_article.url
url_without_ext = url[0..url.length-6]
#determine if image has an exact link or belongs to "/images/blog/CURRENT_ARTICLE_NAME/"
prefix = src[0..6]
if prefix != "http://" and prefix != "https:/" and src[0] !="/" then
#image belongs to "/images/blog/CURRENT_ARTICLE_NAME/" - add prefix to src
src = "/images#{url_without_ext}/#{src}"
end
%>
{::nomarkdown}
<%= caption %>
{:/}