Skip to content

Commit

Permalink
Merge pull request #343 from cogentcore/author-png-cover
Browse files Browse the repository at this point in the history
use cover.png instead of cover.jpg for cover image
  • Loading branch information
rcoreilly authored Aug 23, 2024
2 parents 53ea508 + 3081954 commit 686359f
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 31 deletions.
2 changes: 1 addition & 1 deletion author/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The style of the references is determined by the `csl` property in the `metadata
You must use specific file names to indicate the functionality and ordering of the content within the book, as follows, with [] indicating optional files:

* `metadata.yaml`: pandoc metadata with various important options.
* `cover.jpg`: cover image
* `cover.png`: cover image
* `frontmatter.md`: with copyright, dedication, foreward, preface, prologue sections.
* `chapter-*.md` chapters, using 01 etc numbering to put in order.
* `endmatter.md`: includes epilogue, acknowledgements, author
Expand Down
10 changes: 5 additions & 5 deletions author/book/book.cosh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
// following required file names (with [] indicating optional files):
//
// - metadata.yaml: pandoc metadata with various important options
// - cover.jpg: cover image
// - cover.png: cover image
// - frontmatter.md: with copyright, dedication, foreward, preface, prologue sections.
// - chapter-*.md: chapters, using 01 etc numbering to put in order.
// - endmatter.md: includes epilogue, acknowledgements, author
Expand Down Expand Up @@ -116,16 +116,16 @@ func (bk *BookData) HTML(mdfn string) error {
trg := bk.Name + ".html"

cover := bk.pdi("cover_page.html")
img, _, err := imagex.Open("cover.jpg")
img, _, err := imagex.Open("cover.png")
if err != nil {
return errors.Log(err)
}
imgb64, _ := imagex.ToBase64JPG(img)
imgb64, _ := imagex.ToBase64PNG(img)
f, err := os.Create(cover)
if errors.Log(err); err != nil {
return err
}
f.Write([]byte("<div id=\"cover-image\">\n<img src=\"data:image/jpg;base64,"))
f.Write([]byte("<div id=\"cover-image\">\n<img src=\"data:image/png;base64,"))
f.Write(imgb64)
f.Write([]byte("\"/>\n</div>\n"))
f.Close()
Expand Down Expand Up @@ -171,7 +171,7 @@ func (bk *BookData) EPUB(mdfn string) error {
fmt.Fprintf(f, "<dc:identifier id=\"BookId\" opf:scheme=%q>%s</dc:identifier>\n", md["identifier_scheme"], md["identifier"])
f.Close()

pandoc -f {mdopts} --lua-filter {bk.pdi("glossary-filter.lua")} -F pandoc-crossref --citeproc --bibliography references.bib -t epub --standalone --embed-resources --number-sections --css {bk.pdi("epub.css")} --epub-metadata {emd} --epub-cover-image "cover.jpg" -o {trg} {mdfn}
pandoc -f {mdopts} --lua-filter {bk.pdi("glossary-filter.lua")} -F pandoc-crossref --citeproc --bibliography references.bib -t epub --standalone --embed-resources --number-sections --css {bk.pdi("epub.css")} --epub-metadata {emd} --epub-cover-image "cover.png" -o {trg} {mdfn}
return nil
}

Expand Down
11 changes: 5 additions & 6 deletions author/book/book.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion author/book/pandoc-inputs/cover-page.latex
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
\thispagestyle{empty}
\begin{center}
\includegraphics[width=5in]{cover.jpg}
\includegraphics[width=6.5in]{cover.png}
\end{center}

2 changes: 1 addition & 1 deletion author/book/pandoc-inputs/latex.template
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ $if(title)$
$if(beamer)$
\frame{\titlepage}
$else$
\maketitle
%% \maketitle
$endif$
$if(abstract)$
\begin{abstract}
Expand Down
49 changes: 33 additions & 16 deletions author/book/pandoc-inputs/latex.template.diff
Original file line number Diff line number Diff line change
@@ -1,27 +1,44 @@
*** latex.template Sat Aug 17 19:13:39 2024
--- default.latex Sat Aug 17 19:20:57 2024
*** default.latex Tue Aug 20 12:29:56 2024
--- latex.template Fri Aug 23 15:08:13 2024
***************
*** 1,4 ****
-
*** 1,3 ****
--- 1,4 ----
+
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref}
\PassOptionsToPackage{hyphens}{url}
--- 1,3 ----
***************
*** 452,466 ****
*** 451,456 ****
--- 452,466 ----
\fi
$endif$
$endif$
- \oddsidemargin 0pt
- \evensidemargin 0pt
- \textwidth 6.5in
- \headheight 12pt
- \headsep .5in
- \topmargin -.75in
- \footskip .75in
- \textheight 9in
- \usepackage[font=small]{caption}
+ \oddsidemargin 0pt
+ \evensidemargin 0pt
+ \textwidth 6.5in
+ \headheight 12pt
+ \headsep .5in
+ \topmargin -.75in
+ \footskip .75in
+ \textheight 9in
+ \usepackage[font=small]{caption}
$for(header-includes)$
$header-includes$
$endfor$
--- 451,456 ----
***************
*** 556,562 ****
$if(beamer)$
\frame{\titlepage}
$else$
! \maketitle
$endif$
$if(abstract)$
\begin{abstract}
--- 566,572 ----
$if(beamer)$
\frame{\titlepage}
$else$
! %% \maketitle
$endif$
$if(abstract)$
\begin{abstract}
2 changes: 1 addition & 1 deletion author/book/typegen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 686359f

Please sign in to comment.