From 40141575b24b5a9177623ab99b485f5672dccb93 Mon Sep 17 00:00:00 2001 From: Theo-Hafsaoui Date: Sun, 13 Oct 2024 16:12:27 +0200 Subject: [PATCH] Enable mutltiple skill Closes #1 --- cv/eng/skill.md | 6 ++++-- cv/fr/skill.md | 6 ++++-- internal/markup_languages/markdown.go | 25 ++++++++++++++++++++++--- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/cv/eng/skill.md b/cv/eng/skill.md index 266fcb4..f0df084 100644 --- a/cv/eng/skill.md +++ b/cv/eng/skill.md @@ -1,2 +1,4 @@ -# Languages -## Java, Python, Ruby, Golang, SQL, JavaScript, HTML/CSS +**Languages** + - Java, Python, Ruby, Golang, SQL, JavaScript, HTML/CSS +**Library** + - a bo0k diff --git a/cv/fr/skill.md b/cv/fr/skill.md index 62da3d0..8b3edce 100644 --- a/cv/fr/skill.md +++ b/cv/fr/skill.md @@ -1,3 +1,5 @@ -# Langages -## Langage A, Langage B, Langage C, Langage D, Langage E, Langage F, Langage G/H +**Langage** + - Langage A, Langage B, Langage C, Langage D, Langage E, Langage F, Langage G/H +**Librarie** + - Librarie A, Librarie B, Librarie C, Librarie D, Librarie E, Librarie F, Librarie G/H diff --git a/internal/markup_languages/markdown.go b/internal/markup_languages/markdown.go index c197a07..6c71251 100644 --- a/internal/markup_languages/markdown.go +++ b/internal/markup_languages/markdown.go @@ -24,16 +24,35 @@ func (s Section) String() string { } /* -Parse parses a Markdown-like `paragraph` into a `Section`, extracting headings and description based on the number of leading hashtags. Returns an error if the format is invalid. +Parse parses a Markdown-like `paragraph` into a `Section`, +extracting headings and description based on the number of leading hashtags or stars. +Returns an error if the format is invalid. */ func Parse(paragraph string) (Section,error){ section := Section{} if len(strings.Split(paragraph, "\n\n")) > 1{ return section, errors.New("Tried to parse mutiple paragraph into a single section") } - r, _ := regexp.Compile("^#+") + hashtag_regex, _ := regexp.Compile("^#+") + wasASkill := false for _, line := range strings.Split(strings.TrimRight(paragraph, "\n"), "\n") { - nb_hashtag := len(r.FindString(line)) + nb_hashtag := len(hashtag_regex.FindString(line)) + + if len(line) == 0{ + continue + } + + if wasASkill { + wasASkill = false + section.second= strings.TrimLeft(line,"- ") + } + + if nb_hashtag == 0 && string(line[0])=="*" && len(strings.Trim(line,"*")) == len(line) - 4 {//Trim should **tt** -> tt + section.first= strings.Trim(line,"*") + wasASkill = true + } + + switch{ case nb_hashtag>0 && line[nb_hashtag] != ' ': return section, errors.New("Err: cannot parse this md line{"+line+"} # should be followed by space")