Skip to content

Commit

Permalink
Merge pull request #3 from mps9506/v1.0.1
Browse files Browse the repository at this point in the history
V1.0.1
  • Loading branch information
mps9506 authored Nov 2, 2023
2 parents 88f5868 + 7abe7d2 commit 4014c96
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 82 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/check-extension.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
workflow_dispatch:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

name: quarto-ext-chk

permissions:
contents: write

jobs:
quarto-ext-chk:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:

- uses: actions/checkout@v3

- uses: quarto-dev/quarto-actions/setup@v2
with:
tinytex: true

- run: |
quarto check
- name: Render Quarto Project
uses: quarto-dev/quarto-actions/render@v2
with:
path: template.qmd



- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: .
branch: gh-pages

8 changes: 8 additions & 0 deletions .quartoignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
examples/
LICENSE
DESCRIPTION
.github/
.gitignore
screenshots/
quarto-cv.rproj
template.pdf
37 changes: 26 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Quarto-cv Format

[![quarto-ext-chk](https://github.com/mps9506/quarto-cv/actions/workflows/check-extension.yaml/badge.svg)](https://github.com/mps9506/quarto-cv/actions/workflows/check-extension.yaml)

A Quarto template for generating a CV in pdf format. The template is based entirely
on [Steven Miller's R Markdown templates](https://github.com/svmiller/stevetemplates).

Expand Down Expand Up @@ -59,23 +61,28 @@ The template includes a lua filter to easily incorporate multiple bibliographies
In the document yaml header simply point to your `.bib` files and provide a unique name:

```yaml
bibliography_peer: peer.bib
bibliography_reports: reports.bib
bibliography_books: books.bib
bibliography_software: software.bib
bibliography:
peer: peer.bib
reports: reports.bib
books: books.bib
software: software.bib
validate-yaml: false
```

Then create different bibliographies for each one:
Note, that the `validate-yaml` key must be false in quarto because it expects
a character value when it vaildates the yaml header.

Now create different bibliographies for each one:

```
# Journal Articles
::: {#refs_peer}
::: {#refs-peer}
:::
# Software
::: {#refs_software}
::: {#refs-software}
:::
```

Expand All @@ -91,15 +98,23 @@ Here is the source code for a minimal sample document: [template.qmd](template.q
The template is based entirely
on [Steven Miller's R Markdown templates](https://github.com/svmiller/stevetemplates)
licensed under GPL-2. A copy of the pandoc
[multiple-bibliographies](https://github.com/pandoc/lua-filters) lua filter
[`multibib`](https://github.com/pandoc-ext/multibib) lua filter
licensed under MIT is included as part of this template.

# Release Notes

# v1.0.9999 (dev)
## v1.0.2 (not released)

- Update tex template for changes to citeproc in pandoc >=3.1.8 (Fixes [#4](https://github.com/mps9506/quarto-cv/issues/4)).

## v1.0.1

- Properly embed [pandoc-ext `multibib`](https://github.com/pandoc-ext/multibib) extension (Fixes [#2](https://github.com/mps9506/quarto-cv/issues/2)).
- Add CI test for pull requests on main.
- Add .quartoignore to avoid copying extra files.
- Fix README.md install instructions (@anielsen001) ([#1](https://github.com/mps9506/quarto-cv/pull/1)).

- Fix README.md install instructions (@anielsen001) [#1](https://github.com/mps9506/quarto-cv/pull/1)

# v1.0.0
## v1.0.0

- Initial Release
9 changes: 5 additions & 4 deletions _extensions/quarto-cv/_extension.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
title: quarto-cv
author: Michael Schramm
version: 1.0.0
quarto-required: ">=1.2.0"
version: 1.0.1
quarto-required: ">=1.3.450"
contributes:
formats:
pdf:
filters:
- multibib
pdf-engine: lualatex
toc: false
linkcolor: blue
urlcolor: blue
geometry: margin=1in
filters:
- "multiple-bibliographies.lua"
biblio-config: false
include-in-header: header.tex
template: quarto-cv.tex
template-partials:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: multibib
author: Albert Krewinkel
version: 1.0.0
contributes:
filters:
- multibib.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
--[[
multiple-bibliographies – create multiple bibliographies
Copyright © 2018-2021 Albert Krewinkel
multibib – create multiple bibliographies
Copyright © 2018-2022 Albert Krewinkel
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
Expand All @@ -12,71 +15,61 @@ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
]]
PANDOC_VERSION:must_be_at_least '2.11'

local List = require 'pandoc.List'
local utils = require 'pandoc.utils'
local stringify = utils.stringify
local run_json_filter = utils.run_json_filter

--- get the type of meta object
local metatype = pandoc.utils.type or
function (v)
local metatag = type(v) == 'table' and v.t and v.t:gsub('^Meta', '')
return metatag and metatag ~= 'Map' and metatag or type(v)
end

--- Collection of all cites in the document
local all_cites = {}
--- Document meta value
local doc_meta = pandoc.Meta{}

--- Div used by pandoc-citeproc to insert the bibliography.
--- Div used by citeproc to insert the bibliography.
local refs_div = pandoc.Div({}, pandoc.Attr('refs'))

-- Div filled by citeproc with properties set according to
-- the output format and the attributes of cs:bibliography
local refs_div_with_properties

local supports_quiet_flag = (function ()
-- We use pandoc instead of pandoc-citeproc starting with pandoc 2.11
if PANDOC_VERSION >= "2.11" then
return true
end
local version = pandoc.pipe('pandoc-citeproc', {'--version'}, '')
local major, minor, patch = version:match 'pandoc%-citeproc (%d+)%.(%d+)%.?(%d*)'
major, minor, patch = tonumber(major), tonumber(minor), tonumber(patch)
return major > 0
or minor > 14
or (minor == 14 and patch >= 5)
end)()

local function run_citeproc(doc, quiet)
if PANDOC_VERSION >= "2.11" then
return run_json_filter(
doc,
'pandoc',
{'--from=json', '--to=json', '--citeproc', quiet and '--quiet' or nil}
)
else
-- doc = run_json_filter(doc, 'pandoc-citeproc')
return run_json_filter(
doc,
'pandoc-citeproc',
{FORMAT, (quiet and supports_quiet_flag) and '-q' or nil}
)
--- Run citeproc on a pandoc document
local citeproc
if utils.citeproc then
-- Built-in Lua function
citeproc = utils.citeproc
else
-- Use pandoc as a citeproc processor
citeproc = function (doc)
local opts = {'--from=json', '--to=json', '--citeproc', '--quiet'}
return run_json_filter(doc, 'pandoc', opts)
end
end


--- Resolve citations in the document by combining all bibliographies
-- before running pandoc-citeproc on the full document.
local function resolve_doc_citations (doc)
-- combine all bibliographies
local meta = doc.meta
local orig_bib = meta.bibliography
meta.bibliography = pandoc.MetaList{orig_bib}
for name, value in pairs(meta) do
if name:match('^bibliography_') then
table.insert(meta.bibliography, value)
local bibconf = meta.bibliography
meta.bibliography = pandoc.MetaList{}
if metatype(bibconf) == 'table' then
for _, value in pairs(bibconf) do
table.insert(meta.bibliography, stringify(value))
end
end
-- add dummy div to catch the created bibliography
-- add refs div to catch the created bibliography
table.insert(doc.blocks, refs_div)
-- resolve all citations
-- doc = run_json_filter(doc, 'pandoc-citeproc')
doc = run_citeproc(doc)
doc = citeproc(doc)
-- remove catch-all bibliography and keep it for future use
refs_div_with_properties = table.remove(doc.blocks)
-- restore bibliography to original value
Expand Down Expand Up @@ -119,19 +112,19 @@ end
-- ID starts with "refs", followed by nothing but underscores and
-- alphanumeric characters.
local function create_topic_bibliography (div)
local name = div.identifier:match('^refs([_%w]*)$')
local bibfile = name and doc_meta['bibliography' .. name]
local name = div.identifier:match('^refs[-_]?([-_%w]*)$')
local bibfile = name and (doc_meta.bibliography or {})[name]
if not bibfile then
return nil
end
local tmp_blocks = {pandoc.Para(all_cites), refs_div}
local tmp_meta = meta_for_pandoc_citeproc(bibfile)
local tmp_doc = pandoc.Pandoc(tmp_blocks, tmp_meta)
local res = run_citeproc(tmp_doc, true) -- try to be quiet
local res = citeproc(tmp_doc)
-- First block of the result contains the dummy paragraph, second is
-- the refs Div filled by pandoc-citeproc.
-- the refs Div filled by citeproc.
div.content = res.blocks[2].content
-- Set the classes and attributes as pandoc-citeproc did it on refs_div
-- Set the classes and attributes as citeproc did it on refs_div
div.classes = remove_duplicates(refs_div_with_properties.classes)
div.attributes = refs_div_with_properties.attributes
return div
Expand Down
38 changes: 29 additions & 9 deletions _extensions/quarto-cv/partials/biblio.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,34 @@
$-- If your CLS file already define a style file, then set `biblio-config: false` to deactivate the main template configuration, otherwise there could be a conflict.
$--

% $if(natbib)$
% \usepackage{natbib}
% \bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
% $endif$
$if(natbib)$
$if(bibliography)$
$if(biblio-title)$
$if(has-chapters)$
\renewcommand\bibname{$biblio-title$}
$else$
\renewcommand\refname{$biblio-title$}
$endif$
$endif$
$if(beamer)$
\begin{frame}[allowframebreaks]{$biblio-title$}
\bibliographytrue
$endif$
\bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}
$if(beamer)$
\end{frame}
$endif$

$endif$
$endif$
$if(biblatex)$
\usepackage$if(biblio-style)$[style=$biblio-style$]$endif${biblatex}
$if(biblatexoptions)$\ExecuteBibliographyOptions{$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$}$endif$
$for(bibliography)$
\addbibresource{$bibliography$}
$endfor$
$if(beamer)$
\begin{frame}[allowframebreaks]{$biblio-title$}
\bibliographytrue
\printbibliography[heading=none]
\end{frame}
$else$
\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
$endif$

$endif$
18 changes: 8 additions & 10 deletions _extensions/quarto-cv/partials/doc-class.tex
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,24 @@
\fi
\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
% this is for pandoc <3.1.8
$if(csl-refs)$
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
% For Pandoc 2.8 to 2.11
\newenvironment{cslreferences}%
{$if(csl-hanging-indent)$\setlength{\parindent}{0pt}%
\everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces$endif$}%
{\par}
% For pandoc 2.11+ using new --citeproc
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\newlength{\cslentryspacingunit} % times entry-spacing
\setlength{\cslentryspacingunit}{\parskip}
\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing
{% don't indent paragraphs
\setlength{\parindent}{0pt}
% turn on hanging indent if param 1 is 1
\ifodd #1 \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces\fi
% set entry spacing
\ifnum #2 > 0
\setlength{\parskip}{#2\baselineskip}
\ifodd #1
\let\oldpar\par
\def\par{\hangindent=\cslhangindent\oldpar}
\fi
% set entry spacing
\setlength{\parskip}{#2\cslentryspacingunit}
}%
{}
\usepackage{calc}
Expand Down
Binary file removed template.pdf
Binary file not shown.
Loading

0 comments on commit 4014c96

Please sign in to comment.