MCPcopy Create free account
hub / github.com/astercloud/aster / parseMarkdownRules

Method parseMarkdownRules

pkg/memory/rules/manager.go:177–199  ·  view source on GitHub ↗

parseMarkdownRules 解析 Markdown 格式的规则

(content, sourcePath string, scope Scope)

Source from the content-addressed store, hash-verified

175
176// parseMarkdownRules 解析 Markdown 格式的规则
177func (m *Manager) parseMarkdownRules(content, sourcePath string, scope Scope) ([]*Rule, error) {
178 var rules []*Rule
179
180 // 整个文件作为一条规则
181 title := extractTitle(content)
182 if title == "" {
183 title = filepath.Base(sourcePath)
184 }
185
186 rule := &Rule{
187 ID: generateID(),
188 Scope: scope,
189 Title: title,
190 Content: content,
191 Source: "file",
192 SourcePath: sourcePath,
193 Priority: 0,
194 Enabled: true,
195 }
196 rules = append(rules, rule)
197
198 return rules, nil
199}
200
201// extractTitle 从 Markdown 中提取标题
202func extractTitle(content string) string {

Callers 1

loadRulesFromFileMethod · 0.95

Calls 2

extractTitleFunction · 0.85
generateIDFunction · 0.70

Tested by

no test coverage detected