mirror of
https://github.com/not-kennethreitz/markdownplease.com.git
synced 2026-06-05 23:20:19 +00:00
honor titles too
This commit is contained in:
+8
-3
@@ -15,14 +15,19 @@ def readability(url):
|
||||
params = {'url': url, 'token': token}
|
||||
|
||||
r = requests.get(READABILITY_URL, params=params)
|
||||
return r.json()['content']
|
||||
return r.json()['content'], r.json()['title']
|
||||
|
||||
def convert(html, title=None):
|
||||
if title:
|
||||
title = '# {}'.format(title)
|
||||
html = '\n\n'.join([title, html])
|
||||
|
||||
def convert(html):
|
||||
return html2text(html)
|
||||
|
||||
def meh(url):
|
||||
try:
|
||||
return convert(readability(url))
|
||||
content, title = readability(url)
|
||||
return convert(content, title=title)
|
||||
except KeyError:
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user