Измените вашу функцию входа в систему
[AcceptVerbs(HttpVerbs.Post)]
public JsonResult Login(String username, String password)
{
...
if (ValidUser)
{
FormsAuthentication.SetAuthCookie(username, true);
return Json(false, JsonRequestBehavior.AllowGet);
}
return Json(true, JsonRequestBehavior.AllowGet);
}
и ваш метод AJAX
$('.login-btn').click(function (e) {
$.ajax({
type: "POST",
url: "/Home/Login",
data: {
userName: $('#username').val(),
password: $('#password').val()
},
succcess:function (myJSONdata) {
if(myJSONdata == true)
location.href = '/ChatRoom/ChatRoom';
else
location.href = '/Home/Index';
}
}).done(function (data) {
});
});
Этот модуль поможет сделать то, что вы описываете:
http://www.freewisdom.org/projects/ python-markdown / Using_as_a_Module
После того, как вы преобразовали уценку в HTML, вы можете использовать анализатор HTML для вырезания простого текста.
Ваш код может выглядеть примерно так:
from BeautifulSoup import BeautifulSoup
from markdown import markdown
html = markdown(some_html_string)
text = ''.join(BeautifulSoup(html).findAll(text=True))
Commented and removed it because I finally think I see the rub here: It may be easier to convert your markdown text to HTML and remove HTML from the text. I'm not aware of anything to remove markdown from text effectively but there are many HTML to plain text solutions.