Ejemplo n.º 1
0
func (mr *markdownRenderer) ListItem(out *bytes.Buffer, text []byte, flags int) {
	/*if flags&blackfriday.LIST_ITEM_CONTAINS_BLOCK != 0 {
		doubleSpace(out)
	}*/
	//text = bytes.Replace(text, []byte("\n"), append([]byte("\n"), bytes.Repeat([]byte("\t"), 1)...), -1)
	if flags&blackfriday.LIST_TYPE_ORDERED != 0 {
		fmt.Fprintf(out, "%d.", mr.orderedListCounter[mr.listDepth])
		indentwriter.New(out, 1).Write(text)
		mr.orderedListCounter[mr.listDepth]++
	} else if flags&blackfriday.LIST_TYPE_TERM != 0 {
		out.WriteString("\n")
		indentwriter.New(out, 0).Write(text)
	} else if flags&blackfriday.LIST_TYPE_DEFINITION != 0 {
		out.WriteString(":")
		indentwriter.New(out, 1).Write(text)
	} else {
		out.WriteString("-")
		indentwriter.New(out, 1).Write(text)
	}
	out.WriteString("\n")
	if mr.paragraph[mr.listDepth] {
		if flags&blackfriday.LIST_ITEM_END_OF_LIST == 0 {
			out.WriteString("\n")
		}
		mr.paragraph[mr.listDepth] = false
	}
}
Ejemplo n.º 2
0
func (mr *markdownRenderer) ListItem(out *bytes.Buffer, text []byte, flags int) {
	if flags&blackfriday.LIST_TYPE_ORDERED != 0 {
		fmt.Fprintf(out, "%d.", mr.orderedListCounter[mr.listDepth])
		indentwriter.New(out, 1).Write(text)
		mr.orderedListCounter[mr.listDepth]++
	} else {
		out.WriteString("-")
		indentwriter.New(out, 1).Write(text)
	}
	out.WriteString("\n")
	if mr.paragraph[mr.listDepth] {
		if flags&blackfriday.LIST_ITEM_END_OF_LIST == 0 {
			out.WriteString("\n")
		}
		mr.paragraph[mr.listDepth] = false
	}
}
Ejemplo n.º 3
0
func Example() {
	iw := indentwriter.New(os.Stdout, 1)

	io.WriteString(iw, `IndentWriter is simple Go package you can import for the following task.

You take an existing io.Writer, and an integer "indent",
and create this IndentWriter that implements io.Writer too, but it prepends every line with
indent number of tabs.

Note that only non-empty lines get indented.
`)

	// Output:
	// 	IndentWriter is simple Go package you can import for the following task.
	//
	// 	You take an existing io.Writer, and an integer "indent",
	// 	and create this IndentWriter that implements io.Writer too, but it prepends every line with
	// 	indent number of tabs.
	//
	// 	Note that only non-empty lines get indented.
	//
}