Skip to content

Lua function pandoc.read seems to ignore ReaderOptions.extensions #10593

Open
@rnwst

Description

@rnwst

Explain the problem.
When running the following Lua filter (test.lua)

function Pandoc(doc)
    local reader_options = pandoc.ReaderOptions(PANDOC_READER_OPTIONS)
    -- remove 'auto_identifiers' extension
    for i, v in ipairs(reader_options.extensions) do
        if v == 'auto_identifiers' then
            table.remove(reader_options.extensions, i)
        end
    end
    local doc = pandoc.read('# Header {.class key=val}', 'markdown', reader_options)
    io.stderr:write(pandoc.write(doc, 'markdown'))
end

with the following command (where test.md is any document)

pandoc --from=markdown --to=native test.md --lua-filter=test.lua > /dev/null

, the following text is printed to stderr:

# Header {#header .class key="val"}

It seems as if removing the auto_identifiers extension from reader_options.extensions has no effect and the header is automatically assigned an Id regardless. The expected stderr output is

# Header {.class key="val"}

Pandoc version?
pandoc 3.6.2
Features: +server +lua
Scripting engine: Lua 5.4

OS: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions