Skip to content

Commit

Permalink
major update
Browse files Browse the repository at this point in the history
  • Loading branch information
assuncaolfi committed Dec 5, 2023
1 parent 7734135 commit 3665f00
Show file tree
Hide file tree
Showing 73 changed files with 37,418 additions and 770 deletions.
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cpython@3.11.3
22 changes: 22 additions & 0 deletions _extensions/mps9506/quarto-cv/_extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
title: quarto-cv
author: Michael Schramm
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
biblio-config: false
include-in-header: header.tex
template: quarto-cv.tex
template-partials:
- "partials/doc-class.tex"
- "partials/biblio.tex"


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
@@ -0,0 +1,141 @@
--[[
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
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
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 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

--- 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 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 refs div to catch the created bibliography
table.insert(doc.blocks, refs_div)
-- resolve all citations
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
doc.meta.bibliography = orig_bib
return doc
end

--- Explicitly create a new meta object with all fields relevant for
--- pandoc-citeproc.
local function meta_for_pandoc_citeproc (bibliography)
-- We could just indiscriminately copy all meta fields, but let's be
-- explicit about what's important.
local fields = {
'bibliography', 'references', 'csl', 'citation-style',
'link-citations', 'citation-abbreviations', 'lang',
'suppress-bibliography', 'reference-section-title',
'notes-after-punctuation', 'nocite'
}
local new_meta = pandoc.Meta{}
for _, field in ipairs(fields) do
new_meta[field] = doc_meta[field]
end
new_meta.bibliography = bibliography
return new_meta
end

local function remove_duplicates(classes)
local seen = {}
return classes:filter(function(x)
if seen[x] then
return false
else
seen[x] = true
return true
end
end)
end

--- Create a bibliography for a given topic. This acts on all divs whose
-- 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 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 = citeproc(tmp_doc)
-- First block of the result contains the dummy paragraph, second is
-- the refs Div filled by citeproc.
div.content = res.blocks[2].content
-- 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
end

return {
{
-- Collect all citations and the doc's Meta value for other filters.
Cite = function (c) all_cites[#all_cites + 1] = c end,
Meta = function (m) doc_meta = m end,
},
{ Pandoc = resolve_doc_citations },
{ Div = create_topic_bibliography },
}
1 change: 1 addition & 0 deletions _extensions/mps9506/quarto-cv/header.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
% TODO: Add custom LaTeX header directives here
36 changes: 36 additions & 0 deletions _extensions/mps9506/quarto-cv/partials/biblio.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
$-- Necessary content to creates the bibliography.
$-- Bibliography style is defined in the main template. Use `biblio-style` YAML key to customize the .bst file for natbib.
$-- 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)$
$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)$
$if(beamer)$
\begin{frame}[allowframebreaks]{$biblio-title$}
\bibliographytrue
\printbibliography[heading=none]
\end{frame}
$else$
\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
$endif$

$endif$
120 changes: 120 additions & 0 deletions _extensions/mps9506/quarto-cv/partials/doc-class.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
$-- Contains the document class declaration and options.
$-- By default we provide the identical document class that Pandoc provides, implementing many features.
$-- If provide this partial in your format, you will need to either implement support for the usaul document class options in addition to other one
$-- or be aware that pandoc supported options (e.g. font-size, paper-size, classoption, etc) will not be supported in your format.
$--
\documentclass[
$if(fontsize)$
$fontsize$,
$endif$
$if(lang)$
$babel-lang$,
$endif$
$if(papersize)$
$papersize$paper,
$endif$
$for(classoption)$
$classoption$$sep$,$endfor$
]
{$documentclass$}
$if(fontfamily)$
\usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$}
$else$
\usepackage{ebgaramond-maths}
%\usepackage[T1]{fontenc}
$endif$
$if(linestretch)$
\usepackage{setspace}
\setstretch{$linestretch$}
$endif$
%\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc}
\usepackage[utf8]{inputenc}
$if(euro)$
\usepackage{eurosym}
$endif$
\else % if luatex or xelatex
\ifxetex
\usepackage{mathspec}
\else
\usepackage{fontspec}
\fi
\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
% this is for pandoc <3.1.8
$if(csl-refs)$
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
\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
\let\oldpar\par
\def\par{\hangindent=\cslhangindent\oldpar}
\fi
% set entry spacing
\setlength{\parskip}{#2\cslentryspacingunit}
}%
{}
\usepackage{calc}
\newcommand{\CSLBlock}[1]{#1\hfill\break}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break}
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
$endif$
$if(euro)$
\newcommand{\euro}{€}
$endif$
$if(mainfont)$
\setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$}
$endif$
$if(sansfont)$
\setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$}
$endif$
$if(monofont)$
\setmonofont[Mapping=tex-ansi$if(monofontoptions)$,$for(monofontoptions)$$monofontoptions$$sep$,$endfor$$endif$]{$monofont$}
$endif$
$if(mathfont)$
\setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
$endif$
$if(CJKmainfont)$
\usepackage{xeCJK}
\setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}
$endif$
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
$if(geometry)$
\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
$endif$
$if(lang)$
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}
$if(babel-newcommands)$
$babel-newcommands$
$endif$
\else
\usepackage{polyglossia}
\setmainlanguage[$polyglossia-lang.options$]{$polyglossia-lang.name$}
$for(polyglossia-otherlangs)$
\setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$}
$endfor$
\fi
$endif$
Loading

0 comments on commit 3665f00

Please sign in to comment.