Commit e5342cac authored by Artemis's avatar Artemis 🐱

Added line count

parent d983c7ec
......@@ -41,5 +41,14 @@ form fieldset label, form fieldset input, form fieldset textarea {
form fieldset textarea {
resize: vertical;
}
pre > code {
counter-reset: line;
}
pre > code > span:before {
display: inline-block;
counter-increment: line;
content: counter(line) "|";
}
/*# sourceMappingURL=style.css.map */
package main
import "html/template"
import (
"html/template"
"strings"
)
func Linify(input string) template.HTML {
res := ""
for _, v := range strings.Split(input, "\n") {
if v != "" {
res += "<span>" + v[:len(v)-1] + "</span>\n"
}
}
return template.HTML(res)
}
func InitTemplates() *template.Template {
return template.Must(template.ParseGlob("templates/*"))
return template.Must(template.New("").Funcs(template.FuncMap{
"linify": Linify,
}).ParseGlob("templates/*"))
}
{{define "header"}}
<meta charset="UTF-8">
<title>Paste</title>
<link rel="stylesheet" href="https://res.axdn.fr/paste/style.min.css" />
<link rel="stylesheet" href="https://res.axdn.fr/paste/style.css" />
{{end}}
......@@ -17,7 +17,7 @@
<section>
<h2>Your paste</h2>
<pre><code>{{.Value}}</code></pre>
<pre><code>{{.Value|linify}}</code></pre>
</section>
{{template "footer"}}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment