Split a post into (front_matter, body, body_start_line). front_matter is "" when the post has no leading --- block. body_start_line is the 1-based line in the ORIGINAL file where the body begins, so callers can report findings against true source line numbers.
(text)
| 41 | |
| 42 | |
| 43 | def split_front_matter(text): |
| 44 | """Split a post into (front_matter, body, body_start_line). |
| 45 | |
| 46 | front_matter is "" when the post has no leading --- block. body_start_line |
| 47 | is the 1-based line in the ORIGINAL file where the body begins, so callers |
| 48 | can report findings against true source line numbers. |
| 49 | """ |
| 50 | m = _FRONT_MATTER_RE.match(text) |
| 51 | if not m: |
| 52 | return "", text, 1 |
| 53 | front_matter = m.group(0) |
| 54 | body = text[m.end():] |
| 55 | body_start_line = front_matter.count("\n") + 1 |
| 56 | return front_matter, body, body_start_line |
| 57 | |
| 58 | |
| 59 | def author_body(body): |