Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tsimons/shortcode-tokenizer

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tsimons/shortcode-tokenizer - npm Package Compare versions

Comparing version 0.7.0 to 0.7.1

5

package.json
{
"name": "@tsimons/shortcode-tokenizer",
"version": "0.7.0",
"version": "0.7.1",
"public": true,

@@ -8,3 +8,4 @@ "description": "",

"scripts": {
"test": "poi test && cat ./coverage/report-lcov/lcov.info | coveralls -v && rm -rf ./coverage ",
"test":
"poi test && cat ./coverage/report-lcov/lcov.info | coveralls -v && rm -rf ./coverage ",
"watch": "poi",

@@ -11,0 +12,0 @@ "build": "poi build --format cjs",

36

src/shortcode-tokenizer.js

@@ -82,3 +82,3 @@ /** @module ShortcodeTokenizer */

export class Token {
constructor(type, body, pos = 0) {
constructor(type, body, pos = 0, strict = true) {
this.name = null

@@ -88,2 +88,3 @@ this.type = type

this.pos = pos
this.strict = strict
this.children = []

@@ -101,5 +102,11 @@ this.params = {}

const match = this.matchBody()
this.initName(match)
if (match[2]) {
this.initParams(match[2])
if (match === null) {
if (this.strict) {
throw new SyntaxError('Invalid ' + this.type + ' token: ' + this.body)
}
} else {
this.initName(match)
if (match[2]) {
this.initParams(match[2])
}
}

@@ -203,5 +210,2 @@ }

let match = this.body.match(rx)
if (match === null) {
throw new SyntaxError('Invalid ' + this.type + ' token: ' + this.body)
}
return match

@@ -304,3 +308,3 @@ }

if (typeof this.buf !== 'string') {
if (typeof this.buf !== 'string' && this.options.strict) {
throw new Error('Invalid input')

@@ -354,3 +358,3 @@ }

} else {
let err = new Token(ERROR, token.body)
let err = new Token(ERROR, token.body, 0, this.options.strict)
if (!parent) {

@@ -374,3 +378,5 @@ ast.push(err)

/* istanbul ignore next */
throw new SyntaxError('Unknown token: ' + token.type)
if (this.options.strict) {
throw new SyntaxError('Unknown token: ' + token.type)
}
}

@@ -382,3 +388,3 @@ }

} else {
ast.push(new Token(ERROR, token.body))
ast.push(new Token(ERROR, token.body, 0, this.options.strict))
}

@@ -434,3 +440,3 @@ }

if (match === null) {
let token = new Token(TEXT, this.buf, this.pos)
let token = new Token(TEXT, this.buf, this.pos, this.options.strict)
this.pos += this.buf.length

@@ -448,3 +454,4 @@ this.buf = null

this.buf.substring(0, match.index),
this.pos
this.pos,
this.options.strict
))

@@ -457,3 +464,4 @@ }

match[0],
this.pos + match.index
this.pos + match.index,
this.options.strict
))

@@ -460,0 +468,0 @@

@@ -272,3 +272,3 @@ import * as lib from '../../src/shortcode-tokenizer'

tokenizer.options.strict = false
expect(tokenizer.input('[/code]').ast()).to.eql([new Token('ERROR', '[/code]')])
expect(tokenizer.input('[/code]').ast()).to.eql([new Token('ERROR', '[/code]', 0, tokenizer.options.strict)])
})

@@ -275,0 +275,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc