gpoore / codebraid-preview-vscode

Preview Pandoc Markdown in VS Code, and execute code blocks and inline code with Codebraid
Other
29 stars 4 forks source link

Support for Pandoc Citations #18

Closed benrbray closed 1 year ago

benrbray commented 1 year ago

CodeBraid is great! I've started using it as my default Markdown preview within VS Code. I see that support for citations is planned in the future -- do you have any thoughts on how to accomplish this? What's the main blocker?

Depending on the complexity, I might be able to make a PR.

gpoore commented 1 year ago

The citation issue is actually in Pandoc, not Codebraid Preview. By default, the preview uses Pandoc's commonmark_x format for Markdown. This format doesn't have support for citations. But it does have the sourcepos extension, which allows mapping the input Markdown to the output, and thus enables scroll sync.

Since version 0.13.0, the preview also supports scroll sync for other formats including Pandoc's markdown format. markdown does support citations. However, since the mapping between input Markdown and output is created by Codebraid Preview separately from Pandoc's parsing, it isn't always as accurate as commonmark_x+sourcepos. If I understand correctly, the parsing algorithm Pandoc uses for markdown and some other formats doesn't track source location (or maintains minimal data), so adding sourcepos would be difficult, and Pandoc is moving more toward CommonMark-based Markdown variants going forward.

You can switch to markdown by changing the setting codebraid.preview.pandoc.build, *.md, reader.

benrbray commented 1 year ago

Thanks for the lightning-fast reply! I can now see the rendered citations after adding the following to my settings JSON:

"codebraid.preview.pandoc.build": {
  "*.md": {
    "reader": "markdown",
    "preview": {
      "html": {
        "defaults": {},
        "options": ["--citeproc"]
      }
    },
  "export": {}
}