style: format a little

pull/664/head
Kia King Ishii 3 years ago
parent 4311c749ba
commit c10c40ce44

@ -10,20 +10,23 @@ export const highlightLinePlugin = (md: MarkdownIt) => {
const [tokens, idx, options] = args const [tokens, idx, options] = args
const token = tokens[idx] const token = tokens[idx]
// due to use of markdown-it-attrs, the {0} syntax would have been converted // due to use of markdown-it-attrs, the {0} syntax would have been
// to attrs on the token // converted to attrs on the token
const attr = token.attrs && token.attrs[0] const attr = token.attrs && token.attrs[0]
let lines = null let lines = null
if (!attr) { if (!attr) {
// markdown-it-attrs maybe disabled // markdown-it-attrs maybe disabled
const rawInfo = token.info const rawInfo = token.info
if (!rawInfo || !RE.test(rawInfo)) { if (!rawInfo || !RE.test(rawInfo)) {
return fence(...args) return fence(...args)
} }
const langName = rawInfo.replace(RE, '').trim() const langName = rawInfo.replace(RE, '').trim()
// ensure the next plugin get the correct lang.
// ensure the next plugin get the correct lang
token.info = langName token.info = langName
lines = RE.exec(rawInfo)![1] lines = RE.exec(rawInfo)![1]
@ -31,6 +34,7 @@ export const highlightLinePlugin = (md: MarkdownIt) => {
if (!lines) { if (!lines) {
lines = attr![0] lines = attr![0]
if (!lines || !/[\d,-]+/.test(lines)) { if (!lines || !/[\d,-]+/.test(lines)) {
return fence(...args) return fence(...args)
} }
@ -45,6 +49,7 @@ export const highlightLinePlugin = (md: MarkdownIt) => {
: token.content : token.content
const rawCode = code.replace(wrapperRE, '') const rawCode = code.replace(wrapperRE, '')
const highlightLinesCode = rawCode const highlightLinesCode = rawCode
.split('\n') .split('\n')
.map((split, index) => { .map((split, index) => {

Loading…
Cancel
Save