Skip to content

section-bibliographies.level and section-bibliographies.minlevel not working as expected #23

@tomicapretto

Description

@tomicapretto

I have the following .qmd file:

---
title: Bibliography
filters:
    - section-bibliographies
citeproc: false
bibliography: ../citas/references.bib
section-bibliographies:
    level: 2
    minlevel: 2
---

## Main

<div style="visibility: hidden; height: 0;">
@CasellaBerger2024
@Hastie2009
@Gelman2013
</div>

## Optional

<div style="visibility: hidden; height: 0;">
@Jaynes2003
@Rudin1976
</div>

The current version of the extension doesn't work as intended, I get no bibliography.
If I use level 1 headers then it works, but I want level 2 headers.

After inspecting the Lua code and adding some logging, I figured out the filter was reaching the metadata successfully, but the conversion to numbers in lines 206 and 209 were not working as expected:

opts.level = tonumber(opts.level)
or tonumber(meta['section-bibs-level'])
or 1
opts.minlevel = tonumber(opts.minlevel)
or 1

As a result, opts.level and opts.minlevel were always set to 1.

To fix it locally, I applied the following change:

@@ -203,10 +203,10 @@ local function get_options (meta)
   opts.bibliography = opts.bibliography
     or meta['section-bibs-bibliography']
     or meta['bibliography']
-  opts.level = tonumber(opts.level)
+  opts.level = tonumber(utils.stringify(opts.level))
     or tonumber(meta['section-bibs-level'])
     or 1
-  opts.minlevel = tonumber(opts.minlevel)
+  opts.minlevel = tonumber(utils.stringify(opts.minlevel))
     or 1
   opts.references = opts.references
     or meta['references']

Do you think this is a satisfactory fix, if this was effectively a bug? Happy to submit a PR, although I'm not very familiar with the testing suite.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions