Won’t it be nice if TeX could pretty-print files hosted on github, e.g.,
or include a remotely hosted markdown file in your document
I wanted to add this feature to the filter and vim modules.
Although I knew that ConTeXt could read remote files directly, I thought that it would be hard to plug into this mechanism.
Boy, was I wrong. Look at the commit history of the change needed to add this feature.
All I needed to do, was add
\locfilename to get the local file name for a file. If the requested file is a remote file (i.e., starts with
ftp://), ConTeXt downloads the file and stores it in the cache directory, and return the name of the cached file. Pretty neat, eh?
With this change,
\process<filter>file macro of the filter module can read remote files. Since, the vim module is built on top of the filter module, the
\type<vim>file can also read remote files.
The above feature is currently only available in the
dev branch. I’ll make a new release once I add hooks to force re-download of remote files. Meanwhile, if you have a ConTeXt macro that reads files, just add a
\locfilename at appropriate place, and your macro will be able to read remote files