adoc/element/plain.go

26 lines
576 B
Go
Raw Normal View History

2022-03-15 15:16:15 +01:00
package element
2024-09-15 12:07:22 +02:00
import "go-mod.ewintr.nl/adoc/token"
2022-03-15 15:16:15 +01:00
type Word string
func (w Word) Text() string { return string(w) }
func (w Word) Append(_ []Element) Element { return w }
type WhiteSpace string
func (ws WhiteSpace) Text() string { return string(ws) }
func (ws WhiteSpace) Append(_ []Element) Element { return ws }
func MakePlain(tok token.Token) Element {
switch tok.Type {
case token.TYPE_WHITESPACE:
return WhiteSpace(tok.Literal)
case token.TYPE_NEWLINE:
return WhiteSpace(tok.Literal)
default:
return Word(tok.Literal)
}
}