Package: markie
MarkieA small project for processing markdown files with metadata.Installpip install markieNote: This project is still in Alpha – significant changes are expected and
features are limitedExamplefrompprintimportpprintfrommarkieimportDocmain_content="""---title: "Ducks: And how to Make Them Pay"year: 1894---# Ducks: And how to Make Them PayBy William CookAuthor of "The Practical Poultry Breeder and Feeder";"The Horse: its keep and management";"Pheasants, Turkeys, and Geese: their management for pleasure and profit"""".strip()chapter_1="""## IntroductionNot so many years ago roast duck was a luxury only for the rich, unless itmight have been a few foreign birds sent into our markets, which couldusually be bought up at a very low price.""".strip()doc=Doc.from_md(main_content)# content can be appended with .append, or prepended with .prependdoc.append(chapter_1)# Metadata can be retrieved and setdoc.metadata["authors"]=["William Cook"]# can be pretty printed to quickly glean the overall document structurepprint(doc)# Iterating over docs yields markdown-it tokens in order# pprint([*doc])# Docs are rendered to markdownwithopen(f"{doc.metadata['title']}.md","w")asf:f.write(doc.render())The above would print:Doc(metadata={'authors': ['William Cook'],
              'title': 'Ducks: And how to Make Them Pay',
              'year': 1894},
    preamble='',
    sections=[Section(level=1,
                      title='Ducks: And how to Make Them Pay',
                      preamble='By William Cook\n'
                               '\n'
                               'Author of "The Practical Poultry Breeder and '
                               'Feeder";\n'
                               '"The Horse: its keep and management";\n'
                               '"Pheasants, Turkeys, and Geese: their '
                               'management for pleasure and profit"',
                      subsections=[Section(level=2,
                                           title='Introduction',
                                           preamble='Not so many years ago '
                                                    'roast duck was a luxury '
                                                    'only for the rich, unless '
                                                    'it\n'
                                                    'might have been a few '
                                                    'foreign birds sent into '
                                                    'our markets, which could\n'
                                                    'usually be bought up at a '
                                                    'very low price.',
                                           subsections=[])])])And write the following to a file "Ducks: And how to Make Them Pay.md":---
title: 'Ducks: And how to Make Them Pay'
year: 1894
authors:- William Cook---# Ducks: And how to Make Them PayBy William Cook

Author of "The Practical Poultry Breeder and Feeder";
"The Horse: its keep and management";
"Pheasants, Turkeys, and Geese: their management for pleasure and profit"## IntroductionNot so many years ago roast duck was a luxury only for the rich, unless it
might have been a few foreign birds sent into our markets, which could
usually be bought up at a very low price.Notes for DevelopersTestsInstall the test requirements fromtests/requirements.txt.These tests
useApprovalTestsandpytestwith theApprovalTests pytest plugin.
To enable diff checking on PyCharm, seetheir documentationwhich describes how to set up a run configuration which uses PyCharm's built-in
diff checker.