markdown-it-attrs
Advanced tools
Comparing version 0.7.4 to 0.8.0
24
index.js
@@ -177,11 +177,23 @@ 'use strict'; | ||
/** | ||
* Find first bullet list open. | ||
* Find corresponding bullet/ordered list open. | ||
*/ | ||
function bulletListOpen(tokens, i) { | ||
if (tokens[i] && | ||
tokens[i].type !== 'bullet_list_open' && | ||
tokens[i].type !== 'ordered_list_open') { | ||
return bulletListOpen(tokens, i - 1); | ||
var level = 0; | ||
var token; | ||
for (; i >= 0; i -= 1) { | ||
token = tokens[i]; | ||
// jump past nested lists, level == 0 and open -> correct opening token | ||
if (token.type === 'bullet_list_close' || | ||
token.type === 'ordered_list_close') { | ||
level += 1; | ||
} | ||
if (token.type === 'bullet_list_open' || | ||
token.type === 'ordered_list_open') { | ||
if (level === 0) { | ||
return token; | ||
} else { | ||
level -= 1; | ||
} | ||
} | ||
} | ||
return tokens[i]; | ||
} | ||
@@ -188,0 +200,0 @@ |
@@ -178,11 +178,23 @@ (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){ | ||
/** | ||
* Find first bullet list open. | ||
* Find corresponding bullet/ordered list open. | ||
*/ | ||
function bulletListOpen(tokens, i) { | ||
if (tokens[i] && | ||
tokens[i].type !== 'bullet_list_open' && | ||
tokens[i].type !== 'ordered_list_open') { | ||
return bulletListOpen(tokens, i - 1); | ||
var level = 0; | ||
var token; | ||
for (; i >= 0; i -= 1) { | ||
token = tokens[i]; | ||
// jump past nested lists, level == 0 and open -> correct opening token | ||
if (token.type === 'bullet_list_close' || | ||
token.type === 'ordered_list_close') { | ||
level += 1; | ||
} | ||
if (token.type === 'bullet_list_open' || | ||
token.type === 'ordered_list_open') { | ||
if (level === 0) { | ||
return token; | ||
} else { | ||
level -= 1; | ||
} | ||
} | ||
} | ||
return tokens[i]; | ||
} | ||
@@ -189,0 +201,0 @@ |
{ | ||
"name": "markdown-it-attrs", | ||
"version": "0.7.4", | ||
"version": "0.8.0", | ||
"description": "Add classes, identifiers and attributes to your markdown with {} curly brackets, similar to pandoc's header attributes", | ||
@@ -43,4 +43,4 @@ "main": "index.js", | ||
"devDependencies": { | ||
"browserify": "^13.0.0", | ||
"eslint": "^3.3.0", | ||
"browserify": "^13.1.0", | ||
"eslint": "^3.7.1", | ||
"markdown-it": ">=7.0.1", | ||
@@ -47,0 +47,0 @@ "mocha": "*" |
@@ -82,2 +82,37 @@ # markdown-it-attrs [![Build Status](https://travis-ci.org/arve0/markdown-it-attrs.svg?branch=master)](https://travis-ci.org/arve0/markdown-it-attrs) [![npm version](https://badge.fury.io/js/markdown-it-attrs.svg)](http://badge.fury.io/js/markdown-it-attrs) | ||
Unfortunately, as of now, attributes on new line will apply to opening `ul` or `ol` for previous list item: | ||
```md | ||
- applies to | ||
- ul of last | ||
{.list} | ||
{.item} | ||
- here | ||
- we get | ||
{.blue} | ||
- what's expected | ||
{.red} | ||
``` | ||
Which is not what you might expect. [Suggestions are welcome](https://github.com/arve0/markdown-it-attrs/issues/32). #. Output: | ||
```html | ||
<ul> | ||
<li>applies | ||
<ul class="item list"> | ||
<li>ul of last</li> | ||
</ul> | ||
</li> | ||
</ul> | ||
<ul class="red"> | ||
<li>here | ||
<ul class="blue"> | ||
<li>we get</li> | ||
</ul> | ||
</li> | ||
<li>what's expected</li> | ||
</ul> | ||
``` | ||
If you need finer control, look into [decorate](https://github.com/rstacruz/markdown-it-decorate). | ||
@@ -84,0 +119,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27198
704
152