Skip to content

Commit

Permalink
put main layout in main config
Browse files Browse the repository at this point in the history
  • Loading branch information
svbaelen committed Apr 21, 2024
1 parent 40247fc commit 7d86327
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Files: config/html/site.webmanifest
Copyright: 2024 Senne Van Baelen <[email protected]>
License: Apache-2.0

Files: config/**/layout.yaml
Files: config/**/config.yaml
Copyright: 2024 Senne Van Baelen <[email protected]>
License: Apache-2.0

Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ docker image pull svbaelen/cowkit:latest

## Configuration

- `config/config.yaml`: main <b>pandoc config</b>
- `config/<fmt>/layout.yaml`: output-specific <b>layout</b> (which input files to include) + config (can overwrite values set in `config.yaml`).
- `config/config.yaml`: main (output-independent) <b>config</b>
- `config/<fmt>/config.yaml`: output-specific <b>config</b> (can overwrite values set in main `config.yaml`).
- `config/<fmt>/templates/<file>`: <b>templates</b> related to specific output formats
- `src/<file>.md`: <b>content</b> files written in **markdown**. Every section, subsection, paragraph, figure, etc. *can*
have a separate file. In the <b>metadata section</b> of each markdown file (between `---`) you can add all kinds of metadata and config options supported
Expand Down Expand Up @@ -98,7 +98,7 @@ Naturally, these commands can be updated or removed anytime in `~/.bash_aliases`

### Speed up building

If re-running build process is too slow for you, open a `./config/<fmt>/layout.yaml` file and comment out stuff. Start with the <b>Lua-based
If re-running build process is too slow for you, open a `./config/<fmt>/config.yaml` file and comment out stuff. Start with the <b>Lua-based
filters</b> (which will skip bibliography rebuilds). If still too slow, uncomment sections/chapters etc.

## Caveats and known limitations
Expand Down Expand Up @@ -138,7 +138,7 @@ docker push svbaelen/cowkit --all-tags
Native Pandoc:

```sh
pandoc --defaults=./config/config.yaml --defaults=./config/html/layout.yaml \
pandoc --defaults=./config/config.yaml --defaults=./config/html/config.yaml \
--template ./config/html/templates/default.html
```

