Preprocessing transcluded files

Mark Knight's Avatar

Mark Knight

21 Nov, 2019 07:43 PM

Hi there,

I have begun experimenting with using the various kinds of transclude syntax for previewing larger projects made up of multiple files together. I also use a custom preprocessor. So far I have found that only the main file is processed, but I'd like the preprocessor to apply to everything previewed, including the transcluded files. Is that possible, or is it simply not possible to use a preprocessor in this way? And if it is possible, what might I be doing wrong? Any help much appreciated.

Thanks in advance!


  1. Support Staff 1 Posted by Brett on 21 Nov, 2019 07:50 PM

    Brett's Avatar

    The entire concatenated file should be processed, but there's no
    individual processing for included files. Does that answer your
    question? If not, could you give me some more details on exactly how
    you're including files and what your preprocessor setup is?


  2. 2 Posted by Mark Knight on 21 Nov, 2019 08:28 PM

    Mark Knight's Avatar

    Hi Brett,

    Thanks for a speedy response. In light of your answer, I can now see I hadn’t quite tested enough to realise what was happening.

    You’re right, of course, that when I include a file using the standard syntax (e.g. <<[Testing 321.txt]) everything is processed.

    I use a simple preprocessor to do one or two things to notes in nvALT, like turning [[Links]] into Markdown links that will still link back to those original notes in previews, etc. (You actually helped me with the regex for that one moons ago – thanks again!)

    What I want to achieve is to have functional [[Links]] to the files in nvALT (or ULTRA!) that would turn into includes in the preview. To do that, I’ve attempted using a regex in a preprocessor that will take any [[Link]] followed directly by a symbol (◇) and turn it into the include syntax – thus, instead of being turned into a Markdown link by the preprocessor, it gets turned into an include.

    All that is working fine, but for the fact that the file included is not then processed by the preprocessor as it would be if the include syntax actually appeared in the main file rather than being “created” as it were at this stage.

    Perhaps this is just a really stupid thing to attempt! But I’ve been working on the basis of something that would be very useful for me. Is it just impossible?



  3. Support Staff 3 Posted by Brett on 21 Nov, 2019 09:57 PM

    Brett's Avatar

    Well, preprocessing every individual file is very complicated from
    Marked's perspective, so I doubt anything will change there. And you're
    right, by the time Marked runs the preprocessor, it's already checked
    for includes and won't process new ones.

    You do have the option, of course, of inserting the text yourself. If
    you're already doing a search and replace, you should be able to `cat`
    the actual note into place. It would still get all of the regular
    processing, but if you needed to preprocess the included note as well
    then things get a step more complicated. But just inserting the text of
    files you have a path for shouldn't be impossible.

    BTW, in nvUltra the MMD transclusion syntax works in the preview
    automatically :).


  4. 4 Posted by Mark Knight on 02 Dec, 2019 02:33 PM

    Mark Knight's Avatar

    Belatedly, thanks, and good to know the transclusion will work with nvUltra! Mark

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac