Skip to content

Commit

Permalink
feat(xegoe): mark legacy spellings red
Browse files Browse the repository at this point in the history
  • Loading branch information
DGCK81LNN committed Apr 4, 2024
1 parent d83695e commit b8c3883
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi-plugin-xdi8",
"description": "Shidinn tools for Koishi",
"version": "1.0.0",
"version": "1.0.1",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
Expand Down
18 changes: 11 additions & 7 deletions src/plugins/xegoe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ function xhTranscribe(
return ctx.xdi8.xdi8ToHanziTranscriber.transcribe(text, { ziSeparator: " " })
}

function ruby(chars: { h: string; x: string }[], className?: string) {
const ruby = <ruby>{chars.flatMap(({ h, x }) => [h, <rt>{chatToXdPUA(x)}</rt>])}</ruby>
if (className) return <div class={className}>{ruby}</div>
return ruby
function ruby(chars: { h: string; x: string; legacy?: boolean }[], className?: string) {
const ruby = chars.flatMap(({ h, x, legacy }) => (
<ruby class={[legacy && "char-legacy"]}>
{h}
<rt>{chatToXdPUA(x)}</rt>
</ruby>
))
return <span class={className}>{ruby}</span>
}

function formatResult<T extends "h" | "x">(
Expand Down Expand Up @@ -100,7 +104,7 @@ function formatResult<T extends "h" | "x">(
{seg[0].content.map(seg => seg[sourceType]).join("")}:
<ul class="alternations">
{seg.map(alt => (
<li class={`alternation ${alt.legacy ? "alternation-legacy" : ""}`}>
<li class="alternation">
{ruby(alt.content)} <span class="note">{alt.note}</span>
</li>
))}
Expand Down Expand Up @@ -162,8 +166,8 @@ export function apply(ctx: Context, config: Config) {
margin: 0;
padding-left: 0.5em;
}
.alternation-legacy {
color: #777;
.char-legacy {
color: red;
}
.footnotes-only ruby {
font-size: 1.333333em;
Expand Down

0 comments on commit b8c3883

Please sign in to comment.