UP Talk Code
parent
6670a4a256
commit
8c1a3dd00d
|
@ -18,6 +18,7 @@
|
|||
imgs = content.match(/!\[.*\]\(.*?\)/g),
|
||||
musics = content.match(/{\s*music\s*(.*)\s*}/g),
|
||||
videos = content.match(/{\s*bilibili\s*(.*)\s*}/g);
|
||||
codes = content.match(/```(.*)```/igs);
|
||||
if (imgs) imgs = imgs.map(item => {
|
||||
return item.replace(/!\[.*\]\((.*?)\)/, '$1')
|
||||
})
|
||||
|
@ -28,8 +29,9 @@
|
|||
else imgs.push(`${url}/o/r/${t.id}/${t.publicId}/${t.filename}`)
|
||||
})
|
||||
}
|
||||
content = content.replace(/#(.*?)\s/g, '').replace(/{.*}/g, '').replace(/\!\[(.*?)\]\((.*?)\)/g, '').replace(/```/g, '')
|
||||
content = content.replace(/#(.*?)\s/g, '').replace(/{.*}/g, '').replace(/\!\[(.*?)\]\((.*?)\)/g, '').replace(/```(.*)```/igs, '')
|
||||
let text = content.replace(/\[(.*?)\]\((.*?)\)/g, '[链接]').trim();
|
||||
console.log(content)
|
||||
content = content.replace(/\[(.*?)\]\((.*?)\)/g, `<a href="$2">@$1</a>`);
|
||||
if (imgs) {
|
||||
content += `<div class="zone_imgbox">`
|
||||
|
@ -42,6 +44,9 @@
|
|||
if (videos) videos.forEach(item => {
|
||||
content += `<div style="position: relative; padding: 30% 45%;margin-top: 10px;margin-bottom: 10px"><iframe style="position: absolute; width: 100%; height: 100%; left: 0; top: 0;" src="//player.bilibili.com/player.html?autoplay=0&bvid=${item.replace(/{\s*bilibili\s*(.*)\s*}/, '$1').replace(/.*video\/([^\/]*).*/, '$1')}" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"></iframe></div>`
|
||||
})
|
||||
if (codes) codes.forEach(item => {
|
||||
content +=marked(item);
|
||||
})
|
||||
return {content, date, text}
|
||||
}
|
||||
function getTime(time) {
|
||||
|
|
Loading…
Reference in New Issue