Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gusbemacbe opened this issue Mar 1, 2024 · 3 comments

Comments

@gusbemacbe
Copy link

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
Copy link
Owner

gpoore commented Mar 1, 2024

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
Copy link
Author

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
Copy link
Owner

gpoore commented Mar 21, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants