Need Pandoc help, html to md conversion, redundant images links

I’m using a script with pandoc to convert html files and assets to markdown. My script “works,” but I have a minor problem: when I look at the markdown note in Obsidian, it has redundant text in the links to the image files in the assets folder.

When I look at the md file in Obsidian, the is what the text looks like for links to images in assets folder:

[![](./assets/3sIcgyHnp7HfaxQy.jpeg)](./assets/3sIcgyHnp7HfaxQy.jpeg)

The proper text should be:

![](./assets/3sIcgyHnp7HfaxQy.jpeg)

So Pandoc seems to be interpreting the html structure as a link within a link, leading to the redundant output.

The code in my html files, I believe, uses a standard <a> tag with an href attribute to link the image., e.g.:

    <img class="img-hide" src="./assets/3sIcgyHnp7HfaxQy.jpeg">
</a>

Can anyone help me fix this to get rid of the redundancy?

My full script, including the pandoc line, is as follows:

# Converts html files into md files (in same location as html files)

success=true

# Use the current working directory as the root directory
root_dir="."

# Recursively traverse the directory structure, suppressing output
find "$root_dir" -name '*.html' -type f -exec sh -c 'pandoc "$1" -t gfm-raw_html --wrap=none -o "${1%.html}.md" >/dev/null 2>&1 || success=false' _ {} \;

if $success; then
    echo "Successfully ran the script."
else
    echo "Some errors occurred during the process."
fi

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.