ReconstructWorkflowFile reconstructs a complete workflow file from frontmatter YAML and markdown content.
(frontmatterYAML, markdownContent string)
| 88 | |
| 89 | // ReconstructWorkflowFile reconstructs a complete workflow file from frontmatter YAML and markdown content. |
| 90 | func ReconstructWorkflowFile(frontmatterYAML, markdownContent string) (string, error) { |
| 91 | var lines []string |
| 92 | |
| 93 | // Add opening frontmatter delimiter |
| 94 | lines = append(lines, "---") |
| 95 | |
| 96 | // Add frontmatter content (trim trailing newline from YAML marshal) |
| 97 | frontmatterStr := strings.TrimSuffix(frontmatterYAML, "\n") |
| 98 | if frontmatterStr != "" { |
| 99 | lines = append(lines, strings.Split(frontmatterStr, "\n")...) |
| 100 | } |
| 101 | |
| 102 | // Add closing frontmatter delimiter |
| 103 | lines = append(lines, "---") |
| 104 | |
| 105 | // Add markdown content if present |
| 106 | if markdownContent != "" { |
| 107 | lines = append(lines, markdownContent) |
| 108 | } |
| 109 | |
| 110 | return strings.Join(lines, "\n"), nil |
| 111 | } |
| 112 | |
| 113 | // QuoteCronExpressions ensures cron expressions in schedule sections are properly quoted. |
| 114 | // The YAML library may drop quotes from cron expressions like "0 14 * * 1-5" which |
no outgoing calls