Skip to content

incorrect path when --extract-media is used in conjunction with #53

Open

Description

@ickc

When --extract-media is used in conjunction with this filter, the resulting path with point to only media/... ignoring the specified parent directory.

A semi-reproducible example would be to create a docx file with an image in a table (TODO: create an example file here), and then run

# makefile syntax
%.md: %.docx
    pandoc -s -o $@ $< --extract-media=$(@D)/$* --id-prefix=$* -F pantable2csv

P.S. It might as well be an upstream bug.

Activity

  1. ickc commented on Oct 6, 2026

    @ickc
    OwnerAuthor

    Reproduced with pandoc 3.12 and pantable 0.15: with --extract-media=out/doc, an image in a table comes out as media/rId9.png in the CSV, while pandoc alone gives out/doc/media/rId9.png.

    The cause is pandoc's order: a filter sees media/rId9.png, and pandoc rewrites image paths to the --extract-media directory only after the filters have run. By then pantable2csv has turned the table, image included, into CSV text, which pandoc does not touch. A JSON filter is not told the --extract-media directory, so pantable cannot fix the path itself.

    Workaround: extract the media in a first pandoc run and filter in a second, so the paths are rewritten before pantable2csv sees them:

    pandoc doc.docx --extract-media=out/doc -t json | pandoc -f json -s -F pantable2csv -o out/doc.md
  2. ickc commented on Oct 6, 2026

    @ickc
    OwnerAuthor

    Tracked in #10: the root problem is how a filter can know what pandoc knows (here, the --extract-media directory). A CLI, or a filter interface that receives pandoc's options, is the longer-term fix; the two-step workaround above is the way until then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions