UNPKG

shortcode-insert

Version:

Shortcode parser, fully-programmable and asychronous. It can parse Wordpress shortcodes as well as embed and insert codes from other platforms.

1 lines 14.3 kB
{"ShortcodeParserFinder()":{"longname":"ShortcodeParserFinder","name":"ShortcodeParserFinder","kind":"constructor","description":"Get an object containing the regular expressions to use in extracting tag and tag-attribute data. Construct these expressions to work with the given start and end tag characters supplied in the options object.","memberof":"ShortcodeParserFinder","params":[{"type":{"names":["object"]},"description":"The options object.","name":"options"},{"type":{"names":["string"]},"description":"Start of tag characters.","name":"options.start"},{"type":{"names":["string"]},"description":"End of tag characters.","name":"options.end"}],"returns":[{"type":{"names":["ShortcodeParserFinder"]}}],"order":5},"ShortcodeParserTag()":{"longname":"ShortcodeParserTag","name":"ShortcodeParserTag","kind":"constructor","description":"Create new tag object, describing extracted tag.","memberof":"ShortcodeParserTag","params":[{"type":{"names":["ShortcodeParserFinder"]},"description":"Finder object to apply.","name":"finder"},{"type":{"names":["Array"]},"description":"Results of tag extraction.","name":"result"}],"returns":[{"type":{"names":["ShortcodeParserTag"]},"description":"New tag object."}],"order":9},"ShortcodeParser()":{"longname":"ShortcodeParser","name":"ShortcodeParser","kind":"constructor","description":"Create a new Shortcode parser instance.","memberof":"ShortcodeParser","params":[{"type":{"names":["Object"]},"description":"Options to ShortcodeParser function.","name":"options"}],"returns":[{"type":{"names":["ShortcodeParser"]},"description":"New instance of shortcode parser."}],"order":17},"ShortcodeParserFinder":{"longname":"ShortcodeParserFinder","name":"ShortcodeParserFinder","scope":"global","kind":"typedef","properties":[{"type":{"names":["RegExp"]},"description":"Expression for extracting a tag.","name":"tagMatch"},{"type":{"names":["RegExp"]},"description":"Expression to test if a tag is an end tag","name":"isEndTag"},{"type":{"names":["RegExp"]},"description":"Expression to extract the tag name.","name":"getTagName"},{"type":{"names":["function"]},"description":"Method to extract the attributes in a given start tag string.","name":"getAttributes"},{"type":{"names":["RegExp"]},"description":"Expression for extracting the contents of start tag.","name":"getStartTagContent"}],"meta":{"lineno":17,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":0},"ShortcodeParserTag":{"longname":"ShortcodeParserTag","name":"ShortcodeParserTag","scope":"global","kind":"class","access":"private","meta":{"lineno":184,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":8},"ShortcodeParser":{"longname":"ShortcodeParser","name":"ShortcodeParser","scope":"global","kind":"class","access":"public","meta":{"lineno":284,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":16},"_addSlashToEachCharacter":{"longname":"_addSlashToEachCharacter","name":"_addSlashToEachCharacter","scope":"global","kind":"function","description":"Add slashes to every character in a string. Can be used to ensure all of contents is treated as text and not used as regular expression functionality when creating a RegExp with the given content.","params":[{"type":{"names":["string"]},"description":"The string to add slashes to.","name":"txt"}],"returns":[{"type":{"names":["string"]},"description":"New slashed string."}],"access":"private","meta":{"lineno":41,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":1},"_getAttribute":{"longname":"_getAttribute","name":"_getAttribute","scope":"global","kind":"function","description":"Get the attributes in the given tag text. Will return an object of the tag attributes with properties being equal to their names and property values equalling their value. Also, assign numbered properties for attribute positions.","params":[{"type":{"names":["RegExp"]},"description":"The regular expression to use in getting the attributes.","name":"getAttributes"},{"type":{"names":["string"]},"description":"The tag text from open tag start and close.","name":"tag"}],"returns":[{"type":{"names":["Object"]},"description":"The attributes object."}],"access":"private","meta":{"lineno":58,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":2},"_createRegExp":{"longname":"_createRegExp","name":"_createRegExp","scope":"global","kind":"function","description":"Safely create a regular expression from the given template with the given start and end characters replaced in the regular expression.","params":[{"type":{"names":["string"]},"description":"The regular expression template. The text {start} and {end} will be replaced with the given startChars and endChars.","name":"template"},{"type":{"names":["string"]},"description":"Tag start characters.","name":"startChars"},{"type":{"names":["string"]},"description":"Tag end characters.","name":"endChars"},{"type":{"names":["string"]},"optional":true,"defaultvalue":"''","description":"The regular expression options to use (eg. 'g' or 'gi').","name":"options"}],"returns":[{"type":{"names":["RegExp"]}}],"access":"private","meta":{"lineno":94,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":3},"_fixEndTags":{"longname":"_fixEndTags","name":"_fixEndTags","scope":"global","kind":"function","description":"Given an array of tags, remove end tags combining them with their start tag and placing tag content in the tag object.","params":[{"type":{"names":["string"]},"description":"The text containing all the given tags.","name":"txt"},{"type":{"names":["Array"]},"description":"Array of tag objects.","name":"tags"}],"returns":[{"type":{"names":["Array.<ShortcodeParserTag>"]},"description":"New array with end tags removed and tag data updated with any tag content."}],"access":"private","meta":{"lineno":134,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":6},"_filterOverlappingTags":{"longname":"_filterOverlappingTags","name":"_filterOverlappingTags","scope":"global","kind":"function","params":[{"type":{"names":["Array.<ShortcodeParserTag>"]},"description":"Tags to filter.","name":"tags"}],"returns":[{"type":{"names":["Array.<ShortcodeParserTag>"]},"description":"Filtered tags."}],"access":"private","meta":{"lineno":157,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":7},"_extractTagStrings":{"longname":"_extractTagStrings","name":"_extractTagStrings","scope":"global","kind":"function","description":"Extract tag strings from given text, return regular expression matches (with some addtional data, such as lastIndex).","params":[{"type":{"names":["string"]},"description":"Text to extract tags from.","name":"txt"},{"type":{"names":["ShortcodeParserFinder"]},"description":"Finder object to apply.","name":"finder"}],"returns":[{"type":{"names":["Array"]},"description":"Results array."}],"access":"private","meta":{"lineno":216,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":11},"_parse":{"longname":"_parse","name":"_parse","scope":"global","kind":"function","description":"Parse string for tags that handlers have been added for. Return tags that can be parsed.","params":[{"type":{"names":["string"]},"description":"Text to parse for tags.","name":"txt"},{"type":{"names":["ShortcodeParserFinder"]},"description":"Finder object to apply.","name":"finder"},{"type":{"names":["ShortcodeParser"]},"description":"The parser instance.","name":"parserInstance"}],"returns":[{"type":{"names":["Array.<ShortcodeParserTag>"]},"description":"Tags which can be handled."}],"access":"private","meta":{"lineno":236,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":12},"_applyHandler":{"longname":"_applyHandler","name":"_applyHandler","scope":"global","kind":"function","description":"Apply a handler function to a given tag with supplied parameters.","params":[{"type":{"names":["function"]},"description":"Handler to apply.","name":"handler"},{"type":{"names":["ShortcodeParserTag"]},"description":"Tag to apply handler to.","name":"tag"},{"type":{"names":["Array"]},"description":"Further parameters to pass to the handler.","name":"params"}],"returns":[{"type":{"names":["Promise.<ShortcodeParserReplacer>"]}}],"access":"private","meta":{"lineno":258,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":14},"_isSelectorMatch":{"longname":"_isSelectorMatch","name":"_isSelectorMatch","scope":"global","kind":"function","description":"Test if given selector is selector for the given tag.","params":[{"type":{"names":["RegExp","function"]},"description":"Selector to test.","name":"selector"},{"type":{"names":["ShortcodeParserTag"]},"description":"Tag to test against.","name":"tag"}],"returns":[{"type":{"names":["boolean"]}}],"access":"private","meta":{"lineno":272,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":15},"ShortcodeParserTag.":{"longname":"ShortcodeParserTag.","name":"ShortcodeParserTag.","scope":"global","kind":"typedef","properties":[{"type":{"names":["string"]},"description":"The name of tag.","name":"tagName"},{"type":{"names":["boolean"]},"description":"Is this an end tag.","name":"endTag"},{"type":{"names":["string"]},"description":"The full tag text and content.","name":"fullMatch"},{"type":{"names":["integer"]},"description":"Start character number in original text.","name":"start"},{"type":{"names":["integer"]},"description":"end character number in original text.","name":"end"},{"type":{"names":["object"]},"description":"The tag attributes as an object.","name":"attributes"},{"type":{"names":["string"]},"description":"The content of tag when their is an opening and closing tag.","name":"content"},{"type":{"names":["boolean"]},"description":"Is this a self-closing tag?","name":"selfClosing"},{"type":{"names":["string"]},"description":"Contents of starting tag.","name":"tagContents"}],"meta":{"lineno":168,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":10},"ShortcodeParserReplacer":{"longname":"ShortcodeParserReplacer","name":"ShortcodeParserReplacer","scope":"global","kind":"typedef","properties":[{"type":{"names":["string"]},"description":"Text to replace tag with.","name":"replacer"},{"type":{"names":["ShortcodeParserTag"]},"description":"Tag to do replacement on.","name":"tag"}],"meta":{"lineno":242,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":13},"ShortcodeParser.add":{"longname":"ShortcodeParser.add","name":"add","scope":"static","kind":"function","description":"Add a new handler to the parser for given tag name.","memberof":"ShortcodeParser","params":[{"type":{"names":["string","function","RegExp"]},"description":"Tag name to set handler for.","name":"name"},{"type":{"names":["function"]},"description":"Handler function to fire on tag.","name":"handler"},{"type":{"names":["boolean"]},"optional":true,"defaultvalue":true,"description":"Throw error if tage already exists?","name":"throwOnAlreadySet"}],"returns":[{"type":{"names":["function"]},"description":"The handler function returned."}],"access":"public","meta":{"lineno":332,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":19},"ShortcodeParser.has":{"longname":"ShortcodeParser.has","name":"has","scope":"static","kind":"function","description":"Test if a handler for given tag name.","memberof":"ShortcodeParser","params":[{"type":{"names":["string"]},"description":"The tag to look for a handler on.","name":"name"}],"returns":[{"type":{"names":["boolean"]},"description":"Does it exist?"}],"access":"public","meta":{"lineno":348,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":20},"ShortcodeParser.delete":{"longname":"ShortcodeParser.delete","name":"delete","scope":"static","kind":"function","description":"Delete the handler for given tag name.","memberof":"ShortcodeParser","params":[{"type":{"names":["string"]},"description":"The tagname to delete the handler for.","name":"name"}],"returns":[{"type":{"names":["boolean"]}}],"access":"public","meta":{"lineno":358,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":21},"ShortcodeParser.get":{"longname":"ShortcodeParser.get","name":"get","scope":"static","kind":"function","description":"Get the handler function for given tag name.","memberof":"ShortcodeParser","params":[{"type":{"names":["string"]},"description":"Tag name to get the handler for.","name":"name"}],"returns":[{"type":{"names":["function"]},"description":"The handler for the given tag name."}],"access":"public","meta":{"lineno":371,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":22},"ShortcodeParser.parse":{"longname":"ShortcodeParser.parse","name":"parse","scope":"static","kind":"function","description":"Parse given text for tags, running handlers where handlers are defined and returning parsed text.","memberof":"ShortcodeParser","params":[{"type":{"names":["string"]},"description":"Text to parse.","name":"txt"},{"type":{"names":["Array"]},"optional":true,"defaultvalue":"[]","description":"Parameters to pass to the handlers.","name":"params"}],"returns":[{"type":{"names":["Promise.<string>"]},"description":"Promise resolving to new parsed text."}],"access":"public","meta":{"lineno":387,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":23},"ShortcodeParser~_runHandlers":{"longname":"ShortcodeParser~_runHandlers","name":"_runHandlers","scope":"inner","kind":"function","description":"Run set handlers for given tags, replacing text content as the handler return content.","memberof":"ShortcodeParser","params":[{"type":{"names":["string"]},"description":"The full text containing the tags to do the replacements on.","name":"txt"},{"type":{"names":["Array.<ShortcodeParserTag>"]},"description":"The tags to run handlers on.","name":"_tags"},{"type":{"names":["Array"]},"description":"The parameters to pass on to the tag handlers.","name":"params"}],"returns":[{"type":{"names":["Promise.<string>"]},"description":"Promise resolving on completion of tag replacements."}],"access":"private","meta":{"lineno":301,"filename":"index.js","path":"/home/simpo/Projects/shortcode-parser"},"order":18}}