Converts source code filenames to PrismJS language aliases.
Install with npm:
$ npm i filename2prism --save
The following reads a directory of source code files, highlights them according to their filenames, and then outputs the results to another directory:
const path =const fs =const filename2prism =const prism =// Loads all languagesconst src = 'path/to/some/src/dir'const out = 'path/to/some/out/dir'fs
filename2prism(filename) -> string | Array<string> | undefined
Returns a PrismJS language alias from a filename. A
string is returned if there was one match, an
Array<string> is returned if there were multiple matches, and
undefined is returned if there was no match.
string- The filename to infer a PrismJS alias from.
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Install dev dependencies:
$ npm i -d && npm test