func (ctx *Context) Parse(r io.Reader, name string, mode ParseMode) (*models.Doc, error) {
	doc := new(models.Doc)
	lines, err := readLines(r)
	if err != nil {
		return nil, err
	}
	for i := lines.Line; i < len(lines.Text); i++ {
		if strings.HasPrefix(lines.Text[i], "*") {
			break
		}
		if isSpeakerNote(lines.Text[i]) {
			doc.TitleNotes = append(doc.TitleNotes, lines.Text[i][2:])
		}
	}
	err = parseHeader(doc, lines)
	if err != nil {
		return nil, err
	}
	if mode&TitlesOnly != 0 {
		return doc, nil
	}
	if doc.Authors, err = parseAuthors(lines); err != nil {
		return nil, err
	}
	if doc.Sections, err = parseSections(ctx, name, lines, []int{}); err != nil {
		return nil, err
	}
	return doc, nil
}
Parse parses a document from r.
package present
import (
	"bufio"
	"bytes"
	"errors"
	"fmt"
	"html/template"
	"io"
	"io/ioutil"
	"log"
	"net/url"
	"regexp"
	"strings"
	"time"
	"unicode"
	"unicode/utf8"
	"github.com/gernest/vectypresent/present/models"
)
var (
	parsers = make(map[string]ParseFunc)
	funcs   = template.FuncMap{}
)
func Template() *template.Template {
	return template.New("").Funcs(funcs)
}
type ParseFunc func(ctx *Context, fileName string, lineNumber int, inputLine string) (models.Elem, error)
func Register(name string, parser ParseFunc) {
	if len(name) == 0 || name[0] == ';' {
		panic("bad name in Register: " + name)
	}
	parsers["."+name] = parser
}
func renderElem(t *template.Template, e models.Elem) (template.HTML, error) {
	var data interface{} = e
	if s, ok := e.(models.Section); ok {
		data = struct {
			models.Section
			Template *template.Template
		}{s, t}
	}
	return execTemplate(t, e.TemplateName(), data)
}
func init() {
	funcs["elem"] = renderElem
}
func execTemplate(t *template.Template, name string, data interface{}) (template.HTML, error) {
	b := new(bytes.Buffer)
	err := t.ExecuteTemplate(b, name, data)
	if err != nil {
		return "", err
	}
	return template.HTML(b.String()), nil
}
func readLines(r io.Reader) (*models.Lines, error) {
	var lines []string
	s := bufio.NewScanner(r)
	for s.Scan() {
		lines = append(lines, s.Text())
	}
	if err := s.Err(); err != nil {
		return nil, err
	}
	return &models.Lines{Line: 0, Text: lines}, nil
}
type Context struct {
	ReadFile func(filename string) ([]byte, error)
}
type ParseMode int
const (
	TitlesOnly ParseMode = 1
)