anchor.diff:        Title = wf:q("post-title"),
         Text = wf:q("textarea"),
         Tags = wf:q("tags-input"),
  +      Format = wf:q(input_format),
         mtc_entry:supdate(Post#mt_post{
           title = case Title of undefined -> Title; _ -> unicode:characters_to_binary(mtws_sanitizer:sanitize("text", sanitize_fix(Title))) end,
           body = Text,
  -        body_html = case Text of undefined -> Text; _ -> unicode:characters_to_binary(mtws_sanitizer:sanitize(sanitize_fix(Text))) end,
  +        body_html = case Text of undefined -> Text; _ -> unicode:characters_to_binary(mtws_sanitizer:sanitize(Format, if Format =:= "html" -> sanitize_fix(Text); true -> ?a2b(Text) end)) end,
           tags = [unicode:characters_to_binary(sanit(unicode:characters_to_binary(T))) || T <- string:tokens(unicode:characters_to_list(list_to_binary(Tags)), ",")],
  +        format = mt_format(Format),
           origin = ?MT_ORIGIN
         })
     end,
  
positive.code:   end.
  
  event({post_edit, Post}) ->
    wf:replace("post",post_editor("post", Post#mt_post.title, Post#mt_post.body, Post#mt_post.tags, "Save", {save_post, Post}, "Cancel", {cancel_edit, Post})),
    ok;
  event({cancel_edit, Post}) ->
    wf:replace("post", post_body(Post)),
  
negative.code:     _ ->
        mtws_common:user_blog(wf:user(), PostSuff)
    end.
  
  mt_format(Format) ->
    case Format of
      "markdown" ->
        ?mtc_schema_Mt_format_MARKDOWN;
      "html" ->
        ?mtc_schema_Mt_format_HTML;
      ?mtc_schema_Mt_format_MARKDOWN ->
        "markdown";
      ?mtc_schema_Mt_format_HTML ->
        "html";
      undefined ->
        "html"
    end.
  