git ssb

0+

Grey the earthling / scuttleblog



Commit 106dca60cdfe2bcffc9244743f91d9edd3762074

Improve logic (again) for stripping the post title out of the body

If the first line is short enough to be the title,
and the second line is whitespace-only,
then strip the first 2 lines from the body.
Otherwise, the body is always the entire text.

This should prevent splitting a paragraph,
quote, list or similar block.

This still doesn't handle a markdown list of paragraphs,
where each item is separated by a blank line.

It also doesn't handle Setext-style headings
(underlined with '====' or '----').
Greg K Nicholson committed on 10/17/2017, 7:55:20 AM
Parent: 21a0511ed1ef6bd7abc7a39ed23f49baa482377b

Files changed

scuttleblog.pychanged
scuttleblog.pyView
@@ -69,13 +69,13 @@
6969 ellipsis = '...'
7070 if len(title) > maxlength:
7171 title = title[:maxlength].rsplit(' ', 1)[0] + ellipsis
7272 body = text
73 + elif len(text.splitlines()) > 2 \
74 + and re.fullmatch('^\s+$', str(text.splitlines[1])):
75 + body = ''.join(text.splitlines(keepends=True)[2:]).strip()
7376 else:
74- if len(text.splitlines()) > 1:
75- body = ''.join(text.splitlines(keepends=True)[1:]).strip()
76- else:
77- body = ''
77 + body = text
7878 return {'title': title, 'body': body}
7979
8080 def build_post_structure(p):
8181 post = {}

Built with git-ssb-web