Socket
Socket
Sign inDemoInstall

micromark-extension-gfm-strikethrough

Package Overview
Dependencies
11
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.1 to 0.6.2

82

index.js

@@ -8,4 +8,2 @@ module.exports = create

var characterGroupPunctuation = 2
function create(options) {

@@ -29,6 +27,4 @@ var settings = options || {}

var strikethrough
var opening
var closing
var text
var indexOpen
var open
var nextEvents

@@ -38,27 +34,28 @@

while (++index < events.length) {
closing = events[index][1]
// Find a token that can close.
if (closing.type === 'strikethroughSequenceTemporary' && closing._close) {
indexOpen = index
if (
events[index][0] === 'enter' &&
events[index][1].type === 'strikethroughSequenceTemporary' &&
events[index][1]._close
) {
open = index
// Now walk back to find an opener.
while (indexOpen--) {
opening = events[indexOpen][1]
while (open--) {
// Find a token that can open the closer.
if (
opening.type === 'strikethroughSequenceTemporary' &&
opening._open &&
closing.end.offset - closing.start.offset ===
opening.end.offset - opening.start.offset &&
!(closing._open || opening._close)
events[open][0] === 'exit' &&
events[open][1].type === 'strikethroughSequenceTemporary' &&
events[open][1]._open &&
// If the sizes are the same:
events[index][1].end.offset - events[index][1].start.offset ===
events[open][1].end.offset - events[open][1].start.offset
) {
closing.type = 'strikethroughSequence'
opening.type = 'strikethroughSequence'
events[index][1].type = 'strikethroughSequence'
events[open][1].type = 'strikethroughSequence'
strikethrough = {
type: 'strikethrough',
start: shallow(opening.start),
end: shallow(closing.end)
start: shallow(events[open][1].start),
end: shallow(events[index][1].end)
}

@@ -68,4 +65,4 @@

type: 'strikethroughText',
start: shallow(opening.end),
end: shallow(closing.start)
start: shallow(events[open][1].end),
end: shallow(events[index][1].start)
}

@@ -76,4 +73,4 @@

['enter', strikethrough, context],
['enter', opening, context],
['exit', opening, context],
['enter', events[open][1], context],
['exit', events[open][1], context],
['enter', text, context]

@@ -89,3 +86,3 @@ ]

context.parser.constructs.insideSpan.null,
events.slice(indexOpen + 1, index),
events.slice(open + 1, index),
context

@@ -98,15 +95,10 @@ )

['exit', text, context],
['enter', closing, context],
['exit', closing, context],
['enter', events[index][1], context],
['exit', events[index][1], context],
['exit', strikethrough, context]
])
chunkedSplice(
events,
indexOpen - 1,
index - indexOpen + 3,
nextEvents
)
chunkedSplice(events, open - 1, index - open + 3, nextEvents)
index = indexOpen + nextEvents.length - 2
index = open + nextEvents.length - 2
break

@@ -155,4 +147,4 @@ }

function more(code) {
var before = classifyCharacter(previous)
var token
var before
var after

@@ -162,6 +154,3 @@

// If this is the third marker, exit.
if (size > 1) {
return nok(code)
}
if (size > 1) return nok(code)
effects.consume(code)

@@ -172,12 +161,7 @@ size++

if (size < 2 && !single) {
return nok(code)
}
before = classifyCharacter(previous)
if (size < 2 && !single) return nok(code)
token = effects.exit('strikethroughSequenceTemporary')
after = classifyCharacter(code)
token = effects.exit('strikethroughSequenceTemporary')
token._open = !after || (before && after === characterGroupPunctuation)
token._close = !before || (after && before === characterGroupPunctuation)
token._open = !after || (after === 2 && before)
token._close = !before || (before === 2 && after)
return ok(code)

@@ -184,0 +168,0 @@ }

{
"name": "micromark-extension-gfm-strikethrough",
"version": "0.6.1",
"version": "0.6.2",
"description": "micromark extension to support GFM strikethrough",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc