import yaml


def dump_md(md, **kwargs):
    """Convert metadata content to a yaml string."""
    ascomments = kwargs.get("ascomments", False)
    s = yaml.dump(md, default_flow_style=False)
    if ascomments:
        s = '# ' + "# ".join(s.splitlines(True))  # comment form
    return s