chore: fmt

This commit is contained in:
Brooklyn Nicholson 2026-04-12 16:33:25 -05:00
parent 4b026d6761
commit e03bef684e
5 changed files with 50 additions and 33 deletions

View file

@ -10,11 +10,11 @@ const FOOTNOTE_RE = /^\[\^([^\]]+)\]:\s*(.*)$/
const DEF_RE = /^\s*:\s+(.+)$/
const TABLE_DIVIDER_CELL_RE = /^:?-{3,}:?$/
const MD_URL_RE = '((?:[^\\s()]|\\([^\\s()]*\\))+?)'
const INLINE_RE =
new RegExp(
`(!\\[(.*?)\\]\\(${MD_URL_RE}\\)|\\[(.+?)\\]\\(${MD_URL_RE}\\)|<((?:https?:\\/\\/|mailto:)[^>\\s]+|[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,})>|~~(.+?)~~|\`([^\\\`]+)\`|\\*\\*(.+?)\\*\\*|__(.+?)__|\\*(.+?)\\*|_(.+?)_|==(.+?)==|\\[\\^([^\\]]+)\\]|\\^([^^\\s][^^]*?)\\^|~([^~\\s][^~]*?)~|(https?:\\/\\/[^\\s<]+))`,
'g'
)
const INLINE_RE = new RegExp(
`(!\\[(.*?)\\]\\(${MD_URL_RE}\\)|\\[(.+?)\\]\\(${MD_URL_RE}\\)|<((?:https?:\\/\\/|mailto:)[^>\\s]+|[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,})>|~~(.+?)~~|\`([^\\\`]+)\`|\\*\\*(.+?)\\*\\*|__(.+?)__|\\*(.+?)\\*|_(.+?)_|==(.+?)==|\\[\\^([^\\]]+)\\]|\\^([^^\\s][^^]*?)\\^|~([^~\\s][^~]*?)~|(https?:\\/\\/[^\\s<]+))`,
'g'
)
type Fence = {
char: '`' | '~'
@ -171,11 +171,7 @@ function MdInline({ t, text }: { t: Theme; text: string }) {
parts.push(renderAutolink(parts.length, t, url))
if (tail) {
parts.push(
<Text key={parts.length}>
{tail}
</Text>
)
parts.push(<Text key={parts.length}>{tail}</Text>)
}
}
@ -193,16 +189,8 @@ export function Md({ compact, t, text }: { compact?: boolean; t: Theme; text: st
const lines = text.split('\n')
const nodes: ReactNode[] = []
let i = 0
let prevKind:
| 'blank'
| 'code'
| 'heading'
| 'list'
| 'paragraph'
| 'quote'
| 'rule'
| 'table'
| null = null
let prevKind: 'blank' | 'code' | 'heading' | 'list' | 'paragraph' | 'quote' | 'rule' | 'table' | null = null
const gap = () => {
if (nodes.length && prevKind !== 'blank') {
@ -400,7 +388,7 @@ export function Md({ compact, t, text }: { compact?: boolean; t: Theme; text: st
nodes.push(
<Text key={`${key}-def-${i}`}>
<Text color={t.color.dim}> · </Text>
<Text color={t.color.dim}> · </Text>
<MdInline t={t} text={def[1]!} />
</Text>
)

View file

@ -2,6 +2,7 @@ import { Box, Text } from '@hermes/ink'
import { useState } from 'react'
import type { Theme } from '../theme.js'
import { TextInput } from './textInput.js'
export function MaskedPrompt({

View file

@ -3,6 +3,7 @@ import { useState } from 'react'
import type { Theme } from '../theme.js'
import type { ApprovalReq, ClarifyReq } from '../types.js'
import { TextInput } from './textInput.js'
export function ApprovalPrompt({ onChoice, req, t }: { onChoice: (s: string) => void; req: ApprovalReq; t: Theme }) {
@ -88,20 +89,31 @@ export function ClarifyPrompt({
useInput((ch, key) => {
if (key.escape) {
typing && choices.length ? setTyping(false) : onCancel()
return
}
if (typing) return
if (typing) {
return
}
if (key.upArrow && sel > 0) setSel(s => s - 1)
if (key.downArrow && sel < choices.length) setSel(s => s + 1)
if (key.upArrow && sel > 0) {
setSel(s => s - 1)
}
if (key.downArrow && sel < choices.length) {
setSel(s => s + 1)
}
if (key.return) {
sel === choices.length ? setTyping(true) : choices[sel] && onAnswer(choices[sel]!)
}
const n = parseInt(ch)
if (n >= 1 && n <= choices.length) onAnswer(choices[n - 1]!)
if (n >= 1 && n <= choices.length) {
onAnswer(choices[n - 1]!)
}
})
if (typing || !choices.length) {
@ -126,7 +138,9 @@ export function ClarifyPrompt({
{[...choices, 'Other (type your answer)'].map((c, i) => (
<Text key={i}>
<Text color={sel === i ? t.color.label : t.color.dim}>{sel === i ? '▸ ' : ' '}</Text>
<Text color={sel === i ? t.color.cornsilk : t.color.dim}>{i + 1}. {c}</Text>
<Text color={sel === i ? t.color.cornsilk : t.color.dim}>
{i + 1}. {c}
</Text>
</Text>
))}