Expand All @@ -148,21 +148,21 @@ With docker:
docker run --rm --volume "$(pwd):/data" \
--user $(id -u):$(id -g) pandoc/latex:latest \
--defaults=./config/config.yaml \
--defaults=./config/html/layout.yaml --template ./config/html/templates/default.html
--defaults=./config/html/config.yaml --template ./config/html/templates/default.html
```

### Build PDF

```sh
pandoc --defaults=./config/config.yaml --defaults=./config/pdf/layout.yaml
pandoc --defaults=./config/config.yaml --defaults=./config/pdf/config.yaml
```

With docker:

```sh
docker run --rm --volume "$(pwd):/data" \
--user $(id -u):$(id -g) pandoc/latex:latest \
--defaults=./config/config.yaml --defaults=./config/pdf/layout.yaml
--defaults=./config/config.yaml --defaults=./config/pdf/config.yaml
```
## Acknowledgements

Expand Down
27 changes: 23 additions & 4 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,35 @@
# Notes:
# - <https://pandoc.org/MANUAL.html#general-writer-options-1>
# - <https://pandoc.org/MANUAL.html#options-affecting-specific-writers>
# - all options can be overwritten in file-specific './config/<fmt>/layout.yaml'
# - all options can be overwritten in file-specific './config/<fmt>/config.yaml'
# (for `input-files`, file-specific additions are possible, but not a full
# overwrite)
# ==================

from: markdown
filters:
- pandoc-crossref
- src/filters/multiple-bibliographies.lua # comment out for quick build (no refs)
#- src/filters/pandoc-quotes.lua

# you can set input files in output-specific config files as well, if a
# discrepancy is required
input-files:
- ./src/_base.md
- ./src/abstract.md
- ./src/01_intro.md
- ./src/02_chapter_1.md
- ./src/03_conclusion.md
- ./src/04_acknowledgment.md
- ./src/05_references.md
#- ./src/appendix.md # add this per outpuf file (see ./<format>/config.yaml)

cite-method: citeproc # citeproc, natbib, or biblatex
embed-resources: true
file-scope: false # Parse each file individually before combining for multifile
# documents. This will allow footnotes in different files with
# the same identifiers to work as expected. If this option is
# set, footnotes and links will not work across files.
from: markdown
highlight-style: pygments
reference-location: block # block, section, or document
resource-path:
Expand All @@ -24,7 +43,7 @@ resource-path:
standalone: false
top-level-division: default # part, chapter, section, or default
toc: true
listings: true
number-sections: true
verbosity: WARNING # ERROR, WARNING, or INFO

# MORE: output-specific configs (and outline) found in subdirs
toc-depth: 3
26 changes: 8 additions & 18 deletions config/html/layout.yaml → config/html/config.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@
# ================================
# HTML config and layout
# HTML config (can overwrite main config.yaml)
#
# Notes:
# - <https://pandoc.org/MANUAL.html#general-writer-options-1>
# - <https://pandoc.org/MANUAL.html#options-affecting-specific-writers>
# ================================

filters:
- pandoc-crossref
- src/filters/multiple-bibliographies.lua # comment out for quick build (no refs)
#- src/filters/pandoc-quotes.lua

# add some input files
input-files:
- ./src/_base.md
- ./src/abstract.md
- ./src/01_intro.md
- ./src/02_chapter_1.md
- ./src/03_conclusion.md
- ./src/04_acknowledgment.md
- ./src/05_references.md
- ./src/appendix.md
#- ./src/list_of_tables.md
#- ./src/list_of_figures.md
#- ./src/list_of_listings.md
#- ./src/appendix.md

# styling
css:
- ./config/html/css/main.css
- ./config/html/css/print.css
- ./config/html/css/font_tufte.css
#- ./config/html/css/font_poppins.css
#- ./config/html/css/font_merriweather.css

# output
log-file: build/html.log
output-file: build/index.html
to: html
toc-depth: 3
listings: true
2 changes: 1 addition & 1 deletion config/html/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
*/

/* the following works, or set in layout.yaml */
/* the following works, or set in config.yaml */
/*@import url("./font_tufte.css");*/

:root {
Expand Down
2 changes: 1 addition & 1 deletion config/html/templates/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
$endfor$
<!-- style -->
<!-- relative to template path (in ./root/templates folder) -->
<!-- see layout.yaml files (can also include here) -->
<!-- see config.yaml files (can also include here) -->
<!-- The default pandoc style under the <style> tag can be-->
$for(css)$
<link rel="stylesheet" href="$css$" />
Expand Down
16 changes: 3 additions & 13 deletions config/pdf/layout.yaml → config/pdf/config.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
# ================================
# PDF config and layout
# PDF config (can overwrite main config.yaml)
#
# Notes:
# - <https://pandoc.org/MANUAL.html#general-writer-options-1>
# - <https://pandoc.org/MANUAL.html#options-affecting-specific-writers>
# ================================

filters:
- pandoc-crossref
- src/filters/multiple-bibliographies.lua # comment out for quick build (no refs)
#- src/filters/pandoc-quotes.lua
# add some input files
input-files:
- ./src/_base.md
- ./src/abstract.md
- ./src/01_intro.md
- ./src/02_chapter_1.md
- ./src/03_conclusion.md
- ./src/04_acknowledgment.md
- ./src/05_references.md
- ./src/appendix.md

log-file: build/pdf.log
output-file: build/index.pdf
pdf-engine: xelatex # wkhtmltopdf, weasyprint, prince, pdflatex, lualatex, xelatex, latexmk, pdfroff, context, tectonic
to: pdf
toc-depth: 3
toc: false
listings: true
17 changes: 17 additions & 0 deletions config/tex/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ================================
# Tex config (can overwrite main config.yaml)
#
# Notes:
# - <https://pandoc.org/MANUAL.html#general-writer-options-1>
# - <https://pandoc.org/MANUAL.html#options-affecting-specific-writers>
# ================================
#
# add some input files
input-files:
- ./src/appendix.md

log-file: build/tex.log
output-file: build/index.tex
to: latex

toc-depth: 3
33 changes: 0 additions & 33 deletions config/tex/layout.yaml

This file was deleted.

10 changes: 5 additions & 5 deletions utils/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ FMT_OUT="<fmt>"
FMT_OUT_DEFAULT="html"
FMT_TMPL="${FMT_OUT}"
CONFIG_MAIN="./config/config.yaml"
CONFIG_FORMAT="./config/${FMT_OUT}/layout.yaml"
CONFIG_FORMAT="./config/${FMT_OUT}/config.yaml"
TEMPLATE="./config/${FMT_OUT}/templates/default.${FMT_TMPL}"
TEMPLATE_IN=""
CONFIG_FORMAT_IN=""
Expand All @@ -53,7 +53,7 @@ Options:
needs to match the output in '${CONFIG_FORMAT}'
-t|--template FILE template file (default: '${TEMPLATE}')
note: for the pdf format, use a .tex template
-l|--layout FILE layout + config (default: '${CONFIG_FORMAT}')
-c|--config FILE config (default: '${CONFIG_FORMAT}')
-ns|--no-serve no HTTP server
EOF
)
Expand Down Expand Up @@ -81,7 +81,7 @@ while [ -n "$1" ]; do
-t|--template) TEMPLATE_IN=$2
shift;
;;
-l|--layout) CONFIG_FORMAT_IN=$2
-c|--config) CONFIG_FORMAT_IN=$2
shift;
;;
-h|--help|--usage)
Expand Down Expand Up @@ -110,7 +110,7 @@ done
config(){
fmt_out=$1
# update configs
CONFIG_FORMAT="./config/${fmt_out}/layout.yaml"
CONFIG_FORMAT="./config/${fmt_out}/config.yaml"

# make latex stuff available
#TEXDIR=$( kpsewhich -var-value=TEXMFLOCAL )
Expand All @@ -133,7 +133,7 @@ config(){
fi

if [ -z "${CONFIG_FORMAT_IN}" ];then
CONFIG_FORMAT="./config/${fmt_out}/layout.yaml"
CONFIG_FORMAT="./config/${fmt_out}/config.yaml"
else
CONFIG_FORMAT="${CONFIG_FORMAT_IN}"
fi
Expand Down

0 comments on commit 7d86327

Please sign in to comment.