Link worktree file paths in Markdown to the Files tab
This commit is contained in:
@@ -85,7 +85,7 @@ private let quote = Re(#"^\s*>\s?(.*)$"#)
|
||||
private let rule = Re(#"^\s*([-*_])(\s*\1){2,}\s*$"#)
|
||||
private let imageOnly = Re(#"^\s*!\[[^\]]*\]\((<[^>]*>|[^)]*)\)\s*$"#)
|
||||
private let tableSep = Re(#"^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$"#)
|
||||
private let inlineToken = Re(#"`([^`]+)`|\*\*(.+?)\*\*|__(.+?)__|\*([^*\s][^*]*?)\*|(?<![A-Za-z0-9_])_([^_\s][^_]*?)_(?![A-Za-z0-9_])|!\[([^\]]*)\]\((?:<([^>]+)>|([^)]+))\)|\[([^\]]+)\]\(([^)\s]+)\)|(https?://[^\s<>()]+[^\s<>().,;:!?'"])"#)
|
||||
private let inlineToken = Re(#"`([^`]+)`|\*\*(.+?)\*\*|__(.+?)__|\*([^*\s][^*]*?)\*|(?<![A-Za-z0-9_])_([^_\s][^_]*?)_(?![A-Za-z0-9_])|!\[([^\]]*)\]\((?:<([^>]+)>|([^)]+))\)|\[([^\]]+)\]\((?:<([^>]+)>|([^)\s]+))\)|(https?://[^\s<>()]+[^\s<>().,;:!?'"])"#)
|
||||
|
||||
func parseMarkdown(_ src: String, choices: Bool = false) -> [MDBlock] {
|
||||
let text = src.replacingOccurrences(of: "\r\n", with: "\n").replacingOccurrences(of: "\r", with: "\n")
|
||||
@@ -359,8 +359,8 @@ private func spans(_ src: String) -> [MDInline] {
|
||||
} else if let alt = g[6] {
|
||||
out.append(.image(src: trimmed(g[7] ?? g[8]!), alt: alt))
|
||||
} else if let text = g[9] {
|
||||
out.append(.link(href: g[10]!, spans(text)))
|
||||
} else if let bare = g[11] {
|
||||
out.append(.link(href: g[10] ?? g[11]!, spans(text)))
|
||||
} else if let bare = g[12] {
|
||||
out.append(.link(href: bare, [.text(bare)]))
|
||||
}
|
||||
rest = String(rest[range.upperBound...])
|
||||
|
||||
Reference in New Issue
Block a user