mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-12 13:30:26 +00:00
27 lines
593 B
Go
27 lines
593 B
Go
package markup
|
|
|
|
const maxRecursionLevel = 3
|
|
|
|
func Parse(ast []Line, from, to int, recursionLevel int) (html string) {
|
|
if recursionLevel > maxRecursionLevel {
|
|
return "Transclusion depth limit"
|
|
}
|
|
for _, line := range ast {
|
|
if line.id >= from && (line.id <= to || to == 0) || line.id == -1 {
|
|
switch v := line.contents.(type) {
|
|
case Transclusion:
|
|
html += Transclude(v, recursionLevel)
|
|
case Img:
|
|
html += v.ToHtml()
|
|
case Table:
|
|
html += v.asHtml()
|
|
case string:
|
|
html += v
|
|
default:
|
|
html += "<b class='error'>Unknown element.</b>"
|
|
}
|
|
}
|
|
}
|
|
return html
|
|
}
|