Skip to content

Commit

Permalink
fix: added alt attribute to image plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Kruceo committed Mar 25, 2024
1 parent 7990bb9 commit ac490a6
Show file tree
Hide file tree
Showing 5 changed files with 4,708 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
.vscode
marceo-go
ztest.*
*.sh
*.sh
*.json
12 changes: 9 additions & 3 deletions library/plugins/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ import (

var imageRegex *regexp.Regexp = regexp.MustCompile(`(!\[)` + `(.+?)` + `(\]\(.+?\))`)
var imageHandler func(s, c, e string) string = func(s, c, e string) string {
url, _ := strings.CutPrefix(e, `](`)
url, _ = strings.CutSuffix(url, ")")
return "<image src=\"" + url + "\" title=\"" + c + "\"/>"
rawurl, _ := strings.CutPrefix(e, `](`)
rawurl, _ = strings.CutSuffix(rawurl, ")")
splitedUrl := strings.Split(rawurl, " ")
url := splitedUrl[0]
alt := c
if len(splitedUrl) > 1 {
alt = splitedUrl[1]
}
return "<image src=\"" + url + "\" title=\"" + c + "\" alt=\"" + alt + "\"/>"
}

var Image = classes.NewPlugin("image", *imageRegex, imageHandler, classes.PluginOptions{HideContent: true})
15 changes: 12 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
"github.com/kruceo/marceo-go/library/packs"
)

const version string = "0.4.2"
const version string = "0.6.3"

func main() {
var inputText string = ""
var outputPath string = ""
var isParalel bool = false
for index, v := range os.Args {
if v == "-i" {
if len(os.Args) > index+1 {
Expand All @@ -37,20 +38,28 @@ func main() {
}

}
if v == "-p" {
isParalel = true
}
if v == "-v" {
println("v" + version)
break
}
if v == "--help" || v == "-h" {
println("-i $path$ ", "Read the input path file and parse to html.")
println("-o $path$ ", "Use the input path to write the results in a file.")
println("-p ", "Use paralelism.")
println("-v ", "Show version.")
println("--help -h ", "Show this message.")
}
}

var parsedText = packs.DefaultPack.Parse(inputText)

var parsedText = ""
if !isParalel {
parsedText = packs.DefaultPack.Parse(inputText)
} else {
parsedText = packs.DefaultPack.ParalelParse(inputText)
}
if outputPath != "" {
os.WriteFile(outputPath, []byte(parsedText), 0644)
} else if inputText != "" {
Expand Down
8 changes: 0 additions & 8 deletions package.json

This file was deleted.

Loading

0 comments on commit ac490a6

Please sign in to comment.