Skip to content

AgustinSRG/Text-Transform

Repository files navigation

Text Transform

Library to build simple text transform tools you can run in your browser.

Usage

Import the style:

<link rel="stylesheet" href="https://agustinsrg.github.io/Text-Transform/style/text-transform.min.css">

Import the script:

<script type="text/javascript" src="https://agustinsrg.github.io/Text-Transform/js/text-transform.min.js"></script>

Define the transform algorithm:

TextTransform.ready(function () {
    // First argument: Element or selector to mount into
    // Second argument: Array of input parsers. 
    // They parse the input text to intermediary unified format for formatters
    // Set a parser to null if the input does not need any parsing
    // Third argument: Array of formatters, 
    // they take the intermediary unified format
    // and return the outout text
    TextTransform.mount(
        ".text-transform",
        [
            {
                name: "Input String",
                parser: null,
            }
        ],
        [
            {
                name: "Uppercase",
                formatter: function (arg) {
                    return arg.toUpperCase()
                },
            },
            {
                name: "Lowercase",
                formatter: function (arg) {
                    return arg.toLowerCase()
                },
            }
        ],
    );
});

Parsers and formatters functions can return a Promise if you require async functionality.

Examples

Build from source code

Install dependencies:

npm install

Build minified files:

npm run build

About

Simple library to build text transform web apps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published