类 MarkdownSkillParser

java.lang.Object
io.agentscope.core.skill.util.MarkdownSkillParser

public class MarkdownSkillParser extends Object
Utility for parsing and generating Markdown files with YAML frontmatter.

This utility can:

  • Extract YAML frontmatter metadata and markdown content from text
  • Generate markdown files with YAML frontmatter from metadata and content

Frontmatter format:


 ---
 name: example_skill
 description: Example skill description
 version: 1.0.0
 ---
 # Skill Content
 This is the markdown content.
 

Usage example:


 // Parse markdown with frontmatter
 ParsedMarkdown parsed = MarkdownSkillParser.parse(markdownContent);
 Map<String, Object> metadata = parsed.getMetadata();
 String content = parsed.getContent();

 // Generate markdown with frontmatter
 String markdown = MarkdownSkillParser.generate(metadata, content);
 
  • 方法详细资料

    • parse

      public static MarkdownSkillParser.ParsedMarkdown parse(String markdown)
      Parse markdown content with YAML frontmatter.

      Extracts both the YAML metadata and the markdown content. If no frontmatter is found, returns empty metadata with the entire content.

      参数:
      markdown - Markdown content (may or may not have frontmatter)
      返回:
      ParsedMarkdown containing metadata and content
    • generate

      public static String generate(Map<String,Object> metadata, String content)
      Generate markdown content with YAML frontmatter.

      Creates a markdown file with the metadata serialized as YAML frontmatter at the beginning, followed by the content.

      参数:
      metadata - Metadata to serialize as YAML frontmatter (can be null or empty)
      content - Markdown content (can be null or empty)
      返回:
      Complete markdown with frontmatter