A JavaScript port of the JagTag text parsing language.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
.github
docs
src Remove plugin scripts and include modified XRegExp May 11, 2018
test
.eslintignore
.eslintrc Finish docs (Full change list in PR) May 9, 2018
.gitignore
LICENSE
README.md
deps.bat Begin implementing docs (WIP) May 6, 2018
index.js
jest.coverage.js Finish docs (Full change list in PR) May 9, 2018
mkdocs.yml
package-lock.json Bump eslint from 5.14.0 to 5.14.1 Feb 19, 2019
package.json Bump jest from 23.6.0 to 24.1.0 Feb 6, 2019
requirements.txt

README.md

JagTag-JS

Codecov License

A JavaScript port of the JagTag text parsing language, originally written in Java by @jagrosh.

This document is a mere README; most of the relevant information can be found in the documentation.

What is JagTag?

JagTag is, in the author's own words, a simple yet powerful and customisable interpreted text parsing language. In practice, JagTag notation is used to customise user input with tags which use the format {name:arg1|arg2}.

How does this differ?

First of all, the implementation of JagTag has been ported to JavaScript. The key thing to note here is that the actual code has not been ported due to language limitations. Instead, this system is essentially JagTag notation implemented in JavaScript with a slightly different methodology.

Due to language-level limitations, some of the methods are also not fully compatible. This project has been developed with maximum compatibility in mind, but some minor changes have been made. More details can be found in the documentation.

It's worth noting that the Discord-related tag functions have been developed to suit Eris and have not been tested with other libraries. For now it's recommended to use Eris in conjunction with the Discord-related tags, if you wish to use those.

Installation and usage

JagTag-JS is available on NPM and you can install it with npm i @thesharks/jagtag-js. Make sure you have Node.js >= 8 installed.

Basic syntax:

const JagTagParser = require('@thesharks/jagtag-js')

JagTagParser('string to parse', argsObject)

For more information about the args object, see the API reference.

Simple example

At its most basic level, JagTag-JS can be used to perform simple string-related operations without any complications.

const JagTagParser = require('@thesharks/jagtag-js')

JagTagParser('change {upper:this} to uppercase')
// Returns 'change THIS to uppercase'

Advanced example

More advanced operations may require you to pass arguments to the parser in order to function correctly. Please check the developer documentation for information on what parser-level arguments need to be passed for which method.

const JagTagParser = require('@thesharks/jagtag-js')

JagTagParser('{argslen} arguments were passed to this tag', { tagArgs: [ 'item1', 'item2', 'item3' ] })
// Returns '3 arguments were passed to this tag'

For more examples and help, check the documentation.

Contributing

See CONTRIBUTING.md.