Skip to content

Commit 86fa9aa

Browse files
committed
md2pdf.go: check for syntax files under /usr/share/mdtopdf/syntax_files, which is where the Deb and RPM packages place them
1 parent 547d3b1 commit 86fa9aa

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

.goreleaser.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ nfpms:
6969
expand: true
7070
file_info:
7171
mode: 0755
72-
- src: ./highlight
73-
dst: /usr/share/{{ .PackageName }}/syntax_highlight
72+
- src: ./highlight/syntax_files
73+
dst: /usr/share/{{ .PackageName }}/syntax_files
7474
expand: true
7575
file_info:
7676
mode: 0755

cmd/md2pdf/md2pdf.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ func main() {
8686
if *pathToSyntaxFiles != "" {
8787
opts = append(opts, mdtopdf.SetSyntaxHighlightBaseDir(*pathToSyntaxFiles))
8888
} else {
89-
opts = append(opts, mdtopdf.SetSyntaxHighlightBaseDir("../../highlight/syntax_files"))
89+
if _, err := os.Stat("../../highlight/syntax_files"); err == nil {
90+
opts = append(opts, mdtopdf.SetSyntaxHighlightBaseDir("/usr/share/mdtopdf/syntax_files"))
91+
} else if _, err := os.Stat("/usr/share/mdtopdf/syntax_files"); err == nil {
92+
opts = append(opts, mdtopdf.SetSyntaxHighlightBaseDir("../../highlight/syntax_files"))
93+
}
9094
}
9195

9296
// get text for PDF
@@ -169,6 +173,8 @@ func main() {
169173
pf.Extensions = parser.NoIntraEmphasis | parser.Tables | parser.FencedCode | parser.Autolink | parser.Strikethrough | parser.SpaceHeadings | parser.HeadingIDs | parser.BackslashLineBreak | parser.DefinitionLists
170174

171175
if *fontFile != "" && *fontName != "" {
176+
fmt.Println(*fontFile)
177+
// pf.Pdf.AddUTF8Font(*fontName, "", *fontFile)
172178
pf.Pdf.AddFont(*fontName, "", *fontFile)
173179
pf.Pdf.SetFont(*fontName, "", 12)
174180
pf.Normal = mdtopdf.Styler{

0 commit comments

Comments
 (0)