Skip to content

Add option to attempt splitting metadata using \n\n if metadata delimiters are missing #19

@Holzhaus

Description

@Holzhaus

This might work for very simple metadata, like:

title: Foo bar
date: 2020-01-01 10:00:00

This is text

If the metadata delimiters are not found and the option is enabled, the plugin could do something like this:

meta, sep, content = text.partition("\n\n")
try:
    metadata = yaml.load(meta, Loader=...)
except yaml.error.YAMLError:
    content = text
    metadata = {}
else:
    # Prevent false-positives if the text does not begin with a metadata block
    if isinstance(metadata, str):
        metadata = {}
        content = text

self.md.Meta = metadata
return content

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions