-
Notifications
You must be signed in to change notification settings - Fork 32
/
mdtopdf_test.go
160 lines (127 loc) · 3.67 KB
/
mdtopdf_test.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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
* Markdown to PDF Converter
* Available at http://github.com/mandolyte/mdtopdf
*
* Copyright © 2018 Cecil New <cecil.new@gmail.com>.
* Distributed under the MIT License.
* See README.md for details.
*
* Dependencies
* This package depends on two other packages:
*
* Blackfriday Markdown Processor
* Available at http://github.com/russross/blackfriday
*
* fpdf - a PDF document generator with high level support for
* text, drawing and images.
* Available at https://github.com/go-pdf/fpdf
*/
package mdtopdf
import (
"os"
"path"
"strings"
"testing"
)
func testit(inputf string, gohighlight bool, t *testing.T) {
inputd := "./testdata/"
input := path.Join(inputd, inputf)
tracerfile := path.Join(inputd, strings.TrimSuffix(path.Base(input), ".text"))
tracerfile += ".log"
pdffile := path.Join(inputd, strings.TrimSuffix(path.Base(input), ".text"))
pdffile += ".pdf"
content, err := os.ReadFile(input)
if err != nil {
t.Errorf("%v:%v", input, err)
}
var r *PdfRenderer
var opts []RenderOption
if gohighlight {
opts := []RenderOption{IsHorizontalRuleNewPage(true), SetSyntaxHighlightBaseDir("./highlight/syntax_files")}
r = NewPdfRenderer("", "", pdffile, tracerfile, opts, LIGHT)
} else {
r = NewPdfRenderer("", "", pdffile, tracerfile, opts, LIGHT)
}
err = r.Process(content)
if err != nil {
t.Error(err)
}
}
func TestTables(t *testing.T) {
testit("Tables.text", false, t)
}
func TestMarkdownDocumenationBasic(t *testing.T) {
testit("Markdown Documentation - Basics.text", false, t)
}
func TestMarkdownDocumenationSyntax(t *testing.T) {
testit("Markdown Documentation - Syntax.text", false, t)
}
func TestMarkdownDocumenationColourSyntax(t *testing.T) {
testit("Markdown Documentation - Colour.text", true, t)
}
func TestImage(t *testing.T) {
testit("Image.text", false, t)
}
func TestAutoLinks(t *testing.T) {
testit("Auto links.text", false, t)
}
func TestAmpersandEncoding(t *testing.T) {
testit("Amps and angle encoding.text", false, t)
}
func TestInlineLinks(t *testing.T) {
testit("Links, inline style.text", false, t)
}
func TestLists(t *testing.T) {
testit("Ordered and unordered lists.text", false, t)
}
func TestStringEmph(t *testing.T) {
testit("Strong and em together.text", false, t)
}
func TestTabs(t *testing.T) {
testit("Tabs.text", false, t)
}
func TestBackslashEscapes(t *testing.T) {
testit("Backslash escapes.text", false, t)
}
func TestBackquotes(t *testing.T) {
testit("Blockquotes with code blocks.text", false, t)
}
func TestCodeBlocks(t *testing.T) {
testit("Code Blocks.text", false, t)
}
func TestCodeSpans(t *testing.T) {
testit("Code Spans.text", false, t)
}
func TestHardWrappedPara(t *testing.T) {
testit("Hard-wrapped paragraphs with list-like lines no empty line before block.text", false, t)
}
func TestHardWrappedPara2(t *testing.T) {
testit("Hard-wrapped paragraphs with list-like lines.text", false, t)
}
func TestHorizontalRules(t *testing.T) {
testit("Horizontal rules.text", false, t)
}
func TestInlineHtmlSimple(t *testing.T) {
testit("Inline HTML (Simple).text", false, t)
}
func TestInlineHtmlAdvanced(t *testing.T) {
testit("Inline HTML (Advanced).text", false, t)
}
func TestInlineHtmlComments(t *testing.T) {
testit("Inline HTML comments.text", false, t)
}
func TestTitleWithQuotes(t *testing.T) {
testit("Literal quotes in titles.text", false, t)
}
func TestNestedBlockquotes(t *testing.T) {
testit("Nested blockquotes.text", false, t)
}
func TestLinksReference(t *testing.T) {
testit("Links, reference style.text", false, t)
}
func TestLinksShortcut(t *testing.T) {
testit("Links, shortcut references.text", false, t)
}
func TestTidyness(t *testing.T) {
testit("Tidyness.text", false, t)
}