Load and parse a file-like object or filename `fd`, and return `content` and `metadata` with the text and the frontmatter metadata.
(fd, encoding="utf-8", **defaults)
| 127 | |
| 128 | |
| 129 | def load_frontmatter(fd, encoding="utf-8", **defaults): |
| 130 | """ |
| 131 | Load and parse a file-like object or filename `fd`, and return |
| 132 | `content` and `metadata` with the text and the frontmatter metadata. |
| 133 | """ |
| 134 | if hasattr(fd, "read"): |
| 135 | text = fd.read() |
| 136 | |
| 137 | else: |
| 138 | with codecs.open(fd, "r", encoding) as f: |
| 139 | text = f.read() |
| 140 | |
| 141 | text = return_unicode(text, encoding) |
| 142 | return parse_frontmatter(text, encoding, **defaults) |
| 143 | |
| 144 | |
| 145 | def dumps_frontmatter(content, metadata, handler=SaneYAMLHandler(), **kwargs): |
no test coverage detected