Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/changelog-1.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- ([#13046](https://github.com/quarto-dev/quarto-cli/issues/13046)): Use new url for multiplex socket.io server <https://multiplex.up.railway.app/> as default for `format: revealjs` and `revealjs.multiplex: true`.
- ([#13506](https://github.com/quarto-dev/quarto-cli/issues/13506)): Fix navbar active state detection when sidebar has no logo configured. Prevents empty logo links from interfering with navigation highlighting.
- ([#13633](https://github.com/quarto-dev/quarto-cli/issues/13633)): Fix detection and auto-installation of babel language packages from newer error format that doesn't explicitly mention `.ldf` filename.

## In previous releases

Expand Down
8 changes: 7 additions & 1 deletion src/command/render/latexmk/parse-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export function findMissingHyphenationFiles(logText: string) {
const babelWarningRegex = /^Package babel Warning:/m;
const hasWarning = logText.match(babelWarningRegex);
if (hasWarning) {
const languageRegex = /^\(babel\).* language `(\S+)'.*$/m;
const languageRegex = /^\(babel\).* language [`'](\S+)[`'].*$/m;
const languageMatch = logText.match(languageRegex);
if (languageMatch) {
return filterLang(languageMatch[1]);
Expand Down Expand Up @@ -271,6 +271,12 @@ const packageMatchers = [
{ regex: /.*! LaTeX Error: File `([^']+)' not found.*/g },
{ regex: /.* file ['`]?([^' ]+)'? not found.*/g },
{ regex: /.*the language definition file ([^\s]*).*/g },
{
regex: /.*! Package babel Error: Unknown option [`']([^'`]+)'[.].*/g,
filter: (match: string, _text: string) => {
return `${match}.ldf`;
},
},
{ regex: /.* \\(file ([^)]+)\\): cannot open .*/g },
{ regex: /.*file `([^']+)' .*is missing.*/g },
{ regex: /.*! CTeX fontset `([^']+)' is unavailable.*/g },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
name: Elsevier Journal Format
title: ACS Journal Format
author: Charles Teague
version: 0.9.2
contributes:
format:
formats:
common:
csl: american-chemical-society.csl
shortcodes:
- fancy-text
filters:
- latex-environment
environments:
- scheme
- chart
- graph
- tocentry
- acknowledgement
- suppinfo
commands:
- ce
html: default
pdf:
template-partials: ["doc-class.tex", "title.tex", "print-affiliation.tex"]
cite-method: natbib
biblio-config: false
format-resources:
- achemso.bst
template-partials:
- "doc-class.tex"
- "title.tex"
- "_affiliation.tex"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: Fancy Text
author: Posit Software, PBC
version: 1.1.1
quarto-required: ">=1.2.198"
contributes:
shortcodes:
- fancy-text.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
-- shortcode that provides a nicely formatted 'LaTeX' string
function latex()
if quarto.doc.is_format("pdf") then
return pandoc.RawBlock('tex', '{\\LaTeX}')
elseif quarto.doc.is_format("html") then
return pandoc.Math('InlineMath', "\\LaTeX")
else
return pandoc.Span('LaTeX')
end
end

function tex()
if quarto.doc.is_format("pdf") then
return pandoc.RawBlock('tex', '{\\TeX}')
elseif quarto.doc.is_format("html") then
return pandoc.Math('InlineMath', "\\TeX")
else
return pandoc.Span('TeX')
end
end

-- shortcode that provides a nicely formatted 'bibtex' string
function bibtex()
if quarto.doc.is_format("pdf") then
return pandoc.RawBlock('tex', '\\textsc{Bib}{\\TeX}')
elseif quarto.doc.is_format("html") then
return pandoc.RawBlock('html', '<span style="font-variant: small-caps;">Bib</span><span style="letter-spacing:-2px;">T</span><sub style="font-size: inherit; letter-spacing:-1px;">E</sub>X')
else
return pandoc.Span('BibTeX')
end
end

function ldots()
if quarto.doc.is_format("pdf") then
return pandoc.RawBlock('tex', '\\ldots')
elseif quarto.doc.is_format("html") then
return pandoc.RawBlock('html', '&#8230;')
else
return "..."
end
end

function vdots()
if quarto.doc.is_format("pdf") then
return pandoc.Math('InlineMath', "\\vdots")
elseif quarto.doc.is_format("html") then
return pandoc.RawBlock('html', '&#8942;')
else
return "..."
end
end

function ddots()
if quarto.doc.is_format("pdf") then
return pandoc.Math('InlineMath', "\\ddots")
elseif quarto.doc.is_format("html") then
return pandoc.RawBlock('html', '&#8945;')
else
return "..."
end
end

function pct()
local pct
if quarto.doc.is_format("pdf") then
return pandoc.Math('InlineMath', '\\%')
else
return pandoc.Str("%")
end
end

function R2()
if quarto.doc.is_format("pdf") then
return pandoc.Math('InlineMath', "R^2")
else
return {pandoc.Str("R"), pandoc.Superscript("2")}
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: LaTeX Environment
author: Posit Software, PBC
version: 1.2.1
quarto-required: ">=1.3"
contributes:
filters:
- latex-environment.lua
format:
pdf: default
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
-- environment.lua
-- Copyright (C) 2020 by RStudio, PBC

local classEnvironments = pandoc.MetaMap({})
local classCommands = pandoc.MetaMap({})

-- helper that identifies arrays
local function tisarray(t)
local i = 0
for _ in pairs(t) do
i = i + 1
if t[i] == nil then return false end
end
return true
end

-- reads the environments
local function readEnvironments(meta)
local env = meta['environments']
if env ~= nil then
if tisarray(env) then
-- read an array of strings
for i, v in ipairs(env) do
local value = pandoc.utils.stringify(v)
classEnvironments[value] = value
end
else
-- read key value pairs
for k, v in pairs(env) do
local key = pandoc.utils.stringify(k)
local value = pandoc.utils.stringify(v)
classEnvironments[key] = value
end
end
end
end

local function readCommands(meta)
local env = meta['commands']
if env ~= nil then
if tisarray(env) then
-- read an array of strings
for i, v in ipairs(env) do
local value = pandoc.utils.stringify(v)
classCommands[value] = value
end
else
-- read key value pairs
for k, v in pairs(env) do
local key = pandoc.utils.stringify(k)
local value = pandoc.utils.stringify(v)
classCommands[key] = value
end
end
end
end

local function readEnvsAndCommands(meta)
readEnvironments(meta)
readCommands(meta)
end

-- use the environments from metadata to
-- emit a custom environment for latex
local function writeEnvironments(divEl)
if quarto.doc.is_format("latex") then
for k, v in pairs(classEnvironments) do
if divEl.attr.classes:includes(k) then
-- process this into a latex environment
local beginEnv = '\\begin' .. '{' .. v .. '}'
local endEnv = '\n\\end{' .. v .. '}'

-- check if custom options or arguments are present
-- and add them to the environment accordingly
local opts = divEl.attr.attributes['options']
if opts then
beginEnv = beginEnv .. '[' .. opts .. ']'
end

local args = divEl.attr.attributes['arguments']
if args then
beginEnv = beginEnv .. '{' .. args .. '}'
end

-- if the first and last div blocks are paragraphs then we can
-- bring the environment begin/end closer to the content
if #divEl.content > 0 and divEl.content[1].t == "Para" and divEl.content[#divEl.content].t == "Para" then
table.insert(divEl.content[1].content, 1, pandoc.RawInline('tex', beginEnv .. "\n"))
table.insert(divEl.content[#divEl.content].content, pandoc.RawInline('tex', "\n" .. endEnv))
else
table.insert(divEl.content, 1, pandoc.RawBlock('tex', beginEnv))
table.insert(divEl.content, pandoc.RawBlock('tex', endEnv))
end
return divEl
end
end
end
end

local function buildCommandArgs(opts, format)
local function wrap(o)
return string.format(format, o)
end
local t = pandoc.List()
for str in string.gmatch(opts, "([^"..",".."]+)") do
t:insert(str)
end
return table.concat(t:map(wrap), "")
end

-- use the environments from metadata to
-- emit a custom environment for latex
local function writeCommands(spanEl)
if quarto.doc.is_format("latex") then
for k, v in pairs(classCommands) do
if spanEl.attr.classes:includes(k) then

-- resolve the begin command
local beginCommand = '\\' .. pandoc.utils.stringify(v)
local opts = spanEl.attr.attributes['options']
local args = spanEl.attr.attributes['arguments']
if opts then
beginCommand = beginCommand .. buildCommandArgs(opts, "[%s]")
end
if args then
beginCommand = beginCommand .. buildCommandArgs(args, "{%s}")
end

local beginCommandRaw = pandoc.RawInline('latex', beginCommand .. '{')

-- the end command
local endCommandRaw = pandoc.RawInline('latex', '}')

-- attach the raw inlines to the span contents
local result = spanEl.content
table.insert(result, 1, beginCommandRaw)
table.insert(result, endCommandRaw)

return result
end
end
end
end

-- Run in two passes so we process metadata
-- and then process the divs
return {
{ Meta = readEnvsAndCommands },
{ Div = writeEnvironments, Span = writeCommands }
}
Loading
Loading