mirror of
https://github.com/Theodor-Springmann-Stiftung/lenz-web.git
synced 2025-10-29 17:25:32 +00:00
Seitenumbrüche und Weißraum FIX
This commit is contained in:
@@ -2,9 +2,6 @@ package functions
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"strings"
|
||||
|
||||
xmlparsing "github.com/Theodor-Springmann-Stiftung/lenz-web/xml"
|
||||
)
|
||||
|
||||
func FirstLetter(s string) string {
|
||||
@@ -20,41 +17,3 @@ func Safe(s string) template.HTML {
|
||||
}
|
||||
return template.HTML(s)
|
||||
}
|
||||
|
||||
type LenzParseState struct{}
|
||||
|
||||
func ParseGeneric(s string) string {
|
||||
if len(s) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
builder := strings.Builder{}
|
||||
for elem, err := range xmlparsing.Iterate(s, LenzParseState{}) {
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
switch elem.Token.Type {
|
||||
case xmlparsing.StartElement:
|
||||
builder.WriteString("<div class=\"")
|
||||
builder.WriteString(elem.Token.Name)
|
||||
for key, value := range elem.Token.Attributes {
|
||||
builder.WriteString(" ")
|
||||
builder.WriteString(key)
|
||||
builder.WriteString("-")
|
||||
builder.WriteString(value)
|
||||
}
|
||||
|
||||
builder.WriteString("\">")
|
||||
}
|
||||
|
||||
if elem.Token.Type == xmlparsing.CharData {
|
||||
builder.WriteString(elem.Token.Data)
|
||||
}
|
||||
|
||||
if elem.Token.Type == xmlparsing.EndElement {
|
||||
builder.WriteString("</div>")
|
||||
}
|
||||
}
|
||||
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user