### Install python-frontmatter Source: https://github.com/eyeseast/python-frontmatter/blob/main/README.md Install the package using pip. ```bash pip install python-frontmatter ``` -------------------------------- ### Import frontmatter library Source: https://github.com/eyeseast/python-frontmatter/blob/main/README.md Import the necessary library to start using its functionalities. ```python import frontmatter ``` -------------------------------- ### Using JSONHandler for Explicit JSON Front Matter Source: https://context7.com/eyeseast/python-frontmatter/llms.txt Demonstrates explicitly loading and dumping a post using JSONHandler. Requires no special setup beyond importing the handler. ```python import frontmatter from frontmatter.default_handlers import YAMLHandler, JSONHandler # Explicitly load and dump as JSON post = frontmatter.loads( '{ "title": "My Post", "draft": true } Body.', handler=JSONHandler(), ) print(post["title"]) # My Post print(frontmatter.dumps(post)) ``` -------------------------------- ### List post metadata keys Source: https://github.com/eyeseast/python-frontmatter/blob/main/docs/index.md Get a sorted list of all metadata keys available in the post. ```python sorted(post.keys()) ``` -------------------------------- ### Parse Raw Data with python-frontmatter Source: https://context7.com/eyeseast/python-frontmatter/llms.txt Use `frontmatter.parse` to get a raw tuple of (metadata_dict, content_str) instead of a Post object. This is efficient when only the raw pieces are needed. It supports default values and handles cases with no front matter. ```python import frontmatter with open("post.md") as f: metadata, content = frontmatter.parse(f.read()) print(metadata["title"]) print(content) # Works with defaults too metadata, content = frontmatter.parse( "---\nauthor: Alice\n---\nBody", layout="article", # default added to metadata dict ) print(metadata) # When no front matter is present, metadata equals the defaults metadata, content = frontmatter.parse("No front matter here.", status="published") print(metadata) print(content) ``` -------------------------------- ### Parse metadata and content separately Source: https://github.com/eyeseast/python-frontmatter/blob/main/README.md Parse a file's content to get metadata and content as separate variables. ```python with open('tests/yaml/hello-world.txt') as f: metadata, content = frontmatter.parse(f.read()) print(metadata['title']) ``` -------------------------------- ### Converting JSON Front Matter to YAML Output Source: https://context7.com/eyeseast/python-frontmatter/llms.txt Shows how to load a JSON-fronted file and then dump it with YAMLHandler. The handler can also be swapped on the post object for future dumps. ```python # Convert a JSON-fronted file to YAML output json_post = frontmatter.load("post-json.md") # JSONHandler auto-detected yaml_text = frontmatter.dumps(json_post, handler=YAMLHandler()) # Swap the handler on the post itself to change all future dumps post.handler = YAMLHandler() print(frontmatter.dumps(post).splitlines()[0]) # --- ``` -------------------------------- ### Load post from filename Source: https://github.com/eyeseast/python-frontmatter/blob/main/README.md Load a post directly from a specified filename. ```python post = frontmatter.load('tests/yaml/hello-world.txt') ``` -------------------------------- ### Load post from text Source: https://github.com/eyeseast/python-frontmatter/blob/main/README.md Load a post by reading its content as text. ```python with open('tests/yaml/hello-world.txt') as f: post = frontmatter.loads(f.read()) ``` -------------------------------- ### Load Post from File with python-frontmatter Source: https://context7.com/eyeseast/python-frontmatter/llms.txt Use `frontmatter.load` to parse a file path or file-like object into a Post instance. Automatic handler detection supports YAML, JSON, and TOML. Metadata defaults can be provided and are overridden by file content. ```python import frontmatter # Load by filename post = frontmatter.load("post.md") print(post["title"]) print(post.content) # Load from an open file object with open("post.md", encoding="utf-8") as f: post = frontmatter.load(f) # Load a file that may have a BOM (byte-order mark) with open("post.md", encoding="utf-8-sig") as f: post = frontmatter.load(f) # Provide metadata defaults — overridden if the file sets the same key post = frontmatter.load("post.md", layout="default", author="unknown") print(post.get("author")) # Force a specific handler instead of auto-detecting from frontmatter.default_handlers import TOMLHandler post = frontmatter.load("post.md", handler=TOMLHandler()) print(type(post.handler)) ``` -------------------------------- ### Load post from file object Source: https://github.com/eyeseast/python-frontmatter/blob/main/README.md Load a post from an open file or file-like object. ```python with open('tests/yaml/hello-world.txt') as f: post = frontmatter.load(f) ``` -------------------------------- ### frontmatter.loads Source: https://context7.com/eyeseast/python-frontmatter/llms.txt Parses front matter from a string, returning a Post instance. This is useful when the document content is already in memory. ```APIDOC ## frontmatter.loads(text, encoding="utf-8", handler=None, **defaults) -> Post ### Description Parse a unicode or bytes string that contains front matter and return a `Post`. Equivalent to `load` but accepts raw text instead of a file reference. Useful when the document source is already in memory (e.g., fetched from a database or an HTTP response). ### Parameters #### Path Parameters - **text** (str | bytes) - Required - The string containing the document and front matter. - **encoding** (str) - Optional - The encoding of the text if it's bytes. Defaults to "utf-8". - **handler** (BaseHandler) - Optional - The handler to use for parsing front matter. If None, it's auto-detected. - **defaults** (dict) - Optional - Keyword arguments that serve as default metadata values. ### Request Example ```python import frontmatter text = """ --- title: My Article tags: [python, parsing] draft: false --- This is the article body. """ post = frontmatter.loads(text) print(post["title"]) print(post["tags"]) print(post["draft"]) print(post.content) # CRLF line endings are handled transparently crlf_text = b'---\r\ntitle: "my title"\r\n---\r\n\r\nBody text' post = frontmatter.loads(crlf_text, "utf-8") print(post["title"]) # Text with no front matter is returned with empty metadata bare = frontmatter.loads("Just some plain text, no delimiters.") print(bare.metadata) print(bare.content) ``` ### Response #### Success Response (Post) - **metadata** (dict) - The parsed metadata from the front matter. - **content** (str) - The content of the document after the front matter. - **handler** (BaseHandler) - The handler used for parsing. ``` -------------------------------- ### Manage post metadata Source: https://github.com/eyeseast/python-frontmatter/blob/main/README.md View all metadata keys and update metadata. Metadata is proxied as post keys. ```python sorted(post.keys()) ``` ```python post['excerpt'] = 'tl;dr' pprint(post.metadata) ``` -------------------------------- ### frontmatter.load Source: https://context7.com/eyeseast/python-frontmatter/llms.txt Loads and parses front matter from a file path or file-like object, returning a Post instance. It automatically detects the handler (YAML, JSON, TOML) and allows for default metadata values. ```APIDOC ## frontmatter.load(fd, encoding="utf-8", handler=None, **defaults) -> Post ### Description Load and parse a file path (`str` / `pathlib.Path`) or an open file-like object. Returns a `Post` instance. The correct handler (YAML, JSON, TOML) is detected automatically from the file's content unless one is passed explicitly. Keyword arguments become metadata defaults that are overridden by anything found in the actual front matter. ### Parameters #### Path Parameters - **fd** (str | pathlib.Path | file-like object) - Required - The file path or file-like object to load. - **encoding** (str) - Optional - The encoding to use when reading the file. Defaults to "utf-8". - **handler** (BaseHandler) - Optional - The handler to use for parsing front matter. If None, it's auto-detected. - **defaults** (dict) - Optional - Keyword arguments that serve as default metadata values. ### Request Example ```python import frontmatter # Load by filename post = frontmatter.load("post.md") print(post["title"]) print(post.content) # Load from an open file object with open("post.md", encoding="utf-8") as f: post = frontmatter.load(f) # Load a file that may have a BOM (byte-order mark) with open("post.md", encoding="utf-8-sig") as f: post = frontmatter.load(f) # Provide metadata defaults — overridden if the file sets the same key post = frontmatter.load("post.md", layout="default", author="unknown") print(post.get("author")) # Force a specific handler instead of auto-detecting from frontmatter.default_handlers import TOMLHandler post = frontmatter.load("post.md", handler=TOMLHandler()) print(type(post.handler)) ``` ### Response #### Success Response (Post) - **metadata** (dict) - The parsed metadata from the front matter. - **content** (str) - The content of the document after the front matter. - **handler** (BaseHandler) - The handler used for parsing. ``` -------------------------------- ### Minimal DummyHandler for Basic Parsing Source: https://context7.com/eyeseast/python-frontmatter/llms.txt A minimal handler that overrides only the load and split methods to demonstrate basic parsing capabilities without complex serialization. ```python # --- Example 3: Minimal no-op handler --- class DummyHandler: def load(self, fm): return {"raw": fm.strip()} def split(self, text): return "key: value", "content goes here" post = frontmatter.loads("anything", handler=DummyHandler()) print(post["raw"]) # key: value ``` -------------------------------- ### Detect Front Matter Format Source: https://context7.com/eyeseast/python-frontmatter/llms.txt Use `frontmatter.detect_format()` with a list of handlers to identify the front matter format of a given text. Returns the handler instance or `None` if no format is detected. ```python import frontmatter from frontmatter.default_handlers import YAMLHandler, JSONHandler, TOMLHandler yaml_text = "---\ntitle: YAML post\n---\nContent" json_text = '{ "title": "JSON post" }\nContent' toml_text = "+++\ntitle = 'TOML post'\n+++\nContent" plain_text = "No front matter at all." handler = frontmatter.detect_format(yaml_text, frontmatter.handlers) print(type(handler)) # handler = frontmatter.detect_format(json_text, frontmatter.handlers) print(type(handler)) # handler = frontmatter.detect_format(toml_text, frontmatter.handlers) print(type(handler)) # handler = frontmatter.detect_format(plain_text, frontmatter.handlers) print(handler) # None ``` -------------------------------- ### frontmatter.dump Source: https://context7.com/eyeseast/python-frontmatter/llms.txt Serializes a Post object and writes it to a file path or a writable file-like object. It accepts the same handler and keyword arguments as `dumps`. ```APIDOC ## `frontmatter.dump(post, fd, encoding="utf-8", handler=None, **kwargs) -> None` Serialise a `Post` and write it to a file path or a writable file-like object. Accepts the same `handler` and `**kwargs` as `dumps`. ```python import frontmatter from io import StringIO import pathlib post = frontmatter.load("post.md") post["updated"] = "2024-01-15" # Write to an open file-like object buffer = StringIO() frontmatter.dump(post, buffer) print(buffer.getvalue()) # Write to a file path (string) frontmatter.dump(post, "output.md") # Write to a pathlib.Path frontmatter.dump(post, pathlib.Path("output.md")) # Round-trip: load → modify → save post = frontmatter.load("draft.md") post["published"] = True del post["draft"] frontmatter.dump(post, "draft.md") # overwrite in place ``` ``` -------------------------------- ### Dump post to file object Source: https://github.com/eyeseast/python-frontmatter/blob/main/README.md Write a post object to a file or file-like object, including its front matter. ```python from io import StringIO f = StringIO() frontmatter.dump(post, f) print(f.getvalue()) ``` -------------------------------- ### Serialize Post Object to File Source: https://context7.com/eyeseast/python-frontmatter/llms.txt Use `frontmatter.dump()` to write a Post object to a file path or a file-like object. It accepts the same handler and keyword arguments as `dumps()`. ```python import frontmatter from io import StringIO import pathlib post = frontmatter.load("post.md") post["updated"] = "2024-01-15" # Write to an open file-like object buffer = StringIO() frontmatter.dump(post, buffer) print(buffer.getvalue()) # Write to a file path (string) frontmatter.dump(post, "output.md") # Write to a pathlib.Path frontmatter.dump(post, pathlib.Path("output.md")) # Round-trip: load → modify → save post = frontmatter.load("draft.md") post["published"] = True del post["draft"] frontmatter.dump(post, "draft.md") # overwrite in place ``` -------------------------------- ### Custom ReverseYAMLHandler for Bottom-Placed Front Matter Source: https://context7.com/eyeseast/python-frontmatter/llms.txt Implements a handler where front matter is placed at the bottom of the file, using a specific boundary string. Requires overriding FM_BOUNDARY, split, and format methods. ```python # --- Example 2: Reversed handler (front matter at the bottom) --- class ReverseYAMLHandler(YAMLHandler): FM_BOUNDARY = "---" # plain string, not a regex def split(self, text): content, fm, _ = text.rsplit(self.FM_BOUNDARY, 2) return fm, content def format(self, post, **kwargs): start = kwargs.pop("start_delimiter", self.START_DELIMITER) end = kwargs.pop("end_delimiter", self.END_DELIMITER) meta = self.export(post.metadata, **kwargs) return f"{post.content}\n\n{start}\n{meta}\n{end}".strip() bottom_text = "Article body.\n\n---\ntitle: Bottom FM ---" post = frontmatter.loads(bottom_text, handler=ReverseYAMLHandler()) print(post["title"]) # Bottom FM print(post.content) # Article body. ``` -------------------------------- ### frontmatter.dumps Source: https://context7.com/eyeseast/python-frontmatter/llms.txt Serializes a Post object back into a string with front matter first. It supports custom handlers and forwards extra keyword arguments to the underlying serializer. ```APIDOC ## `frontmatter.dumps(post, handler=None, **kwargs) -> str` Serialise a `Post` back into a string, front matter first. The handler used for output is (in priority order) the `handler` keyword argument, the handler stored on `post.handler`, or `YAMLHandler` as a final default. Extra keyword arguments are forwarded to the underlying serialiser (e.g., `sort_keys`, `Dumper` for YAML). ```python import frontmatter post = frontmatter.load("post.md") post["excerpt"] = "tl;dr" # Dump to string (YAML front matter, the default) text = frontmatter.dumps(post) print(text) # --- # excerpt: tl;dr # layout: post # title: Hello, world! # --- # # Well, hello there, world. # Preserve insertion order (do not sort keys) text = frontmatter.dumps(post, sort_keys=False) # Change output format to JSON on the fly from frontmatter.default_handlers import JSONHandler text = frontmatter.dumps(post, handler=JSONHandler()) print(text[:40]) # { "excerpt": "tl;dr", ... # Use custom delimiters text = frontmatter.dumps(post, start_delimiter="+++", end_delimiter="+++") print(text.splitlines()[0]) # +++ ``` ``` -------------------------------- ### Access post content Source: https://github.com/eyeseast/python-frontmatter/blob/main/README.md Retrieve the main content of the post. ```python print(post.content) ``` -------------------------------- ### frontmatter.parse Source: https://context7.com/eyeseast/python-frontmatter/llms.txt Parses text from a string or file-like object and returns a tuple of (metadata_dict, content_str), without creating a Post object. ```APIDOC ## frontmatter.parse(text, encoding="utf-8", handler=None, **defaults) -> tuple[dict, str] ### Description Parse text and return a plain `(metadata_dict, content_str)` two-tuple instead of a `Post` object. Useful when you only need the raw pieces and do not want the overhead of a `Post` instance, or when you prefer to work with native dicts directly. ### Parameters #### Path Parameters - **text** (str | file-like object) - Required - The text or file-like object to parse. - **encoding** (str) - Optional - The encoding to use if `text` is a file-like object. Defaults to "utf-8". - **handler** (BaseHandler) - Optional - The handler to use for parsing front matter. If None, it's auto-detected. - **defaults** (dict) - Optional - Keyword arguments that serve as default metadata values. ### Request Example ```python import frontmatter with open("post.md") as f: metadata, content = frontmatter.parse(f.read()) print(metadata["title"]) print(content) # Works with defaults too metadata, content = frontmatter.parse( "---\nauthor: Alice\n---\nBody", layout="article", # default added to metadata dict ) print(metadata) # When no front matter is present, metadata equals the defaults metadata, content = frontmatter.parse("No front matter here.", status="published") print(metadata) print(content) ``` ### Response #### Success Response (tuple[dict, str]) - **metadata** (dict) - The parsed metadata from the front matter. - **content** (str) - The content of the document after the front matter. ``` -------------------------------- ### Load post with UTF-8-SIG encoding Source: https://github.com/eyeseast/python-frontmatter/blob/main/README.md Load a post from a file, ensuring Byte-Order Mark (BOM) is stripped by using 'utf-8-sig' encoding. ```python with open('tests/yaml/hello-world.txt', encoding="utf-8-sig") as f: post = frontmatter.load(f) ``` -------------------------------- ### Access post metadata by key Source: https://github.com/eyeseast/python-frontmatter/blob/main/README.md Access specific metadata values using dictionary-like key access. ```python print(post['title']) ``` -------------------------------- ### Parse String with python-frontmatter Source: https://context7.com/eyeseast/python-frontmatter/llms.txt Use `frontmatter.loads` to parse a string into a Post instance. This is useful when the document source is already in memory. It handles CRLF line endings and returns an empty metadata dictionary for text without front matter. ```python import frontmatter text = """ --- title: My Article tags: [python, parsing] draft: false --- This is the article body. """ post = frontmatter.loads(text) print(post["title"]) print(post["tags"]) print(post["draft"]) print(post.content) # CRLF line endings are handled transparently crlf_text = b'---\r\ntitle: "my title"\r\n---\r\n\r\nBody text' post = frontmatter.loads(crlf_text, "utf-8") print(post["title"]) # Text with no front matter is returned with empty metadata bare = frontmatter.loads("Just some plain text, no delimiters.") print(bare.metadata) print(bare.content) ``` -------------------------------- ### Custom PandocHandler for Pandoc-Style Front Matter Source: https://context7.com/eyeseast/python-frontmatter/llms.txt Extends YAMLHandler to support Pandoc's front matter delimiters (--- ... ---). Requires overriding START_DELIMITER, END_DELIMITER, and the split method. ```python import re import frontmatter from frontmatter.default_handlers import BaseHandler, YAMLHandler # --- Example 1: Pandoc front matter (--- ... ---) --- class PandocHandler(YAMLHandler): START_DELIMITER = "---" END_DELIMITER = "..." def split(self, text): _, start, rest = text.partition(self.START_DELIMITER) fm, _, content = rest.partition(self.END_DELIMITER) return fm, content pandoc_text = "---\ntitle: Pandoc Doc ... Body content." post = frontmatter.loads(pandoc_text, handler=PandocHandler()) print(post["title"]) # Pandoc Doc print(frontmatter.dumps(post).splitlines()[-1]) # Body content. ``` -------------------------------- ### Post Object Usage and Manipulation Source: https://context7.com/eyeseast/python-frontmatter/llms.txt The `Post` object holds content and metadata. Access metadata via attribute or item syntax, modify it, and convert the object to string or dictionary representations. ```python import frontmatter post = frontmatter.loads("---\ntitle: Guide\nauthor: Alice\n---\nBody text.") # Attribute access print(post.content) # Body text. print(post.metadata) # {'title': 'Guide', 'author': 'Alice'} # Item-style access print(post["title"]) # Guide print(post.get("missing", "default")) # default # Mutation post["status"] = "published" del post["author"] print(sorted(post.keys())) # ['status', 'title'] # Membership test print("title" in post) # True print("author" in post) # False # String and bytes conversion print(str(post)) # Body text. print(bytes(post)) # b'Body text.' # Serialise to dict (includes "content" key) d = post.to_dict() print(d) # {'title': 'Guide', 'status': 'published', 'content': 'Body text.'} ``` -------------------------------- ### Dump post to plain text Source: https://github.com/eyeseast/python-frontmatter/blob/main/README.md Convert a post object back into its plain text representation, including front matter. ```python print(frontmatter.dumps(post)) ``` -------------------------------- ### frontmatter.detect_format Source: https://context7.com/eyeseast/python-frontmatter/llms.txt Detects the front matter format of a given text by iterating through a list of handlers and returning the first one that matches, or None if no handler matches. ```APIDOC ## `frontmatter.detect_format(text, handlers) -> BaseHandler | None` Iterate over a list of handler instances and return the first one whose `detect()` method matches the text, or `None` if no handler matches. Used internally by `load`/`loads` but also useful for inspection. ```python import frontmatter from frontmatter.default_handlers import YAMLHandler, JSONHandler, TOMLHandler yaml_text = "---\ntitle: YAML post\n---\nContent" json_text = '{ "title": "JSON post" }\nContent' toml_text = "+++\ntitle = 'TOML post'\n+++\nContent" plain_text = "No front matter at all." handler = frontmatter.detect_format(yaml_text, frontmatter.handlers) print(type(handler)) # handler = frontmatter.detect_format(json_text, frontmatter.handlers) print(type(handler)) # handler = frontmatter.detect_format(toml_text, frontmatter.handlers) print(type(handler)) # handler = frontmatter.detect_format(plain_text, frontmatter.handlers) print(handler) # None ``` ``` -------------------------------- ### Post Object Source: https://context7.com/eyeseast/python-frontmatter/llms.txt The Post object is the container for content and metadata, returned by load/loads. It allows attribute and item-style access to metadata, supports mutation, and can be converted to string or bytes. ```APIDOC ## `class Post(content, handler=None, **metadata)` The container object returned by `load` and `loads`. Exposes `post.content` (str), `post.metadata` (dict), and `post.handler`. Metadata keys are accessible directly via item syntax (`post["key"]`), and the object converts to its content string via `str(post)` or `bytes(post)`. ```python import frontmatter post = frontmatter.loads("---\ntitle: Guide\nauthor: Alice\n---\nBody text.") # Attribute access print(post.content) # Body text. print(post.metadata) # {'title': 'Guide', 'author': 'Alice'} # Item-style access print(post["title"]) # Guide print(post.get("missing", "default")) # default # Mutation post["status"] = "published" del post["author"] print(sorted(post.keys())) # ['status', 'title'] # Membership test print("title" in post) # True print("author" in post) # False # String and bytes conversion print(str(post)) # Body text. print(bytes(post)) # b'Body text.' # Serialise to dict (includes "content" key) d = post.to_dict() print(d) # {'title': 'Guide', 'status': 'published', 'content': 'Body text.'} ``` ``` -------------------------------- ### Check for Front Matter in Files and Strings Source: https://context7.com/eyeseast/python-frontmatter/llms.txt Use `frontmatter.check()` to determine if a file or string contains front matter. This is useful for conditionally processing files. ```python import frontmatter # File-based check has_fm = frontmatter.check("post.md") # True no_fm = frontmatter.check("plain.txt") # False # String-based check frontmatter.checks("---\ntitle: Hi\n---\nBody") # True frontmatter.checks("---\n---\nOnly body") # True (empty but present) frontmatter.checks("Just plain text") # False # Practical use: skip files that have no front matter import pathlib for path in pathlib.Path("content").glob("**/*.md"): if frontmatter.check(path): post = frontmatter.load(path) process(post) ``` -------------------------------- ### Serialize Post Object to String Source: https://context7.com/eyeseast/python-frontmatter/llms.txt Use `frontmatter.dumps()` to convert a Post object back into a string. You can specify a handler, custom delimiters, and forward arguments to the underlying serializer. ```python import frontmatter post = frontmatter.load("post.md") post["excerpt"] = "tl;dr" # Dump to string (YAML front matter, the default) text = frontmatter.dumps(post) print(text) # --- # excerpt: tl;dr # layout: post # title: Hello, world! # --- # # Well, hello there, world. # Preserve insertion order (do not sort keys) text = frontmatter.dumps(post, sort_keys=False) # Change output format to JSON on the fly from frontmatter.default_handlers import JSONHandler text = frontmatter.dumps(post, handler=JSONHandler()) print(text[:40]) # { "excerpt": "tl;dr", ... # Use custom delimiters text = frontmatter.dumps(post, start_delimiter="+++", end_delimiter="+++") print(text.splitlines()[0]) # +++ ``` -------------------------------- ### Update and view post metadata Source: https://github.com/eyeseast/python-frontmatter/blob/main/docs/index.md Modify the metadata dictionary and view the updated metadata. ```python post['excerpt'] = 'tl;dr' pprint(post.metadata) ``` -------------------------------- ### frontmatter.check / frontmatter.checks Source: https://context7.com/eyeseast/python-frontmatter/llms.txt Detects if a file or string contains front matter without fully parsing it. `check` works with file objects/paths, `checks` works with strings. ```APIDOC ## frontmatter.check(fd, encoding="utf-8") -> bool ## frontmatter.checks(text, encoding="utf-8") -> bool ### Description Detect whether a file (or raw text string) contains any recognised front matter without fully parsing it. Returns `True` even when the front matter block is present but empty. `check` accepts a filename or file object; `checks` accepts a string. ### Parameters #### Path Parameters - **fd** (str | pathlib.Path | file-like object) - Required (for `check`) - The file path or file-like object to check. - **text** (str) - Required (for `checks`) - The string to check for front matter. - **encoding** (str) - Optional - The encoding to use when reading the file or text. Defaults to "utf-8". ### Request Example ```python import frontmatter # Example for frontmatter.check (file-based) # with open("post.md", "r") as f: # has_frontmatter = frontmatter.check(f) # print(has_frontmatter) # Example for frontmatter.checks (string-based) text_with_fm = "---\ntitle: Example\n---\nContent" text_without_fm = "Just content." print(frontmatter.checks(text_with_fm)) print(frontmatter.checks(text_without_fm)) ``` ### Response #### Success Response (bool) - **True** - If front matter is detected. - **False** - If no front matter is detected. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.