mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
* feat(mobile): render GitHub alerts, task boxes, inline tags, images and footnotes GitHub text on the phone now draws what desktop and github.com do: > [!NOTE]-style alerts (desktop's marker rule, shared), read-only task boxes, <sub>/<sup>/<kbd>/<ins> and <b>/<i>/<del>/<code> inline tags, https <img> and Markdown images at their authored width, raised footnote numbers, and #123 links in the PR view into the PR's own repository. * fix(mobile): keep linked badges and commented images, read only pixel widths An <a href> around inline content becomes a link, so a badge keeps its target; images inside links, comments, icons by height, and percentage widths stay as before. Footnote numbers follow the text scale. * fix(mobile): keep images inside headings and styles in place, read link hrefs as HTML does Only images that a p, div, picture or center places are cut out of HTML, in one pass; an image in a heading, link or bold stays in its element. Inline <a> hrefs use the shared attribute reader (quotes and entities), <code> keeps only the text of tags inside it, and alert titles follow the text scale.
15 lines
581 B
TypeScript
15 lines
581 B
TypeScript
import type { Parent } from 'mdast'
|
|
|
|
const TASK_MARKER = /^\[([ xX])\](?:\s+|$)/
|
|
|
|
/** GitHub task list items: `[ ]` or `[x]` opening the item's first paragraph. */
|
|
export function readTaskMarker(item: Parent & { checked?: boolean | null }): void {
|
|
const paragraph = item.children[0]
|
|
const text = paragraph?.type === 'paragraph' ? paragraph.children[0] : undefined
|
|
const marker = text?.type === 'text' ? TASK_MARKER.exec(text.value) : null
|
|
if (text?.type === 'text' && marker) {
|
|
item.checked = marker[1] !== ' '
|
|
text.value = text.value.slice(marker[0].length)
|
|
}
|
|
}
|