git ssb

0+

Grey the earthling / scuttleblog



Commit 3e4cd5cd53d0b8d6f4964b7960386bb0b6763182

Always use only the first line in the post title

Including when the title is not a heading.
Greg K Nicholson committed on 10/15/2017, 5:04:05 PM
Parent: a1d3ac16dfab4dabf37b36f6c2ffbae74f80753b

Files changed

scuttleblog.pychanged
scuttleblog.pyView
@@ -49,19 +49,19 @@
4949 return user_posts
5050
5151 def define_post_text(text):
5252 text = text.strip()
53 + title = text.splitlines()[0]
5354 if re.match('#', text):
5455 # The first line is a heading. Use it as the title and strip it from the body.
55- title = text.splitlines()[0]
5656 body = ''.join(text.splitlines(keepends=True)[1:]).strip() \
5757 if len(text.splitlines()) > 1 \
5858 else ''
5959 else:
6060 # Truncate the first line and use it as the title. Keep everything in the body.
6161 maxlength = 100
6262 ellipsis = '...'
63- title = text if len(text) <= maxlength else text[:maxlength].rsplit(' ', 1)[0] + ellipsis
63 + title = title if len(title) <= maxlength else title[:maxlength].rsplit(' ', 1)[0] + ellipsis
6464 body = text
6565 title = re.sub('^#+\s+', '', title)
6666 # FIXME: This doesn't gracefully handle markdown near the start of a post.
6767 return {'title': title, 'body': body}

Built with git-ssb-web