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

Pandoc build configuration for preview and export does not support the whole name of a file with extension #25

Open gusbemacbe opened 8 months ago

gusbemacbe commented 8 months ago

Good morning!

I wrote a build configuration to preview the LICENSE.md with a default HTML file template to suppress the title, the author, the date, etc. on the preview. But it does not support the whole name of a file with extension, for example:

"codebraid.preview.pandoc.build": 
  {
    "LICENSE.md": 
    {
      "reader": "markdown",
      "preview": 
      {
        "html": 
        {
          "defaults": {},
          "options": 
          [
            "--template assets/templates/licence.html"
          ]
        }
      },
      "export": {}
    }
  }
gpoore commented 8 months ago

The build configuration only supports file extensions.

If you want to customize things for a specific file, you can use the _codebraid_preview.yaml config file.

gusbemacbe commented 8 months ago

The build configuration only supports file extensions.

If you want to customize things for a specific file, you can use the _codebraid_preview.yaml config file.

I want to set a universal _codebraid_preview.yaml for all Markdown files, but not for the licence file. Is it possible?

If not possible, I have to link symbolically LICENSE.md to LICENSE.lmd, and set the file extension *.lmd for the build configuration. I know that it is silly.

gpoore commented 7 months ago

There isn't a way to use _codebraid_preview.yaml for all Markdown files in a directory except for one or more that are excluded, unless you use input-files: to specify that several files are all part of a single document so that other files are ignored. This is all following standard Pandoc usage for defaults files. At this point, I'm trying to avoid adding any features for _codebraid_preview.yaml that go beyond Pandoc, to minimize complexity.

There are a few possibilities for the case you are describing. The simplest would be to have one _codebraid_preview.yaml per directory, so perhaps put the license in a separate directory. Depending on what you want to do, it might also be possible to have a defaults file in your user data directory that is used for all Markdown files (see https://pandoc.org/MANUAL.html#defaults-files), and then have _codebraid_preview.yaml only apply to the license file by setting input-files:.

A final possibility would be to use a Lua filter that determines whether the license file is being built, and if so modifies the template. There should be a way to customize WriterOptions (https://pandoc.org/lua-filters.html#type-writeroptions) based on input filename.