Skip to content

Have --self-contained use alt text when images are missing instead of failing #7904

@lucalenardi

Description

@lucalenardi

Explain the problem.

Not sure if this is actually a bug or an expected behaviour, so sorry if this is not the right place to report.

Starting from a simple test.md file, with a markdown command such as ![my image](./myimage.png)

If the image exists, everything is ok, but if the image does not exist, I have the following behaviours:

  1. with latex output: pandoc returns a warning message on the command line regarding the missing image and replaces the image with the alternative text "my image"
  2. with html output and --self-contained option: pandoc returns an missing file error: File ./myimage.png not found in resource path and exits without completing the process using the alternative text (which is the default for html).

The same also happens with raw html tags: <img> and <embded> trying to embed a pdf file in the html.

It seems to be related to the --self-contained option, as removing it actually populate the src attribute in the html tag ignoring the file existence.

It may be useful to have pandoc generates the final output with alternative texts – or maybe just completes the generation of the output file with warnings – in contexts where an automation runs a script that involves pandoc and not all assets are already available (es. some appendix as pdf, or some images).

Pandoc version?

pandoc 2.17.1.1 on Docker image pandoc/latex.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions