(text)
return text
Remove the YAML front matter of a Markdown document
Remove the YAML front matter of a Markdown document
Remove the YAML front matter of a Markdown document
def remove_yaml_front_matter(text):
    """Remove the YAML front matter of a Markdown document"""
    if text[0:4] == "---\n":
        # Find where the front matter ends
        lines = text.splitlines()
        i_end = 1
        while (i_end < 10):  # front matter should use less than 10 lines
            if lines[i_end] == "---":
                break
            i_end += 1
        assert (i_end < 10), "Failed to find YAML front matter closure"

        # Remove also the extra line break after the front matter
        if (lines[i_end + 1] == ""):
            i_end += 1

        text = "\n".join(lines[(i_end + 1):])

    return text
def remove_yaml_front_matter ( text ) : if text [ 0 : 4 ] == "---\n" : # Find where the front matter ends lines = text . splitlines ( ) i_end = 1 while ( i_end < 10 ) : # front matter should use less than 10 lines if lines [ i_end ] == "---" : break i_end += 1 assert ( i_end < 10 ) , "Failed to find YAML front matter closure" # Remove also the extra line break after the front matter if ( lines [ i_end + 1 ] == "" ) : i_end += 1 text = "\n" . join ( lines [ ( i_end + 1 ) : ] ) return text