inline-js-default-transforms
This repository contains builtin transformers for inline-js
Installation
npm install inline-js-default-transforms
Usage
const createInliner = ;const TRANSFORMS = ; const inliner = ;TRANSFORMS;
TRANSFORMS
cssmin
Minify css content.
dataurl
Convert the content into data URL.
The transformer would determine the mimetype from the filename:
// data:text/css;charset=utf8;base64,... // data:image/png;base64,...
Or you can pass the mimetype manually:
Specify charset (default to utf8
for text files):
docstring
Extract docstring (i.e. the top-most template literal) from the content.
eval
Evaluate JavaScript expression. You can access the content with $0
.
var version = ;
indent
Indent the string according to the indent of the current line.
entry.js
{ ;}
foo.js
console;console;
inlinejs entry.js
result:
{ console; console;}
markdown
Wrap content with markdown codeblock, code, or quote.
// a.txtsome text // $inline("a.txt|markdown:codeblock")```some text``` // $inline("a.txt|markdown:codeblock,js")```jssome text``` // $inline("a.txt|markdown:code")`some text` // $inline("a.txt|markdown:quote")> sometext
parse
JSON.parse
the content. You can access properties by specifying key name.
var version = nestedProp = ;
string
If the content is a buffer, convert it into a utf8 string. Otherwise do nothing.
stringify
JSON.stringify
the content. Useful to include text content into JavaScript code:
var myCssString = ;
trim
String.prototype.trim
the content.
Changelog
-
0.1.2 (Jun 6, 2020)
- Fix: make
indent
work with$inline.start
. - Add: support language mark in
markdown:codeblock
.
- Fix: make
-
0.1.1 (Jun 28, 2018)
- Fix: exclude test files from the package.
-
0.1.0 (Jun 27, 2018)
- Split out from inline-js.