markdown support (using misaka)
This commit is contained in:
parent
d30c3c059b
commit
efa334de39
@ -21,6 +21,7 @@ def create(app, environ, request, path):
|
||||
except ValueError:
|
||||
return abort(400)
|
||||
|
||||
rv.text = utils.markdown(rv.text)
|
||||
response = Response(json.dumps(rv), 201, content_type='application/json')
|
||||
response.set_cookie('session', app.signer.dumps([path, rv.id]), max_age=app.MAX_AGE)
|
||||
return response
|
||||
@ -31,6 +32,13 @@ def get(app, environ, request, path, id=None):
|
||||
rv = list(app.db.retrieve(path)) if id is None else app.db.get(path, id)
|
||||
if not rv:
|
||||
abort(404)
|
||||
|
||||
if isinstance(rv, list):
|
||||
for item in rv:
|
||||
item.text = utils.markdown(item.text)
|
||||
else:
|
||||
rv.text = utils.markdown(rv.text)
|
||||
|
||||
return Response(json.dumps(rv), 200, content_type='application/json')
|
||||
|
||||
|
||||
|
@ -8,6 +8,8 @@ import socket
|
||||
import httplib
|
||||
import urlparse
|
||||
import contextlib
|
||||
|
||||
import misaka
|
||||
import werkzeug.routing
|
||||
|
||||
from isso.models import Comment
|
||||
@ -44,3 +46,9 @@ def determine(host):
|
||||
host = 'http://' + host
|
||||
rv = urlparse.urlparse(host)
|
||||
return (rv.netloc + ':443') if rv.scheme == 'https' else rv.netloc
|
||||
|
||||
|
||||
def markdown(text):
|
||||
return misaka.html(text,
|
||||
extensions = misaka.EXT_STRIKETHROUGH | misaka.EXT_SUPERSCRIPT | misaka.EXT_AUTOLINK \
|
||||
| misaka.HTML_SKIP_HTML | misaka.HTML_SKIP_IMAGES | misaka.HTML_SAFELINK)
|
||||
|
Loading…
Reference in New Issue
Block a user