Skip to content

Commit a1ee943

Browse files
committed
(clean) remove unecessary markdown logic
1 parent 21536b5 commit a1ee943

File tree

1 file changed

+1
-57
lines changed

1 file changed

+1
-57
lines changed

src/utils/formatString.js

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ export default (text, doLinkify) => {
55

66
const html = compileToHTML(json)
77

8-
const flatten = flattenResult(html)
9-
10-
const result = [].concat.apply([], flatten)
11-
12-
markdownResult(result)
8+
const result = [].concat.apply([], html)
139

1410
if (doLinkify) linkifyResult(result)
1511

@@ -188,58 +184,6 @@ function parseContent(item) {
188184
return result
189185
}
190186

191-
function flattenResult(array, types = []) {
192-
const result = []
193-
194-
array.forEach(arr => {
195-
if (typeof arr.value === 'string') {
196-
arr.types = arr.types.concat(types)
197-
result.push(arr)
198-
} else {
199-
arr.forEach(a => {
200-
if (typeof a.value === 'string') {
201-
a.types = a.types.concat(types)
202-
result.push(a)
203-
} else {
204-
result.push(flattenResult(a.value, a.types))
205-
}
206-
})
207-
}
208-
})
209-
210-
return result
211-
}
212-
213-
function markdownResult(array) {
214-
for (let i = 0; i < array.length; i) {
215-
if (array[i - 1]) {
216-
const isInline =
217-
array[i].types.indexOf('inline-code') !== -1 &&
218-
array[i - 1].types.indexOf('inline-code') !== -1
219-
220-
const isMultiline =
221-
array[i].types.indexOf('multiline-code') !== -1 &&
222-
array[i - 1].types.indexOf('multiline-code') !== -1
223-
224-
if (isInline || isMultiline) {
225-
let value = array[i].value
226-
array[i].types.forEach(type => {
227-
const markdown = typeMarkdown[type] || ''
228-
value = markdown + value + markdown
229-
})
230-
231-
array[i - 1].value = array[i - 1].value + value
232-
233-
array.splice(i, 1)
234-
} else {
235-
i++
236-
}
237-
} else {
238-
i++
239-
}
240-
}
241-
}
242-
243187
function linkifyResult(array) {
244188
const result = []
245189

0 commit comments

Comments
 (0)