-
Notifications
You must be signed in to change notification settings - Fork 4
Rulers: Tokens and Processing
Tokens are the workhorse of the entire extension. Simply put, they determine the HTML output that will conform to the specified method. Unfortunately, we're still not completely aware of what a token can and can't do, but we'll cover everything we know for certain.
But first, let us start with passing tokens, as well as relevant tag components into a function. See Dissection of a Tag for descriptions of tag
, tagInfo
, and content
.
Functions can be made to process the tag, the tag arguments, and even the tag contents, providing far more flexibility than just outputting a simple HTML element + class (see wrap). Here are the two types of functions that can be made.
method: function (token, [tagInfo, content]) { } //single token
method: function (startToken, endToken, [tagInfo, content]) { } //double token
Each function requires a single token
or the combination startToken
and endToken
, with the optional arguments tagInfo
and content
. You'll find throughout our code that we regularly switch between using token
and state
for single token
's, ignore it. We've been through a lot.
From what we have found, any method can take any function. Also, all that a function needs to do is just build the HTML into the token, without any need to return anything. Though we do have some functions doing a return true
for some reason we're not quite sure why.
Although a function can be passed tagInfo
and content
, it is not necessary for there to be anything in them, and not having them doesn't mean a tag with them will not be processed. It is up to the code to determine how to process these optional arguments.