markdown-to-jsx
Advanced tools
Comparing version 6.5.2 to 6.6.0
@@ -164,3 +164,3 @@ 'use strict'; | ||
var LIST_ITEM_END_R = / *\n+$/; | ||
var LIST_LOOKBEHIND_R = /^$|\n *$/; | ||
var LIST_LOOKBEHIND_R = /(?:^|\n)( *)$/; | ||
var CAPTURE_LETTER_AFTER_HYPHEN = /-([a-z])?/gi; | ||
@@ -226,2 +226,8 @@ var NP_TABLE_R = /^(.*\|?.*)\n *(\|? *[-:]+ *\|[-| :]*)\n((?:.*\|.*\n)*)\n?/; | ||
// based on https://stackoverflow.com/a/18123682/1141611 | ||
// not complete, but probably good enough | ||
function slugify(str) { | ||
return str.replace(/[ÀÁÂÃÄÅàáâãäåæÆ]/g, 'a').replace(/[çÇ]/g, 'c').replace(/[ðÐ]/g, 'd').replace(/[ÈÉÊËéèêë]/g, 'e').replace(/[ÏïÎîÍíÌì]/g, 'i').replace(/[Ññ]/g, 'n').replace(/[øØœŒÕõÔôÓóÒò]/g, 'o').replace(/[ÜüÛûÚúÙù]/g, 'u').replace(/[ŸÿÝý]/g, 'y').replace(/[^a-z0-9- ]/gi, '').replace(/ /gi, '-').toLowerCase(); | ||
} | ||
function parseTableAlignCapture(alignCapture) { | ||
@@ -885,2 +891,3 @@ if (TABLE_RIGHT_ALIGN.test(alignCapture)) { | ||
content: parseInline(_parse2, capture[2], state), | ||
id: slugify(capture[2]), | ||
level: capture[1].length | ||
@@ -893,3 +900,3 @@ }; | ||
Tag, | ||
{ key: state.key }, | ||
{ id: node.id, key: state.key }, | ||
output(node.content, state) | ||
@@ -1078,6 +1085,8 @@ ); | ||
// nested lists inside this inline scope. | ||
var isStartOfLine = LIST_LOOKBEHIND_R.test(prevCapture); | ||
var isStartOfLine = LIST_LOOKBEHIND_R.exec(prevCapture); | ||
var isListBlock = state._list || !state.inline; | ||
if (isStartOfLine && isListBlock) { | ||
source = isStartOfLine[1] + source; | ||
return LIST_R.exec(source); | ||
@@ -1101,3 +1110,3 @@ } else { | ||
var itemContent = items.map(function (item, i) { | ||
// We need to see how far indented this item is: | ||
// We need to see how far indented the item is: | ||
var space = LIST_ITEM_PREFIX_R.exec(item)[0].length; | ||
@@ -1104,0 +1113,0 @@ |
@@ -150,3 +150,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var LIST_ITEM_END_R = / *\n+$/; | ||
var LIST_LOOKBEHIND_R = /^$|\n *$/; | ||
var LIST_LOOKBEHIND_R = /(?:^|\n)( *)$/; | ||
var CAPTURE_LETTER_AFTER_HYPHEN = /-([a-z])?/gi; | ||
@@ -212,2 +212,8 @@ var NP_TABLE_R = /^(.*\|?.*)\n *(\|? *[-:]+ *\|[-| :]*)\n((?:.*\|.*\n)*)\n?/; | ||
// based on https://stackoverflow.com/a/18123682/1141611 | ||
// not complete, but probably good enough | ||
function slugify(str) { | ||
return str.replace(/[ÀÁÂÃÄÅàáâãäåæÆ]/g, 'a').replace(/[çÇ]/g, 'c').replace(/[ðÐ]/g, 'd').replace(/[ÈÉÊËéèêë]/g, 'e').replace(/[ÏïÎîÍíÌì]/g, 'i').replace(/[Ññ]/g, 'n').replace(/[øØœŒÕõÔôÓóÒò]/g, 'o').replace(/[ÜüÛûÚúÙù]/g, 'u').replace(/[ŸÿÝý]/g, 'y').replace(/[^a-z0-9- ]/gi, '').replace(/ /gi, '-').toLowerCase(); | ||
} | ||
function parseTableAlignCapture(alignCapture) { | ||
@@ -871,2 +877,3 @@ if (TABLE_RIGHT_ALIGN.test(alignCapture)) { | ||
content: parseInline(_parse2, capture[2], state), | ||
id: slugify(capture[2]), | ||
level: capture[1].length | ||
@@ -879,3 +886,3 @@ }; | ||
Tag, | ||
{ key: state.key }, | ||
{ id: node.id, key: state.key }, | ||
output(node.content, state) | ||
@@ -1064,6 +1071,8 @@ ); | ||
// nested lists inside this inline scope. | ||
var isStartOfLine = LIST_LOOKBEHIND_R.test(prevCapture); | ||
var isStartOfLine = LIST_LOOKBEHIND_R.exec(prevCapture); | ||
var isListBlock = state._list || !state.inline; | ||
if (isStartOfLine && isListBlock) { | ||
source = isStartOfLine[1] + source; | ||
return LIST_R.exec(source); | ||
@@ -1087,3 +1096,3 @@ } else { | ||
var itemContent = items.map(function (item, i) { | ||
// We need to see how far indented this item is: | ||
// We need to see how far indented the item is: | ||
var space = LIST_ITEM_PREFIX_R.exec(item)[0].length; | ||
@@ -1090,0 +1099,0 @@ |
30
index.js
@@ -148,3 +148,3 @@ /* @jsx h */ | ||
const LIST_ITEM_END_R = / *\n+$/; | ||
const LIST_LOOKBEHIND_R = /^$|\n *$/; | ||
const LIST_LOOKBEHIND_R = /(?:^|\n)( *)$/; | ||
const CAPTURE_LETTER_AFTER_HYPHEN = /-([a-z])?/gi; | ||
@@ -223,2 +223,21 @@ const NP_TABLE_R = /^(.*\|?.*)\n *(\|? *[-:]+ *\|[-| :]*)\n((?:.*\|.*\n)*)\n?/; | ||
// based on https://stackoverflow.com/a/18123682/1141611 | ||
// not complete, but probably good enough | ||
function slugify (str) { | ||
return str | ||
.replace(/[ÀÁÂÃÄÅàáâãäåæÆ]/g,'a') | ||
.replace(/[çÇ]/g,'c') | ||
.replace(/[ðÐ]/g,'d') | ||
.replace(/[ÈÉÊËéèêë]/g,'e') | ||
.replace(/[ÏïÎîÍíÌì]/g,'i') | ||
.replace(/[Ññ]/g,'n') | ||
.replace(/[øØœŒÕõÔôÓóÒò]/g,'o') | ||
.replace(/[ÜüÛûÚúÙù]/g,'u') | ||
.replace(/[ŸÿÝý]/g,'y') | ||
.replace(/[^a-z0-9- ]/gi,'') | ||
.replace(/ /gi,'-') | ||
.toLowerCase() | ||
; | ||
} | ||
function parseTableAlignCapture (alignCapture) { | ||
@@ -913,2 +932,3 @@ if (TABLE_RIGHT_ALIGN.test(alignCapture)) { | ||
content: parseInline(parse, capture[2], state), | ||
id: slugify(capture[2]), | ||
level: capture[1].length, | ||
@@ -920,3 +940,3 @@ }; | ||
return ( | ||
<Tag key={state.key}> | ||
<Tag id={node.id} key={state.key}> | ||
{output(node.content, state)} | ||
@@ -1110,6 +1130,8 @@ </Tag> | ||
// nested lists inside this inline scope. | ||
const isStartOfLine = LIST_LOOKBEHIND_R.test(prevCapture); | ||
const isStartOfLine = LIST_LOOKBEHIND_R.exec(prevCapture); | ||
const isListBlock = state._list || !state.inline; | ||
if (isStartOfLine && isListBlock) { | ||
source = isStartOfLine[1] + source; | ||
return LIST_R.exec(source); | ||
@@ -1133,3 +1155,3 @@ } else { | ||
const itemContent = items.map(function (item, i) { | ||
// We need to see how far indented this item is: | ||
// We need to see how far indented the item is: | ||
const space = LIST_ITEM_PREFIX_R.exec(item)[0].length; | ||
@@ -1136,0 +1158,0 @@ |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "6.5.2", | ||
"version": "6.6.0", | ||
"engines": { | ||
@@ -33,7 +33,8 @@ "node": ">= 4" | ||
"babel-cli": "^6.14.0", | ||
"babel-eslint": "^8.0.3", | ||
"babel-core": "^6.26.0", | ||
"babel-eslint": "^8.2.2", | ||
"babel-jest": "^20.0.3", | ||
"babel-loader": "^7.1.1", | ||
"babel-loader": "^7.1.4", | ||
"babel-plugin-emotion": "^8.0.11", | ||
"babel-plugin-transform-react-remove-prop-types": "^0.4.6", | ||
"babel-plugin-transform-react-remove-prop-types": "^0.4.13", | ||
"babel-preset-es2015": "^6.14.0", | ||
@@ -48,3 +49,3 @@ "babel-preset-react": "^6.11.1", | ||
"jest": "^20.0.4", | ||
"jest-serializer-html": "^4.0.1", | ||
"jest-serializer-html": "^5.0.0", | ||
"polished": "^1.3.0", | ||
@@ -56,6 +57,7 @@ "preact": "^8.2.1", | ||
"react-dom": "^15.6.1", | ||
"size-limit": "^0.13.1", | ||
"uglify-js": "^2.7.3", | ||
"webpack": "^3.4.1", | ||
"webpack-dev-server": "^2.6.1" | ||
"size-limit": "^0.16.2", | ||
"uglify-js": "^3.3.15", | ||
"webpack": "^4.1.1", | ||
"webpack-cli": "^2.0.12", | ||
"webpack-dev-server": "^3.1.1" | ||
}, | ||
@@ -62,0 +64,0 @@ "dependencies": { |
# Markdown Component for React, Preact + Friends | ||
[![npm version](https://badge.fury.io/js/markdown-to-jsx.svg)](https://badge.fury.io/js/markdown-to-jsx) ![build status](https://api.travis-ci.org/probablyup/markdown-to-jsx.svg) [![codecov](https://codecov.io/gh/probablyup/markdown-to-jsx/branch/master/graph/badge.svg)](https://codecov.io/gh/probablyup/markdown-to-jsx) ![downloads](https://img.shields.io/npm/dm/markdown-to-jsx.svg) | ||
[![npm version](https://badge.fury.io/js/markdown-to-jsx.svg)](https://badge.fury.io/js/markdown-to-jsx) [![build status](https://api.travis-ci.org/probablyup/markdown-to-jsx.svg)](https://travis-ci.org/probablyup/markdown-to-jsx) [![codecov](https://codecov.io/gh/probablyup/markdown-to-jsx/branch/master/graph/badge.svg)](https://codecov.io/gh/probablyup/markdown-to-jsx) [![downloads](https://img.shields.io/npm/dm/markdown-to-jsx.svg)](https://npm-stat.com/charts.html?package=markdown-to-jsx) | ||
<!-- TOC --> | ||
- [Markdown Component for React, Preact + Friends](#markdown-component-for-react-preact-friends) | ||
- [Markdown Component for React, Preact + Friends](#markdown-component-for-react-preact--friends) | ||
- [Installation](#installation) | ||
@@ -62,4 +62,2 @@ - [Usage](#usage) | ||
const markdown = `# Hello world!`.trim(); | ||
render(( | ||
@@ -66,0 +64,0 @@ <Markdown> |
Sorry, the diff of this file is not supported yet
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
238356
3822
28
374