-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublication_test.go
More file actions
68 lines (59 loc) · 951 Bytes
/
Copy pathpublication_test.go
File metadata and controls
68 lines (59 loc) · 951 Bytes
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package metadata
import (
"encoding/xml"
"os"
"testing"
"gopkg.in/yaml.v3"
)
func TestPublicationConverter(t *testing.T) {
data := `---
title:
- type: main
text: My Book
file-as: book, my
- type: subtitle
text: An investigation of metadata
creator:
- role: author
text: John Smith
- role: editor
text: Sarah Jones
identifier:
- scheme: URN
text: urn:uuid:02B1F386-E83A-4454-B6EC-422DD949BE43
publisher: My Press
rights: © 2007 John Smith, CC BY-NC
date: 2021-01
stylesheet:
- 1
- 2
- 3
subject:
- 1
- 2
- 3
...`
meta, err := Parse([]byte(data))
if err != nil {
t.Fatal(err)
}
yamlEnc := yaml.NewEncoder(os.Stdout)
yamlEnc.SetIndent(2)
err = yamlEnc.Encode(meta)
if err != nil {
t.Fatal(err)
}
err = yamlEnc.Close()
if err != nil {
t.Fatal(err)
}
epub := meta.EPUB()
println()
enc := xml.NewEncoder(os.Stdout)
enc.Indent("", " ")
err = enc.Encode(epub)
if err != nil {
t.Fatal(err)
}
println()
}