diff --git a/parser/parser.go b/parser/parser.go index 2bf5c01..ebb4e25 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -41,8 +41,6 @@ func DetectType(markdownContent string) (string, error) { } func MatchBlocks(markdownContent, templateContent string) ([]matcher.Block, error) { - markdownContent = strings.TrimSuffix(markdownContent, "\n") - tpl, err := template.CompileTemplate(templateContent) if err != nil { return nil, fmt.Errorf("failed to compile template -> %w", err) @@ -66,13 +64,16 @@ func ParseFile(markdownContent string) (any, error) { } func ParseFileWithTemplate(markdownContent string, templateContent string) (any, error) { - markdownContent = strings.TrimSuffix(markdownContent, "\n") - tpl, err := template.CompileTemplate(templateContent) if err != nil { return nil, fmt.Errorf("failed to compile template -> %w", err) } + for strings.HasSuffix(markdownContent, "\n") { + markdownContent = strings.TrimSuffix(markdownContent, "\n") + } + markdownContent = markdownContent + "\n" + blocks := matcher.MatchBlocksFuzzy(markdownContent, tpl, 0.3) result, err := decoders.Parse(blocks) diff --git a/server/internal/adapters/fs.go b/server/internal/adapters/fs.go index a080257..1cd48ce 100644 --- a/server/internal/adapters/fs.go +++ b/server/internal/adapters/fs.go @@ -2,6 +2,7 @@ package adapters import ( "errors" + "fmt" "os" "path/filepath" "strings" @@ -118,6 +119,7 @@ func (l *LocalFsAdapter) readFile(path string, root string) (*Entry, error) { if err == nil { content = parsedContent } else { + fmt.Println(err) // Fallback to raw content on parsing error content = fileContent }