Spaces:
Build error
Build error
| import { AutoCastable, Prop } from 'civkit/civ-rpc'; | |
| import {Context} from '../services/registry'; | |
| import _ from 'lodash'; | |
| export class TurnDownTweakableOptions extends AutoCastable { | |
| ({ | |
| desc: 'Turndown options > headingStyle', | |
| type: new Set(['setext', 'atx']), | |
| }) | |
| headingStyle?: 'setext' | 'atx'; | |
| ({ | |
| desc: 'Turndown options > hr', | |
| validate: (v: string) => v.length > 0 && v.length <= 128 | |
| }) | |
| hr?: string; | |
| ({ | |
| desc: 'Turndown options > bulletListMarker', | |
| type: new Set(['-', '+', '*']), | |
| }) | |
| bulletListMarker?: '-' | '+' | '*'; | |
| ({ | |
| desc: 'Turndown options > emDelimiter', | |
| type: new Set(['_', '*']), | |
| }) | |
| emDelimiter?: '_' | '*'; | |
| ({ | |
| desc: 'Turndown options > strongDelimiter', | |
| type: new Set(['__', '**']), | |
| }) | |
| strongDelimiter?: '__' | '**'; | |
| ({ | |
| desc: 'Turndown options > linkStyle', | |
| type: new Set(['inlined', 'referenced', 'discarded']), | |
| }) | |
| linkStyle?: 'inlined' | 'referenced' | 'discarded'; | |
| ({ | |
| desc: 'Turndown options > linkReferenceStyle', | |
| type: new Set(['full', 'collapsed', 'shortcut', 'discarded']), | |
| }) | |
| linkReferenceStyle?: 'full' | 'collapsed' | 'shortcut' | 'discarded'; | |
| static fromCtx(ctx: Context, prefix= 'x-md-') { | |
| const draft: Record<string, string> = {}; | |
| for (const [k, v] of Object.entries(ctx.headers)) { | |
| if (k.startsWith(prefix)) { | |
| const prop = k.slice(prefix.length); | |
| const sk = _.camelCase(prop); | |
| draft[sk] = v as string; | |
| } | |
| } | |
| return this.from(draft); | |
| } | |
| } | |