mirror of
https://github.com/marktext/marktext.git
synced 2025-05-20 02:40:28 +08:00
* fix: #277 inline math * fix typo
This commit is contained in:
parent
7c891f5fbc
commit
b3cd4661ba
@ -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) {
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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),
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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),
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user