aboutsummaryrefslogtreecommitdiff
path: root/examples/furigana-html.ts
diff options
context:
space:
mode:
Diffstat (limited to 'examples/furigana-html.ts')
-rw-r--r--examples/furigana-html.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/furigana-html.ts b/examples/furigana-html.ts
new file mode 100644
index 0000000..5f59b4f
--- /dev/null
+++ b/examples/furigana-html.ts
@@ -0,0 +1,19 @@
+import Yomikun from "../api/yomikun.ts";
+import DirectCoreClient from "../core/direct/client.ts";
+
+// Create a direct (local) API instance
+var api = new Yomikun(new DirectCoreClient());
+
+// Excplicitly wait until everything is ready
+// await api.ready;
+
+// This sentence does not contain all information until it is explicitly
+// fetched by the user. Each subclass instantiated from an API instance keeps a
+// reference to that API instance for fetching additional data.
+var sentence = await api.sentence("日本に来て一番驚いたことは自動販売機の多さだ。");
+
+// Copy the sentence verbatim but add furigana to each word's kanji
+var furigana = sentence.furigana({ format: "HTML" });
+
+console.log(furigana);
+