Closed benmarwick closed 2 years ago
Hi, and thanks for using Quarto!
This is our fault. It happens because the field institute
actually has a schema associated with it because of requirements of the html
and beamer
classes. Those formats expect institute
to be a string.
As we describe in #369, our validation infrastructure currently doesn't know to ignore errors stemming from a format that's not being used by the current document.
I added a workaround for the validator not to complain in this case in 89292de3b, and @dragonstyle is working on the remainder of the fix right at this moment.
Brilliant, thanks so much for your quick reply, that workaround has those filters working as expected, fantastic!
When I try to render @benmarwick's second code block, I get the following error:
Error running filter ../../pandoc/filters/scholarly-metadata.lua:
../../pandoc/filters/scholarly-metadata.lua:95: not a named object: List: 0x7fe1ab857850
stack traceback:
../../pandoc/filters/scholarly-metadata.lua:95: in function 'to_named_object'
[C]: in function 'pandoc.List.map'
../../pandoc/filters/scholarly-metadata.lua:144: in upvalue 'canonicalize'
../../pandoc/filters/scholarly-metadata.lua:181: in function <../../pandoc/filters/scholarly-metadata.lua:180>
Using pandoc 2.9.2.1, quarto 0.9.415, vscode 1.67.1 with quarto extension v1.20.1.
Works with Rmd.
Any ideas as to why I cannot get this working?
I tried again with an older Rmd that I converted to qmd.
Here is the output:
pandoc
to: latex
output-file: test.tex
standalone: true
pdf-engine: xelatex
variables:
graphics: true
tables: true
default-image-extension: pdf
filters:
- crossref
- ../../pandoc/filters/author-info-blocks.lua
- ../../pandoc/filters/scholarly-metadata.lua
- citeproc
metadata
documentclass: scrartcl
classoption:
- DIV=11
- numbers=noendperiod
papersize: letter
header-includes:
- '\KOMAoption{captions}{tableheading}'
block-headings: true
title: test
author:
- Jane A. Doe:
institute:
- a
- b
- Juan Koe:
institute: c
- Lisa Soe:
institute: d
- Thomas G. Loe:
institute:
- a
- b
institute:
- a: This Inc.
- b: 'Biom, University of Here'
- c: 'Clin, University of There'
- d: 'That, LLC'
fontsize: 11pt
link-citations: true
bibliography:
- ../../../library.bib
Error running filter ../../pandoc/filters/author-info-blocks.lua:
../../pandoc/filters/author-info-blocks.lua:100: bad argument #2 to 'concat' (table expected, got nil)
stack traceback:
../../pandoc/filters/author-info-blocks.lua:100: in function <../../pandoc/filters/author-info-blocks.lua:95>
[C]: in function 'pandoc.List.map'
../../pandoc/filters/author-info-blocks.lua:94: in upvalue 'create_affiliations_blocks'
../../pandoc/filters/author-info-blocks.lua:160: in function <../../pandoc/filters/author-info-blocks.lua:153>
edit: fixed institutes.
I think the issue is likely that you have authors referencing institute c
and d
but that those institutes are not defined in the metadata (not 100% sure, but from looking at the line of code and the yaml).
- Juan Koe:
institute: c
- Lisa Soe:
institute: d
...
institute:
- a: This Inc.
- b: 'Biom, University of Here'
- clin: 'Clin, University of There'
- lik: 'That, LLC'
I'm sorry. That was me incompletely trying to anonymize the info. In reality, all institutes are represented correctly. This file works fine when knitting the Rmd.
When I render this document:
---
title: "Testing Lua filters with Qmd"
author:
- Jane A. Doe:
institute:
- a
- b
- Juan Koe:
institute: c
- Lisa Soe:
institute: d
- Thomas G. Loe:
institute:
- a
- b
institute:
- a: This Inc.
- b: 'Biom, University of Here'
- c: 'Clin, University of There'
- d: 'That, LLC'
format: pdf
filters:
- scholarly-metadata.lua
- author-info-blocks.lua
---
Using the latest version of the filter at https://github.com/pandoc/lua-filters/blob/master/scholarly-metadata/scholarly-metadata.lua I get a document rendered without issue. Sample document w/filters attached here:
Thank you very much. That works for me as well.
I was using the latest release of lua filters from Nov 5, 2021, not the latest versions available.
Hello @cscheid , I refer to your previous comment:
As we describe in https://github.com/quarto-dev/quarto-cli/issues/369, our validation infrastructure currently doesn't know to ignore errors stemming from a format that's not being used by the current document.
I added a workaround for the validator not to complain in this case in https://github.com/quarto-dev/quarto-cli/commit/89292de3b59e15e7c6c779ca1d577a969e29bb80, and @dragonstyle is working on the remainder of the fix right at this moment.
Would it be possible to generalize this workaround on other metadatas. Presently my key abstract is not a string but a more complex object:
abstract:
- lang: fr
text_f: >-
Lorem ipsum in french.
- lang: en
text_f: >-
Lorem ipsum in english.
I get the same error :
Field "abstract" has value
- lang: fr
text_f: >-
...
The value must instead be a string.
For your information, I have created a adapted journal template for this yaml schema, and I am now trying to make it work. Thanks for your help !
Would it be possible to generalize this workaround on other metadatas.
Unfortunately that's a very hard thing to do in general. With that said, if you must disable the validation entirely, add
validate-yaml: false
to your metadata. Do note that this completely stops validation, which means errors won't be flagged at YAML loading time and might cause downstream problems. We really recommend that you use a different key instead.
One suggestion I have - could you not use the keyword abstract
and instead use some other key name (e.g. abstract-localized
or something) and then normalize the correct value into the abstract
metadata in a LUA filter based upon the active language when rendering?
Thank you for quick answers ! Yes indeed, lua filter might work, however:
I'm really enjoying Quarto and excited to shift from Rmd to Qmd in my writing and teaching. I use these Lua filters frequently: scholarly-metadata.lua and author-info-blocks.lua. When I use these with Qmd I get "Validation of YAML front matter failed".
These work great with Rmd, for example this MWE works as expected:
Here's the output:
But when I try the same filters in a Qmd document, following the docs, I get an error about invalid YAML:
Here's the output in the Render tab:
Here's my session info:
Quarto version 0.9.80 Pandoc version 2.17.1.1
RStudio 2022.02.1+461 "Prairie Trillium" Release (8aaa5d470dd82d615130dbf663ace5c7992d48e3, 2022-03-17) for macOS Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.10 Chrome/69.0.3497.128 Safari/537.36