转盘
This commit is contained in:
parent
2592f502b4
commit
cbdaf866a5
@ -76,18 +76,22 @@ router.get('/text', async (req, res, next) => {
|
|||||||
function parseText(text) {
|
function parseText(text) {
|
||||||
const result = []
|
const result = []
|
||||||
const textArr = text.split('\n')
|
const textArr = text.split('\n')
|
||||||
const textReg = /^(#+) (.*)(::)*(.*)$/
|
const textReg = /^(#+) (.*)::(.*)$/
|
||||||
let lastLevel = 0
|
let lastLevel = 0
|
||||||
let lastIdx = 0
|
let lastIdx = 0
|
||||||
const posArr = [result]
|
const posArr = [result]
|
||||||
|
|
||||||
textArr.map(item => {
|
textArr.map(item => {
|
||||||
|
if (item.indexOf('::') === -1) {
|
||||||
|
item += '::'
|
||||||
|
}
|
||||||
|
|
||||||
const execRes = textReg.exec(item)
|
const execRes = textReg.exec(item)
|
||||||
if (!execRes) return
|
if (!execRes) return
|
||||||
const curLevel = execRes[1].split('').length - 2
|
const curLevel = execRes[1].split('').length - 2
|
||||||
if (curLevel < 0) return
|
if (curLevel < 0) return
|
||||||
const text = execRes[2]
|
const text = execRes[2]
|
||||||
const content = execRes[4]
|
const content = execRes[3]
|
||||||
if (curLevel === lastLevel) {
|
if (curLevel === lastLevel) {
|
||||||
const curPos = posArr[curLevel]
|
const curPos = posArr[curLevel]
|
||||||
curPos.push({
|
curPos.push({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user