Skip to content

Commit

Permalink
md2pdf.go: check for syntax files under `/usr/share/mdtopdf/syntax_fi…
Browse files Browse the repository at this point in the history
…les`, which is where the Deb and RPM packages place them
  • Loading branch information
jessp01 committed Feb 12, 2025
1 parent 547d3b1 commit 86fa9aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ nfpms:
expand: true
file_info:
mode: 0755
- src: ./highlight
dst: /usr/share/{{ .PackageName }}/syntax_highlight
- src: ./highlight/syntax_files
dst: /usr/share/{{ .PackageName }}/syntax_files
expand: true
file_info:
mode: 0755
Expand Down
8 changes: 7 additions & 1 deletion cmd/md2pdf/md2pdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ func main() {
if *pathToSyntaxFiles != "" {
opts = append(opts, mdtopdf.SetSyntaxHighlightBaseDir(*pathToSyntaxFiles))
} else {
opts = append(opts, mdtopdf.SetSyntaxHighlightBaseDir("../../highlight/syntax_files"))
if _, err := os.Stat("../../highlight/syntax_files"); err == nil {
opts = append(opts, mdtopdf.SetSyntaxHighlightBaseDir("/usr/share/mdtopdf/syntax_files"))
} else if _, err := os.Stat("/usr/share/mdtopdf/syntax_files"); err == nil {
opts = append(opts, mdtopdf.SetSyntaxHighlightBaseDir("../../highlight/syntax_files"))
}
}

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

if *fontFile != "" && *fontName != "" {
fmt.Println(*fontFile)
// pf.Pdf.AddUTF8Font(*fontName, "", *fontFile)
pf.Pdf.AddFont(*fontName, "", *fontFile)
pf.Pdf.SetFont(*fontName, "", 12)
pf.Normal = mdtopdf.Styler{
Expand Down

0 comments on commit 86fa9aa

Please sign in to comment.