fix: #277 inline math and typo (#278)

* fix: #277 inline math

* fix typo
This commit is contained in:
Felix Häusler 2018-05-18 17:59:28 +02:00 committed by 冉四夕
parent 7c891f5fbc
commit b3cd4661ba
7 changed files with 13 additions and 13 deletions

View File

@ -1,6 +1,6 @@
import { CLASS_OR_ID } from '../../../config'
import { tokenizer } from '../../parse'
import { snackToCamel } from '../../../utils'
import { snakeToCamel } from '../../../utils'
import { h, htmlToVNode } from '../snabbdom'
const PRE_BLOCK_HASH = {
@ -28,7 +28,7 @@ export default function renderLeafBlock (block, cursor, activeBlocks, matches, u
tokens = tokenizer(text, highlights)
if (highlights.length === 0 && useCache) this.tokenCache.set(text, tokens)
}
children = tokens.reduce((acc, token) => [...acc, ...this[snackToCamel(token.type)](h, cursor, block, token)], [])
children = tokens.reduce((acc, token) => [...acc, ...this[snakeToCamel(token.type)](h, cursor, block, token)], [])
}
if (/th|td/.test(type) && align) {

View File

@ -1,5 +1,5 @@
import { CLASS_OR_ID } from '../../../config'
import { snackToCamel } from '../../../utils'
import { snakeToCamel } from '../../../utils'
// `a_link`: `<a href="url">anchor</a>`
export default function aLink (h, cursor, block, token, outerClass) {
@ -8,7 +8,7 @@ export default function aLink (h, cursor, block, token, outerClass) {
const { start, end } = token.range
const openTag = this.highlight(h, block, start, start + token.openTag.length, token)
const anchor = token.children.reduce((acc, to) => {
const chunk = this[snackToCamel(to.type)](h, cursor, block, to, className)
const chunk = this[snakeToCamel(to.type)](h, cursor, block, to, className)
return Array.isArray(chunk) ? [...acc, ...chunk] : [...acc, chunk]
}, [])
const closeTag = this.highlight(h, block, end - token.closeTag.length, end, token)

View File

@ -1,5 +1,5 @@
import { CLASS_OR_ID } from '../../../config'
import { isLengthEven, snackToCamel } from '../../../utils'
import { isLengthEven, snakeToCamel } from '../../../utils'
// render factory of `del`,`em`,`strong`
export default function delEmStrongFac (type, h, cursor, block, token, outerClass) {
@ -10,7 +10,7 @@ export default function delEmStrongFac (type, h, cursor, block, token, outerClas
const backlashStart = end - marker.length - token.backlash.length
const content = [
...token.children.reduce((acc, to) => {
const chunk = this[snackToCamel(to.type)](h, cursor, block, to, className)
const chunk = this[snakeToCamel(to.type)](h, cursor, block, to, className)
return Array.isArray(chunk) ? [...acc, ...chunk] : [...acc, chunk]
}, []),
...this.backlashInToken(h, token.backlash, className, backlashStart, token)

View File

@ -1,5 +1,5 @@
import { CLASS_OR_ID, IMAGE_EXT_REG } from '../../../config'
import { isLengthEven, getImageSrc, snackToCamel } from '../../../utils'
import { isLengthEven, getImageSrc, snakeToCamel } from '../../../utils'
// I dont want operate dom directly, is there any better method? need help!
export default function image (h, cursor, block, token, outerClass) {
@ -79,7 +79,7 @@ export default function image (h, cursor, block, token, outerClass) {
return [
...firstBracketContent,
...token.children.reduce((acc, to) => {
const chunk = this[snackToCamel(to.type)](h, cursor, block, to, className)
const chunk = this[snakeToCamel(to.type)](h, cursor, block, to, className)
return Array.isArray(chunk) ? [...acc, ...chunk] : [...acc, chunk]
}, []),
...this.backlashInToken(h, token.backlash.first, className, firstBacklashStart, token),

View File

@ -1,3 +1,3 @@
export default function inlineMath (h, cursor, block, token, outerClass) {
return this['display_math'](h, cursor, block, token, outerClass)
return this.displayMath(h, cursor, block, token, outerClass)
}

View File

@ -1,5 +1,5 @@
import { CLASS_OR_ID } from '../../../config'
import { isLengthEven, snackToCamel } from '../../../utils'
import { isLengthEven, snakeToCamel } from '../../../utils'
// 'link': /^(\[)((?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*?)(\\*)\]\((.*?)(\\*)\)/, // can nest
export default function link (h, cursor, block, token, outerClass) {
@ -55,7 +55,7 @@ export default function link (h, cursor, block, token, outerClass) {
}
}, [
...token.children.reduce((acc, to) => {
const chunk = this[snackToCamel(to.type)](h, cursor, block, to, className)
const chunk = this[snakeToCamel(to.type)](h, cursor, block, to, className)
return Array.isArray(chunk) ? [...acc, ...chunk] : [...acc, chunk]
}, []),
...this.backlashInToken(h, token.backlash.first, className, firstBacklashStart, token)
@ -72,7 +72,7 @@ export default function link (h, cursor, block, token, outerClass) {
return [
...firstBracket,
...token.children.reduce((acc, to) => {
const chunk = this[snackToCamel(to.type)](h, cursor, block, to, className)
const chunk = this[snakeToCamel(to.type)](h, cursor, block, to, className)
return Array.isArray(chunk) ? [...acc, ...chunk] : [...acc, chunk]
}, []),
...this.backlashInToken(h, token.backlash.first, className, firstBacklashStart, token),

View File

@ -17,7 +17,7 @@ export const isEven = number => Math.abs(number) % 2 === 0
export const isLengthEven = (str = '') => str.length % 2 === 0
export const snackToCamel = name => name.replace(/_([a-z])/g, (p0, p1) => p1.toUpperCase())
export const snakeToCamel = name => name.replace(/_([a-z])/g, (p0, p1) => p1.toUpperCase())
/**
* Are two arrays have intersection
*/