Skip to content

Missing metadata in markdown object #13

Description

@GiovanH

When python-markdown processes a file the markdown or md object holds the markdown rendering context for other markdown plugins to use. One of these fields is Meta, which stores the metadata information parsed from the header.

This pelican plugin is working correctly in parsing the yaml metadata and passing it to pelican, but it doesn't populate the Meta field of the markdown object, which causes markdown plugins to receive an empty dict as metadata for all articles.

This can be easily simulated by adding self._md.Meta = output to _parse_yaml_metadata, although for compatibility purposes some strings should be wrapped in lists to match python-markdown's expected metadata format.

Or at least populate a few commonly-used metadata fields, like

        metadata = self._load_yaml_metadata(m.group("metadata"), source_path)

        self._md.Meta = {
            'title': [metadata.get('title')],
            'date': [metadata.get('date')]
        }

        return (
            self._md.reset().convert(m.group("content")),
            metadata,
        )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions