File: example.go

package info (click to toggle)
golang-github-muesli-roff 0.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 136 kB
  • sloc: makefile: 5
file content (43 lines) | stat: -rw-r--r-- 919 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main

import (
	"fmt"
	"time"

	"github.com/muesli/roff"
)

func main() {
	doc := roff.NewDocument()
	doc.Heading(1, "Title", "A short description", time.Now())

	// a section of text
	doc.Section("Introduction")
	doc.Text("Here is a quick introduction to writing roff documents with Go!")

	// fonts
	doc.Section("Fonts")
	doc.Text("This is a text with a bold font: ")
	doc.TextBold("I am bold!")
	doc.Paragraph()
	doc.Text("This is a text with an italic font: ")
	doc.TextItalic("I am italic!")

	// indentation
	doc.Section("Indentation")
	doc.Text("This block of text is left-aligned to the section.")
	doc.Indent(4)
	doc.Text("This block of text is totally indented.")
	doc.IndentEnd()
	doc.Text("... left-aligned & happy again!")

	// lists
	doc.Section("Lists")
	doc.Text("A list:")
	doc.Paragraph()
	doc.Indent(4)
	doc.List("First list item")
	doc.List("Second list item")

	fmt.Println(doc.String())
}