I need a template engine (preprocessor) for Windows that allows me to define my own (very simple) language. I need it for generating html files. It should be able to make macro substitutions but also to make replacements like this:

replace this:


with this:

<a target="_blank" href="http://www.example.com">http://www.example.com</a>

I prefer to be able to define replacements in a text file - preferably in a way that looks readable, where you can write http:// instead of an escape sequence like http:\/\/ (sed has this issue).

Later edit: meanwhile I managed to do something like this using sed for Windows, but the script looks dreadful:

#Plain link
s/lnk\x28\(.*\)\x29/<a target="_blank" href="\1">\1<\/a>/g

Instead, it would be much better to be able to define replacements in a way like this:

#Replace this:
#With this:
<a target="_blank" href="$var">$var</a>

Basically I need to compile a source text file into a HTML file.

I'm using Windows 10 x64

  • 4
    What tools do you have available, and are willing to use? Is a commercial solution acceptable, or FOSS only? What is the ultimate problem you are trying to solve? Commented Feb 1, 2019 at 20:45
  • @Jeff Zeitlin - Now that I tried with sed - and it works (quite rudimentary but it works), I think that having a GUI is not important. What is important for me to be able to define the substitutions in a way that it's easy to read. "Compiling" the source using a command-line batch is not a problem
    – BearCode
    Commented Feb 13, 2019 at 6:09
  • What about a PHP tempting engine, like Smarty? Might something like that help? It is intended to generate HTML though variable substitution.
    – Mawg
    Commented Feb 13, 2019 at 14:40

2 Answers 2


You might consider the UNIX/Linux standard macro preprocessor m4, which does have at least one port to Windows, and is almost certainly available in WSL (although you didn't indicate what version of Windows you're using). I'm pretty sure it can handle your example substitution cleanly, and defines the substitutions almost as simply as your desire.

Another possibility is gpp, a generalized preprocessor whose syntax is different from that of m4, but still simple. There is an (unmaintained) Windows build.

  • Thanks, now my script looks readable, like "define(`lnk',<a target="_blank" href="$1">$1</a>)", m4 is awesome! (I downloaded the m4 contained in the gnuwin32 package)
    – BearCode
    Commented Feb 14, 2019 at 22:28

To generate files with e-mail signatures I used python based jinja2 template engine. Bacause I like python (and template filled by data extracted from web, so python scrapy is good suited).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.