 
       [title|lines] = File.read!("#{srcdir}#{x}.md") |> String.split("\n")
       title = title |> String.trim |> String.replace(~r/^# /, "")
-      stub = lines |> Earmark.to_html
+      stub = lines |> Enum.join("\n") |> process_media(proj) |> Earmark.to_html
       html = render(template_post, proj ++ [title: title, date: datestr, contents: stub])
              |> genpage(proj ++ [page_title: title])
       File.open!("#{dstdir}#{x}.html", [:write], fn device ->


  @dowstr {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}
  @monabbr {"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}

  def init(dir) do
    dir = if String.ends_with?(dir, "/"), do: dir, else: dir<>"/"

  defp render(template, assigns) do
    {html, _} = Code.eval_quoted template, [assigns: assigns]
    html
  end

  defp process_media(contents, proj) do
    tmp = Regex.replace @media_re, contents, "![\\1](#{Keyword.get proj, :base_url}media/\\2)"
    Regex.replace @media_re_unesc, tmp, "![\\1](%\\2)"
  end

  defp mkmeta(dir, proj, [h|t], l) do
