diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/japanese.ts | 11 | ||||
-rw-r--r-- | api/sentence.ts | 2 |
2 files changed, 8 insertions, 5 deletions
diff --git a/api/japanese.ts b/api/japanese.ts index 9319cdd..ffbc773 100644 --- a/api/japanese.ts +++ b/api/japanese.ts @@ -3,20 +3,23 @@ import { escape } from "https://deno.land/std@0.192.0/html/entities.ts"; import "../util/string.ts"; import "../util/japanese.ts"; import "../util/array.ts"; +import { Wrap } from "../util/wrap.ts"; const formatters = { "HTML": tokens => tokens.reduce((out, token) => { - if (token.ruby) out += `<ruby>${escape(token.writing)}<rt>${escape(token.reading)}</rt></ruby>`; - else out += token.writing; + if (token.ruby) { + out += (escape(token.writing) + + escape(token.reading).wrap(Wrap.HTML.rubyText)).wrap(Wrap.HTML.ruby); + } else out += token.writing; return out; }, ""), "parenthesis": tokens => tokens.reduce((out, token) => { - if (token.ruby) out += `${token.writing}(${token.reading}) `; + if (token.ruby) out += token.writing + token.reading.wrap(Wrap.parenthesis) + " "; else out += token.writing; return out; }, ""), "refold-tools": tokens => tokens.reduce((out, token) => { - if (token.ruby) out += `[${token.writing}](${token.reading})`; + if (token.ruby) out += token.writing.wrap(Wrap.bracket) + token.reading.wrap(Wrap.parenthesis); else out += token.writing; return out; }, ""), diff --git a/api/sentence.ts b/api/sentence.ts index d0cc434..cde66a5 100644 --- a/api/sentence.ts +++ b/api/sentence.ts @@ -1,6 +1,6 @@ import { ParseResult } from "../language/types.ts"; import APIBase from "./base.ts"; -import Japanese, { JapaneseFormatter } from "./japanese.ts"; +import { JapaneseFormatter } from "./japanese.ts"; import Word from "./word.ts"; export default class Sentence extends APIBase { |