-
Couldn't load subscription status.
- Fork 152
Description
When one-boxing a link to the new website on the forum, e.g. in this post, the description currently reads:
ImageJ is an open source image processing program designed for scientific multidimensional images.
It's possible to specify the description with description: in the front matter, but ideally we should improve the default description to be the same that is also used in the search (see this Gitter discussion).
@ctrueden suggests translating the Python code here:
imagej.github.io/_search/server/index-site.py
Lines 18 to 32 in 2f99613
| def first_sentence(lines): | |
| def good(line): | |
| if line.startswith('#'): return False # ignore headers | |
| if re.match('^[=-]+$', line): return False # ignore section dividers | |
| return True | |
| s = ''.join(line for line in lines if good(line)) | |
| s = re.sub('<[^>]*>', '', s) # strip HTML | |
| s = re.sub('{%[^%]*%}', '', s) # strip Liquid tags | |
| s = re.sub('\[([^]]*)\]\([^\)]*\)', '\\1', s) # strip Markdown links | |
| s = re.sub('\*+\\s*([^\*]*)\\s*\*+', '\\1', s) # strip emphasis | |
| s = re.sub('\\s\\s*', ' ', s) # unify whitespace | |
| dot = s.find('. ') | |
| if dot >= 0: s = s[:dot+1] # cut down to first sentence | |
| return s.strip() |
... to Liquid and call it from here:
imagej.github.io/_includes/layout/onebox-info
Lines 25 to 27 in 2f99613
| {%- else -%} | |
| {{ site.description }} | |
| {%- endif -%} |