MCPcopy Index your code
hub / github.com/github/spec-kit / _split_frontmatter

Method _split_frontmatter

src/specify_cli/integrations/base.py:916–941  ·  view source on GitHub ↗

Split YAML frontmatter from the remaining content. Returns ``("", content)`` when no complete frontmatter block is present. The body is preserved exactly as written so prompt text keeps its intended formatting.

(content: str)

Source from the content-addressed store, hash-verified

914
915 @staticmethod
916 def _split_frontmatter(content: str) -> tuple[str, str]:
917 """Split YAML frontmatter from the remaining content.
918
919 Returns ``("", content)`` when no complete frontmatter block is
920 present. The body is preserved exactly as written so prompt text
921 keeps its intended formatting.
922 """
923 if not content.startswith("---"):
924 return "", content
925
926 lines = content.splitlines(keepends=True)
927 if not lines or lines[0].rstrip("\r\n") != "---":
928 return "", content
929
930 frontmatter_end = -1
931 for i, line in enumerate(lines[1:], start=1):
932 if line.rstrip("\r\n") == "---":
933 frontmatter_end = i
934 break
935
936 if frontmatter_end == -1:
937 return "", content
938
939 frontmatter = "".join(lines[1:frontmatter_end])
940 body = "".join(lines[frontmatter_end + 1 :])
941 return frontmatter, body
942
943 @staticmethod
944 def _render_toml_string(value: str) -> str:

Callers 2

setupMethod · 0.95
_extract_descriptionMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected