aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorache <ache@ache.one>2018-10-23 03:26:11 +0200
committerache <ache@ache.one>2018-10-23 03:26:11 +0200
commitea33616b5c7ef9332af3689d97a3f4d1900a2c77 (patch)
tree8d1371295baae449f660bb42676a76f8868d3f17 /src
parentMerge branch 'master' of github.com:arobase-che/remark-attr (diff)
Compatibility with upcomping version of remark-parse
Diffstat (limited to 'src')
-rw-r--r--src/dom-event-handler.js2
-rw-r--r--src/index.js42
2 files changed, 12 insertions, 32 deletions
diff --git a/src/dom-event-handler.js b/src/dom-event-handler.js
index dc4f3bd..d559e91 100644
--- a/src/dom-event-handler.js
+++ b/src/dom-event-handler.js
@@ -1,6 +1,6 @@
'use strict';
-module.export = [
+module.exports = [
'onabort',
'onautocomplete',
'onautocompleteerror',
diff --git a/src/index.js b/src/index.js
index 49ee990..2e839e8 100644
--- a/src/index.js
+++ b/src/index.js
@@ -159,6 +159,8 @@ function filterAttributes(prop, config, type) {
/* This is a special modification of the function tokenizeGenerator
* to parse the fencedCode info string and the fallback
* customAttr parser
+ *
+ * It's only temporary
*/
function tokenizeFencedCode(oldParser, config) {
const prefix = '\n';
@@ -167,10 +169,8 @@ function tokenizeFencedCode(oldParser, config) {
const self = this;
let eaten = oldParser.call(self, eat, value, silent);
- let index = 0;
let parsedAttr;
- let parsedByCustomAttr = false;
- const {length} = value;
+ const parsedByCustomAttr = false;
if (!eaten || !eaten.position) {
return undefined;
@@ -182,37 +182,17 @@ function tokenizeFencedCode(oldParser, config) {
// which is the 'lang' attributes of 'eaten'.
if (eaten.lang) {
- let infoPart = '';
- if (eaten.lang.indexOf(' ') >= 0) {
- if (eaten.lang.indexOf('{') >= 0) {
- const posStart = Math.min(eaten.lang.indexOf(' '), eaten.lang.indexOf('{'));
- infoPart = eaten.lang.substr(posStart);
-
- if (posStart === eaten.lang.indexOf('{')) {
- eaten.lang = eaten.lang.substr(0, eaten.lang.indexOf('{')) + ' ' + infoPart;
- }
- } else {
- infoPart = eaten.lang.substr(eaten.lang.indexOf(' '));
- }
- } else if (eaten.lang.indexOf('{') >= 0) {
- infoPart = eaten.lang.substr(eaten.lang.indexOf('{'));
- eaten.lang = eaten.lang.substr(0, eaten.lang.indexOf('{')) + ' ' + infoPart;
- }
-
- if (infoPart) {
- parsedAttr = parseAttr(infoPart, 0, config.mdAttrConfig);
+ // Then the meta
+ if (eaten.meta) {
+ parsedAttr = parseAttr(eaten.meta);
+ } else {
+ // If it's an old version, we can still find from the attributes
+ // from 'value' ¯\_(ツ)_/¯
+ // Bad hack, will be deleted soon
+ parsedAttr = parseAttr(value, value.indexOf(' '));
}
}
- index = eaten.position.end.offset - eaten.position.start.offset;
-
- // Then we check for attributes
- if (index + prefix.length < length && value.charAt(index + prefix.length) === '{') {
- // If any, parse it
- parsedAttr = {...parsedAttr, ...parseAttr(value, index + prefix.length, config.mdAttrConfig)};
- parsedByCustomAttr = Boolean(parsedAttr);
- }
-
// If parsed configure the node
if (parsedAttr) {
if (config.scope && config.scope !== 'none') {