api cleanup for before / after rules

This commit is contained in:
Sam 2017-07-21 16:09:27 -04:00
parent bb35d9fc07
commit 9b4f5710e6
3 changed files with 9 additions and 8 deletions

View File

@ -192,7 +192,7 @@ function applyBBCode(state, startLine, endLine, silent, md) {
} else {
if (rule.before) {
rule.before.call(this, state, info.attrs, md, state.src.slice(initial, initial + info.length + 1));
rule.before.call(this, state, info, state.src.slice(initial, initial + info.length + 1));
}
let wrapTag;
@ -235,7 +235,7 @@ function applyBBCode(state, startLine, endLine, silent, md) {
}
if (rule.after) {
rule.after.call(this, state, lastToken, md, state.src.slice(start-2, start + closeTag.length - 1));
rule.after.call(this, state, lastToken, state.src.slice(start-2, start + closeTag.length - 1));
}
}

View File

@ -3,9 +3,10 @@ import { performEmojiUnescape } from 'pretty-text/emoji';
const rule = {
tag: 'quote',
before: function(state, attrs, md) {
before: function(state, tagInfo) {
let options = md.options.discourse;
const attrs = tagInfo.attrs;
let options = state.md.options.discourse;
let quoteInfo = attrs['_default'];
let username, postNumber, topicId, avatarImg, full;

View File

@ -95,14 +95,14 @@ function invalidPoll(state, tag) {
const rule = {
tag: 'poll',
before: function(state, attrs, md, raw){
before: function(state, tagInfo, raw){
let token = state.push('text', '', 0);
token.content = raw;
token.bbcode_attrs = attrs;
token.bbcode_attrs = tagInfo.attrs;
token.bbcode_type = 'poll_open';
},
after: function(state, openToken, md, raw) {
after: function(state, openToken, raw) {
let items = getListItems(state.tokens, openToken);
if (!items) {
@ -153,7 +153,7 @@ const rule = {
if (attrs["type"] === "number") {
// default values
if (isNaN(min)) { min = 1; }
if (isNaN(max)) { max = md.options.discourse.pollMaximumOptions; }
if (isNaN(max)) { max = state.md.options.discourse.pollMaximumOptions; }
if (isNaN(step)) { step = 1; }
if (items.length > 0) {