obsidian-pandoc icon indicating copy to clipboard operation
obsidian-pandoc copied to clipboard

An unnecessary `Copy` is added to code blocks in Pandoc markdown export

Open pmagwene opened this issue 2 years ago • 3 comments

The following Obisidian markdown:

Here's a code block:
```python
print("hello world")
```

Gets converted to the following Pandoc markdown. Note the addition of the unwanted word Copy in the Pandoc code block:

Here\'s a code block:

``` {.language-python tabindex="0"}
print("hello world")
Copy
```

Also, is there a reason why the single quote character in here's is getting escaped?

pmagwene avatar Oct 22 '22 14:10 pmagwene

I am also having this issue.

lukenormile avatar Dec 09 '22 16:12 lukenormile

Any resolution to this issue?

6StringSam avatar Mar 03 '23 00:03 6StringSam

I was able to resolve this issue for myself. My markdown had the triple backtick code blocks like yours and when I used the Pandoc plugin to convert to DOCX, it generated the word "Copy" in monospace at the bottom of each code block.

  • Workaround #​1: Instead of the plugin, use the command line: pandoc SRC.md -f markdown -t docx -s -o DEST.docx --reference-doc=TEMPLATE.docx. This created the same exact output as the plugin but without the "Copy" and is my preferred workaround because it's a one-liner. There's a nice community plugin that lets you run shell commands like this within Obsidian via the command palette or a hotkey.
  • Workaround #​2: Replace the triple backticks with an HTML <pre></pre> element. This is less desirable as you're moving away from the point of markdown, but it prevents the Pandoc plugin from generating "Copy" text for the code blocks.

r-jm avatar Sep 05 '23 07:09 r-jm