codebraid-preview-vscode
codebraid-preview-vscode copied to clipboard
Feature request: Add option for filters in "_codebraid_preview.yaml"
I usually like to keep my reports consolidated in a single folder, with the filters also stored. The folder organization may vary for different reports, therefore I wish there was an option to specify the filters used for generating the preview.
include-code-files is one of my personal favourites when it comes to filters.
Currently, I did this for the builds using pandocomatic using the following in the document frontmatter.
---
title: 'Exp 4: Stepper motor control with systick timer'
author: Utkarsh Verma
date: \today
pandocomatic_:
pandoc:
from: markdown
to: pdf
template: ../template.tex
lua-filter:
- ../../.filters/include-code-files.lua
---
I also like the fact that pandocomatic can be configured directly inside the frontmatter. Could we have something for codebraid preview as well?
The plan is to support at least many of the features of a Pandoc defaults file in _codebraid_preview.yaml, including filters. I still have to work out some of the technical details. _codebraid_preview.yaml is using the format of a Pandoc defaults file, but it can't always be treated as an actual defaults file when previewing Markdown that has been modified since the last save.
Adding support for configuration in the frontmatter is a good idea and may actually be better in many cases. _codebraid_preview.yaml is largely intended for multi-file documents, because commonmark_x only supports YAML metadata in the first file and thus there isn't a way for individual files to specify that they are part of a larger document.
What if we have a unique key isMain in the frontmatter like this:
# main.md
_codebraid:
isMain: true
inputFiles: [1.md, 2.md]
Upon building, the files should be considered in the order [main.md, 1.md, 2.md]. For this, what codebraid will have to do is quickly read the _codebraid.isMain field of all *.md files and find the main markdown file, which has the configurations for codebraid.
Moreover, if we really need a YAML file for commonmark_x as you had suggested. We can temporarily create a yaml file(inside /tmp on Linux) which will just reflect the contents of _codebraid field in main.md.
I added basic support for filters in _codebraid_preview.yaml in v0.4.0, released a few days ago. Currently, spaces and some other special characters are not supported in filter names.
I believe I have figured out how to support all Pandoc defaults options in _codebraid_preview.yaml, but that will probably take at least a few more weeks to implement. I'm also working on a plan to support at least many of these options in the frontmatter.
With the latest release, _codebraid_preview.yaml supports essentially all Pandoc defaults options and no longer has any limitations on filter file names. Some sort of additional build configuration in either _codebraid_preview.yaml or the frontmatter will likely be added in the next release.