| 1 | <script lang="ts"> |
| 2 | import EmojiText from './EmojiText.svelte'; |
| 3 | import { hasCode, parseCode } from './code'; |
| 4 | |
| 5 | export let text: string; |
| 6 | export let jumbo = false; |
| 7 | |
| 8 | $: segments = parseCode(text); |
| 9 | $: plain = !hasCode(segments); |
| 10 | </script> |
| 11 | |
| 12 | {#if plain}<EmojiText {text} {jumbo} />{:else}{#each segments as s}{#if s.kind === 'inline'}<code class="inline">{s.text}</code>{:else if s.kind === 'block'}<pre class="block"><code>{s.text}</code></pre>{:else}<EmojiText text={s.text} />{/if}{/each}{/if} |
| 13 | |
| 14 | <style> |
| 15 | code { |
| 16 | font-family: ui-monospace, 'JetBrains Mono', 'Fira Code', Menlo, monospace; |
| 17 | font-size: 0.9em; |
| 18 | } |
| 19 | .inline { |
| 20 | padding: 1px 5px; |
| 21 | border-radius: 4px; |
| 22 | background: var(--bg-soft); |
| 23 | border: 1px solid var(--border); |
| 24 | } |
| 25 | .block { |
| 26 | margin: 4px 0; |
| 27 | padding: 8px 10px; |
| 28 | border-radius: 6px; |
| 29 | background: var(--bg-soft); |
| 30 | border: 1px solid var(--border); |
| 31 | overflow-x: auto; |
| 32 | white-space: pre; |
| 33 | line-height: 1.4; |
| 34 | } |
| 35 | </style> |