-
Notifications
You must be signed in to change notification settings - Fork 0
/
caption.go
38 lines (34 loc) · 867 Bytes
/
caption.go
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
// Copyright 2015 The present-tex Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"github.com/sbinet/present-tex/latex"
"golang.org/x/tools/present"
)
func parseCaptions(doc *present.Doc) error {
var err error
for i := range doc.Sections {
section := &doc.Sections[i]
var captions []int
for j := range section.Elem {
elem := section.Elem[j]
switch elem.(type) {
default:
continue
case present.Caption:
captions = append(captions, j)
}
}
for j := len(captions) - 1; j >= 0; j-- {
idx := captions[j]
section.Elem = append(section.Elem[:idx], section.Elem[idx+1:]...)
}
}
return err
}
func parseCaption(elem *present.Caption) error {
var err error
elem.Text = latex.UTF8(renderFont(elem.Text))
return err
}