package wiki import ( "strings" ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/lex" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" kit "shylinux.com/x/toolkits" ) func _spark_md(m *ice.Message, arg ...string) *ice.Message { block, code := "", []string{} text := func() { if len(code) > 0 { m.Cmdy(SPARK, kit.Join(code, lex.NL)) code = []string{} } } m.Cmd(nfs.CAT, arg[0], func(line string) { for _, ls := range [][]string{[]string{"# ", TITLE}, []string{"## ", TITLE, CHAPTER}, []string{"### ", TITLE, SECTION}} { if strings.HasPrefix(line, ls[0]) { text() m.Cmdy(ls[1:], strings.TrimPrefix(line, ls[0])) return } } if strings.HasPrefix(line, "```") { if block == "" { text() block = "```" } else { m.Cmdy(SPARK, SHELL, kit.Join(code, lex.NL)) block, code = "", []string{} } return } code = append(code, line) }) text() return m } func _spark_show(m *ice.Message, name, text string, arg ...string) *ice.Message { return _wiki_template(m.Options(mdb.LIST, kit.SplitLine(text)), name, name, text, arg...) } func _spark_tabs(m *ice.Message, arg ...string) { m.Echo(`