def get_blog_excerpt(path): '''Get excerpt from blog post for inclusion in blog index page.''' with open(path, 'r') as reader: temp = reader.read() temp = P_BLOG_EXCERPT.search(temp) assert temp, 'Blog post {0} lacks excerpt'.format(path) return temp.group(1)
def get_blog_content_excerpt(config, filename): ''' Extract page content and excerpt from compiled blog post. This expects the template for blog posts to include comments: <!-- start content --> <!-- start excerpt --> and <!-- end excerpt --> <!-- end content --> The 'content' marker is in the blog post template, so it should always be present. The 'excerpt' markers have only been added starting in May 2013; earlier blog posts no longer have excerpts included in feed.xml, so this function may return None for them. ''' path = os.path.join(config['output'], filename) with open(path, 'r') as reader: temp = reader.read() temp = P_BLOG_CONTENT.search(temp) assert temp, \ 'Blog entry "{0}" lacks content markers'.format(path) content = temp.group(1) temp = P_BLOG_EXCERPT.search(content) excerpt = None if temp: excerpt = temp.group(1) return content, excerpt
def get_blog_excerpt(path): '''Get excerpt from blog post for inclusion in blog index page. Have to turn newlines into spaces so that older versions of Jekyll (like the one on the server) won't turn them into single backslashes when doing inclusion expansion.''' with open(path, 'r') as reader: temp = reader.read() temp = P_BLOG_EXCERPT.search(temp) assert temp, 'Blog post {0} lacks excerpt'.format(path) return temp.group(1).replace('\n', ' ')