Automatic update of "modified:..." in .md file header



  • Hi guys,

    First post so please be gentle…

    I’m currently working on the website for TV Rename (www.tvrename.com) which is contains many markdown files (.md) hosted using GitHub pages.

    Problem is I keep forgetting to update the “modified:” tag in the file headers viz:


    title: “Quick-Start”
    permalink: /manual/quickstart/
    excerpt: “This guide will help you with the initial setup TV Rename.”
    modified: 2018-01-24T15:53:02-04:00
    sidebar:
    nav: “quickstart”
    redirect_from:
    - /theme-setup/

    Is there a method (or plugin) that will automatically modify this entry when the file is saved?

    Been looking for absolutely ages and haven’t found anything yet!

    Cheers!

    Andy B.



  • What you want is something that will set a callback on the FILEBEFORESAVE notification.

    You could use PythonScript – download the latest using the Plugin Manager, or directly from the github repo releases. The Plugins > Python Script > Context-Help will bring up a help window; navigate to Notepad++ Object and scroll down to notepad.callback(function, notifications) for the syntax.

    You can search this forum for “callback” to find other complete examples of how to set up a callback. (You would want to put the callback initialization in your startup.py in order to get it to be always enabled.) I believe there are also examples in the forum of applying a callback only to a particular type of file – for you, you’d presumably want it only if the file was a .md markdown file.

    I assume LuaScript would also have the notification/callback feature, too (though I could be wrong).


Log in to reply