Skip to content

Commit

Permalink
fix: remove default behaviour of ruamel.yaml line breaking (#33)
Browse files Browse the repository at this point in the history
* fix(cicd): Correct flit behaviour to just work

Signed-off-by: Chris Butler <[email protected]>

* feat: Ensure that ruamel.yaml does not wrap lines

Signed-off-by: Chris Butler <[email protected]>

---------

Signed-off-by: Chris Butler <[email protected]>
  • Loading branch information
butler54 authored Nov 7, 2023
1 parent e4c73ab commit a3ebe8a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
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
---
.

0 comments on commit a3ebe8a

Please sign in to comment.