Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove default behaviour of ruamel.yaml line breaking #33

Merged
merged 3 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mdformat_frontmatter/plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import io
import sys
from typing import Mapping

from markdown_it import MarkdownIt
Expand All @@ -11,6 +12,7 @@
yaml = ruamel.yaml.YAML()
# Make sure to always have `sequence >= offset + 2`
yaml.indent(mapping=2, sequence=4, offset=2)
yaml.width = sys.maxsize


def update_mdit(mdit: MarkdownIt) -> None:
Expand All @@ -36,4 +38,5 @@ def _render_frontmatter(node: RenderTreeNode, context: RenderContext) -> str:
return node.markup + "\n" + formatted_yaml + node.markup


# apply the render function to the block identified by the mdit plugin
RENDERERS: Mapping[str, Render] = {"front_matter": _render_frontmatter}
11 changes: 11 additions & 0 deletions tests/fixtures.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,14 @@ Dont format.
Dont format.
---
.

Test long line endings
.
---
somethingthatis: reallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallylong
---
.
---
somethingthatis: reallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallylong
---
.
Loading