MarkdownConverter icon indicating copy to clipboard operation
MarkdownConverter copied to clipboard

Variable Substitution does not work when chaining documents

Open karmeye opened this issue 3 years ago • 1 comments

Hello @manuth

Running the Chain all Documents command the variables are not set.

Whether referring to them in the same md file they were defined or another file. Nothing is rendered. However if a varible is set as a header, e.g. ## {{ Title }} then it is rendered Untitled-1.

Thx

karmeye avatar Feb 16 '22 05:02 karmeye

Hi @karmeye I feel like this will bring up a lot of questions I haven't considered or thought about so far.

Currently, MarkdownConverter creates a blank document and pastes the content of all markdown files it can find into said document. After that, it will convert the document mentioned before.

This document is not saved to the disk which is why you end up with the Title being Untitled-1. In this process, all yaml variables are basically getting thrown away.

I'm not sure on how to go on further with this. I have some questions in mind I need to think about before being able to implement some alternative which is why I haven't assigned this issue to the upcoming milestone.

The questions being:

  • puppeteer doesn't allow dynamic headers and footers which means: The headers and footers in the whole chained document must be the same.
    • Where should the variables for the header and the footer be loaded from?
    • Should the variables from all documents be merged together?
    • How should MarkdownConverter handle the case when multiple documents declare variables with the same name?
  • An option would be to first convert all markdown files to HTML and chain the HTML code together. To make sure no variables get substituted by accident, #143 must be implemented first.
  • Another option would be to create a separate method for only rendering the markdown segment using handlebars but not using markdown-it... no idea how to name it though. However - just like in the method mentioned before, the resulting markdown code could be chained together. This might work out the best, I guess.

neurolag avatar Sep 16 '22 01:09 neurolag