Socket
Socket
Sign inDemoInstall

markdown-it-attrs

Package Overview
Dependencies
0
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.1 to 0.6.0

8

demo.js
'use strict';
var md = require('markdown-it')();
var markdownItAttrs = require('./');
var mark = require('markdown-it-mark');
var markdownItAttrs = require('markdown-it-attrs');
md.use(mark).use(markdownItAttrs);
md.use(markdownItAttrs);
var src = '# header {.style-me}\n'
src += 'paragraph {data-toggle=modal}\n';
src += '==paragraph=={.red}\n';
src += 'paragraph {data-toggle=modal}';

@@ -12,0 +10,0 @@ var res = md.render(src);

@@ -77,7 +77,6 @@ 'use strict';

var nextLastInline = nextLast(inlineTokens);
var possibleBulletListOpen = secondTokenNotHidden(tokens, i - 1);
if (nextLastInline && possibleBulletListOpen &&
nextLastInline.type === 'softbreak' &&
possibleBulletListOpen.type === 'bullet_list_open') {
utils.addAttrs(attrs, secondTokenNotHidden(tokens, i - 1));
var correspondingBlock = firstTokenNotHidden(tokens, i - 1);
if (nextLastInline && nextLastInline.type === 'softbreak' &&
correspondingBlock && correspondingBlock.type === 'list_item_open') {
utils.addAttrs(attrs, bulletListOpen(tokens, i - 1));
// remove softbreak and {} inline tokens

@@ -87,3 +86,3 @@ tokens[i].children = inlineTokens.slice(0, -2);

// some blocks are hidden, example li > paragraph_open
utils.addAttrs(attrs, firstTokenNotHidden(tokens, i - 1));
utils.addAttrs(attrs, correspondingBlock);
last(inlineTokens).content = content.slice(0, curlyStart);

@@ -138,9 +137,9 @@ }

/**
* same as firstTokenNotHidden, but sTNH([ tok1, tok2, hidden ], 2) gives tok1
* Find first bullet list open.
*/
function secondTokenNotHidden(tokens, i) {
if (tokens[i] && tokens[i].hidden) {
return secondTokenNotHidden(tokens, i - 1);
function bulletListOpen(tokens, i) {
if (tokens[i] && tokens[i].type !== 'bullet_list_open') {
return bulletListOpen(tokens, i - 1);
}
return firstTokenNotHidden(tokens, i - 1);
return tokens[i];
}

@@ -147,0 +146,0 @@

@@ -78,7 +78,6 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.markdownItAttrs = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

var nextLastInline = nextLast(inlineTokens);
var possibleBulletListOpen = secondTokenNotHidden(tokens, i - 1);
if (nextLastInline && possibleBulletListOpen &&
nextLastInline.type === 'softbreak' &&
possibleBulletListOpen.type === 'bullet_list_open') {
utils.addAttrs(attrs, secondTokenNotHidden(tokens, i - 1));
var correspondingBlock = firstTokenNotHidden(tokens, i - 1);
if (nextLastInline && nextLastInline.type === 'softbreak' &&
correspondingBlock && correspondingBlock.type === 'list_item_open') {
utils.addAttrs(attrs, bulletListOpen(tokens, i - 1));
// remove softbreak and {} inline tokens

@@ -88,3 +87,3 @@ tokens[i].children = inlineTokens.slice(0, -2);

// some blocks are hidden, example li > paragraph_open
utils.addAttrs(attrs, firstTokenNotHidden(tokens, i - 1));
utils.addAttrs(attrs, correspondingBlock);
last(inlineTokens).content = content.slice(0, curlyStart);

@@ -139,9 +138,9 @@ }

/**
* same as firstTokenNotHidden, but sTNH([ tok1, tok2, hidden ], 2) gives tok1
* Find first bullet list open.
*/
function secondTokenNotHidden(tokens, i) {
if (tokens[i] && tokens[i].hidden) {
return secondTokenNotHidden(tokens, i - 1);
function bulletListOpen(tokens, i) {
if (tokens[i] && tokens[i].type !== 'bullet_list_open') {
return bulletListOpen(tokens, i - 1);
}
return firstTokenNotHidden(tokens, i - 1);
return tokens[i];
}

@@ -148,0 +147,0 @@

{
"name": "markdown-it-attrs",
"version": "0.5.1",
"version": "0.6.0",
"description": "Add classes, identifiers and attributes to your markdown with {} curly brackets, similar to pandoc's header attributes",

@@ -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