Extract all markdown links from the given lines. Return list of MarkdownLinkInfo, where each dict contains: - `line_no` - line number (1-based) - `url` - link URL - `text` - link text - `title` - link title (if any)
(lines: list[str])
| 250 | |
| 251 | |
| 252 | def extract_markdown_links(lines: list[str]) -> list[MarkdownLinkInfo]: |
| 253 | """ |
| 254 | Extract all markdown links from the given lines. |
| 255 | |
| 256 | Return list of MarkdownLinkInfo, where each dict contains: |
| 257 | - `line_no` - line number (1-based) |
| 258 | - `url` - link URL |
| 259 | - `text` - link text |
| 260 | - `title` - link title (if any) |
| 261 | """ |
| 262 | |
| 263 | links: list[MarkdownLinkInfo] = [] |
| 264 | for line_no, line in enumerate(lines, start=1): |
| 265 | for m in MARKDOWN_LINK_RE.finditer(line): |
| 266 | links.append( |
| 267 | MarkdownLinkInfo( |
| 268 | line_no=line_no, |
| 269 | url=m.group("url"), |
| 270 | text=m.group("text"), |
| 271 | title=m.group("title"), |
| 272 | attributes=m.group("attrs"), |
| 273 | full_match=m.group(0), |
| 274 | ) |
| 275 | ) |
| 276 | return links |
| 277 | |
| 278 | |
| 279 | def _add_lang_code_to_url(url: str, lang_code: str) -> str: |
no test coverage detected