mirror of
https://github.com/marktext/marktext.git
synced 2025-05-03 00:01:19 +08:00
Update index.js
This commit is contained in:
parent
f09b1bda77
commit
c59b3ad423
@ -12,7 +12,7 @@ export const getUniqueId = () => {
|
|||||||
export const getRecommendTitleFromMarkdownString = markdown => {
|
export const getRecommendTitleFromMarkdownString = markdown => {
|
||||||
// NOTE: We should read the title from the renderer cache because this regex matches in
|
// NOTE: We should read the title from the renderer cache because this regex matches in
|
||||||
// code blocks too.
|
// code blocks too.
|
||||||
const tokens = markdown.match(/#{1,6} {1,}(.*\S.*)(?:\n|$)/g)
|
const tokens = markdown.match(/#{1,6} {1,}(?! )(.*\S.*)(?:\n|$)/g)
|
||||||
if (!tokens) return ''
|
if (!tokens) return ''
|
||||||
const headers = tokens.map(t => {
|
const headers = tokens.map(t => {
|
||||||
const matches = t.trim().match(/(#{1,6}) {1,}(.+)/)
|
const matches = t.trim().match(/(#{1,6}) {1,}(.+)/)
|
||||||
|
Loading…
Reference in New Issue
Block a user