mark icon indicating copy to clipboard operation
mark copied to clipboard

Global Templates Directory

Open johnathank-nuna opened this issue 2 years ago • 1 comments

Feature Request

I want to start off by thanking you for creating this project. mark is a really cool tool and I am excited to start using it to manage my team's documentation.

I am using version 8.0 installed by Homebrew. I was looking into taking advantage of the templates and it works well with a flat directory structure. When there are multiple levels to the directory structure it is a bit cumbersome make sure the the file has the Include with the correct number of ../ so that I get to the correct level.

Example directory structure:

├── docs
│   ├── index.md
└── template
    └── footer.md

In the index.md file I have <!-- Include: ../template/footer.md -->. If I were to create a docs/service directory any file at that level would need <!-- Include: ../../template/footer.md -->. I tried passing in the absolute path but if I pass -f docs/index.md from the root of the project, mark will look for the file in docs/${ABSOLUTE_PATH}. If I chdir to the docs directory and run -f index.md it drops the leading / and cannot find the file.

Is there a way to easily point to the same template file with mark regardless of which level in the directory tree the markdown file is in? If not it would be great if we could set a Global Templates directory that mark could look at for templates. If mark looked at the current dir where it is being executed for a templates directory or we could pass a --global-template-dir that would be very helpful. Or if mark searched directories up the tree to look for a matching template name and applied that template which would have the benefit of creating an override.

Does that sound like a feature that would be worth looking into?

johnathank-nuna avatar Feb 28 '22 19:02 johnathank-nuna

This would be great. While I was investigating a way to do this, I noticed that old versions of mark would include templates relative to the directory mark is running, and not the document itself. For example:

document

<!-- Include: docs/includes/disclaimer-generation.mkdn -->

mark 8.0

2022-03-08 01:22:22.104 INFO  processing docs/myfolder/thejob/test.md
2022-03-08 01:22:22.105 FATAL unable to load template
                              ├─ unable to read template file
                              │  ├─ open docs/myfolder/thejob/docs/includes/disclaimer-generation.mkdn: no such file or directory
                              │  └─ name: docs/includes/disclaimer-generation
                              │
                              └─ path: docs/includes/disclaimer-generation.mkdn

mark 7.0

2022-03-08 01:27:21.225 INFO  processing docs/myfolder/thejob/test.md
2022-03-08 01:27:22.656 DEBUG resolving page path: ??? > Test > Myfolder > MyJob > Testing
[...]
2022-03-08 01:27:23.780 INFO  page will be stored under path: Test > Test > Myfolder > MyJob > Testing
[...]
OK!

eitchugo avatar Mar 08 '22 04:03 eitchugo