Last active
January 31, 2023 21:53
-
-
Save cademcniven/dde2597e759ab2c9ab17a4deac673f33 to your computer and use it in GitHub Desktop.
Yomichan handlebars for use with Eminent Note Type V2.4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{#*inline "glossary-single"}} | |
{{~#unless brief~}} | |
{{~#scope~}} | |
{{~#set "any" false}}{{/set~}} | |
{{~#each definitionTags~}} | |
{{~#if (op "||" (op "!" @root.compactTags) (op "!" redundant))~}} | |
{{~#if (get "any")}}, {{else}}<i>({{/if~}} | |
{{name}} | |
{{~#set "any" true}}{{/set~}} | |
{{~/if~}} | |
{{~/each~}} | |
{{~#unless noDictionaryTag~}} | |
{{~#if (op "||" (op "!" @root.compactTags) (op "!==" dictionary (get "previousDictionary")))~}} | |
{{~#if (get "any")}}, {{else}}<i>({{/if~}} | |
{{dictionary}} | |
{{~#set "any" true}}{{/set~}} | |
{{~/if~}} | |
{{~/unless~}} | |
{{~#if (get "any")}})</i> {{/if~}} | |
{{~/scope~}} | |
{{~#if only~}}({{#each only}}{{.}}{{#unless @last}}, {{/unless}}{{/each}} only) {{/if~}} | |
{{~/unless~}} | |
{{~#if (op "<=" glossary.length 1)~}} | |
{{#each glossary}}{{#formatGlossary ../dictionary}}{{{.}}}{{/formatGlossary}}{{/each}} | |
{{~else if @root.compactGlossaries~}} | |
{{#each glossary}}{{#formatGlossary ../dictionary}}{{{.}}}{{/formatGlossary}}{{#unless @last}} | {{/unless}}{{/each}} | |
{{~else~}} | |
<ul>{{#each glossary}}<li>{{#formatGlossary ../dictionary}}{{{.}}}{{/formatGlossary}}</li>{{/each}}</ul> | |
{{~/if~}} | |
{{~#set "previousDictionary" dictionary~}}{{~/set~}} | |
{{/inline}} | |
{{#*inline "audio"}} | |
{{~#if (hasMedia "audio")~}} | |
[sound:{{#getMedia "audio"}}{{/getMedia}}] | |
{{~/if~}} | |
{{/inline}} | |
{{#*inline "character"}} | |
{{~definition.character~}} | |
{{/inline}} | |
{{#*inline "dictionary"}} | |
{{~definition.dictionary~}} | |
{{/inline}} | |
{{#*inline "expression"}} | |
{{~#if merge~}} | |
{{~#if modeTermKana~}} | |
{{~#each definition.reading~}} | |
{{{.}}} | |
{{~#unless @last}}、{{/unless~}} | |
{{~else~}} | |
{{~#each definition.expression~}} | |
{{{.}}} | |
{{~#unless @last}}、{{/unless~}} | |
{{~/each~}} | |
{{~/each~}} | |
{{~else~}} | |
{{~#each definition.expression~}} | |
{{{.}}} | |
{{~#unless @last}}、{{/unless~}} | |
{{~/each~}} | |
{{~/if~}} | |
{{~else~}} | |
{{~#if modeTermKana~}} | |
{{~#if definition.reading~}} | |
<span class="{{~#each (pitchCategories .)~}} | |
{{~#if @first}}{{.}}{{~/if}} | |
{{~/each~}}">{{definition.reading}}</span> | |
{{~else~}} | |
<span class="{{~#each (pitchCategories .)~}} | |
{{~#if @first}}{{.}}{{~/if}} | |
{{~/each~}}">{{definition.expression}}</span> | |
{{~/if~}} | |
{{~else~}} | |
<span class="{{~#each (pitchCategories .)~}} | |
{{~#if @first}}{{.}}{{~/if}} | |
{{~/each~}}">{{definition.expression}}</span> | |
{{~/if~}} | |
{{~/if~}} | |
{{/inline}} | |
{{#*inline "furigana"}} | |
{{~#if merge~}} | |
{{~#each definition.expressions~}} | |
<span class="expression-{{termFrequency}}">{{~#furigana}}{{{.}}}{{/furigana~}}</span> | |
{{~#unless @last}}、{{/unless~}} | |
{{~/each~}} | |
{{~else~}} | |
{{#furigana}}{{{definition}}}{{/furigana}} | |
{{~/if~}} | |
{{/inline}} | |
{{#*inline "furigana-plain"}} | |
{{~#if merge~}} | |
{{~#each definition.expressions~}} | |
<span class="expression-{{termFrequency}}">{{~#furiganaPlain}}{{{.}}}{{/furiganaPlain~}}</span> | |
{{~#unless @last}}、{{/unless~}} | |
{{~/each~}} | |
{{~else~}} | |
{{#furiganaPlain}}{{{definition}}}{{/furiganaPlain}} | |
{{~/if~}} | |
{{/inline}} | |
{{~#*inline "glossary"~}} | |
<div style="text-align: left;"> | |
{{~#scope~}} | |
{{~#if (op "===" definition.type "term")~}} | |
{{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}} | |
{{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}} | |
{{~#if (op ">" definition.definitions.length 1)~}} | |
<ol>{{~#each definition.definitions~}}<li>{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}</li>{{~/each~}}</ol> | |
{{~else~}} | |
{{~#each definition.definitions~}}{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}{{~/each~}} | |
{{~/if~}} | |
{{~else if (op "===" definition.type "kanji")~}} | |
{{~#if (op ">" definition.glossary.length 1)~}} | |
<ol>{{#each definition.glossary}}<li>{{.}}</li>{{/each}}</ol> | |
{{~else~}} | |
{{~#each definition.glossary~}}{{.}}{{~/each~}} | |
{{~/if~}} | |
{{~/if~}} | |
{{~/scope~}} | |
</div> | |
{{~/inline~}} | |
{{#*inline "glossary-no-dictionary"}} | |
{{~> glossary noDictionaryTag=true ~}} | |
{{/inline}} | |
{{#*inline "glossary-brief"}} | |
{{~> glossary brief=true ~}} | |
{{/inline}} | |
{{#*inline "kunyomi"}} | |
{{~#each definition.kunyomi}}{{.}}{{#unless @last}}, {{/unless}}{{/each~}} | |
{{/inline}} | |
{{#*inline "onyomi"}} | |
{{~#each definition.onyomi}}{{.}}{{#unless @last}}, {{/unless}}{{/each~}} | |
{{/inline}} | |
{{#*inline "reading"}} | |
{{~#unless modeTermKana~}} | |
{{~#if merge~}} | |
{{~#each definition.reading~}} | |
{{{.}}} | |
{{~#unless @last}}、{{/unless~}} | |
{{~/each~}} | |
{{~else~}} | |
{{~definition.reading~}} | |
{{~/if~}} | |
{{~/unless~}} | |
{{/inline}} | |
{{#*inline "sentence"}} | |
{{~#if definition.cloze}}{{definition.cloze.sentence}}{{/if~}} | |
{{/inline}} | |
{{#*inline "cloze-prefix"}} | |
{{~#if definition.cloze}} | |
{{#regexReplace "((.*)| \(.*\)| *|\s+)*" "" "g"}} {{definition.cloze.prefix}}{{/regexReplace}} | |
{{/if~}} | |
{{/inline}} | |
{{#*inline "cloze-body"}} | |
{{~#if definition.cloze}}{{definition.cloze.body}}{{/if~}} | |
{{/inline}} | |
{{#*inline "cloze-suffix"}} | |
{{~#if definition.cloze}} | |
{{#regexReplace "((.*)| \(.*\)| *|\s+)*" "" "g"}} {{definition.cloze.suffix}}{{/regexReplace}} | |
{{/if~}} | |
{{/inline}} | |
{{#*inline "tags"}} | |
{{~#mergeTags definition group merge}}{{this}}{{/mergeTags~}} | |
{{/inline}} | |
{{#*inline "url"}} | |
<a href="{{definition.url}}">{{definition.url}}</a> | |
{{/inline}} | |
{{#*inline "screenshot"}} | |
{{~#if (hasMedia "screenshot")~}} | |
<img src="{{#getMedia "screenshot"}}{{/getMedia}}" /> | |
{{~/if~}} | |
{{/inline}} | |
{{#*inline "document-title"}} | |
{{~context.document.title~}} | |
{{/inline}} | |
{{! Pitch Accents }} | |
{{#*inline "pitch-accent-item"}} | |
{{~#pronunciation format=format reading=reading downstepPosition=position nasalPositions=nasalPositions devoicePositions=devoicePositions~}}{{~/pronunciation~}} | |
{{/inline}} | |
{{#*inline "pitch-accent-item-disambiguation"}} | |
{{~#scope~}} | |
{{~#set "exclusive" (spread exclusiveExpressions exclusiveReadings)}}{{/set~}} | |
{{~#if (op ">" (property (get "exclusive") "length") 0)~}} | |
{{~#set "separator" ""~}}{{/set~}} | |
<em>({{#each (get "exclusive")~}} | |
{{~#get "separator"}}{{/get~}}{{{.}}} | |
{{~/each}} only) </em> | |
{{~/if~}} | |
{{~/scope~}} | |
{{/inline}} | |
{{#*inline "pitch-accent-list"}} | |
{{~#if (op ">" pitchCount 0)~}} | |
{{~#if (op ">" pitchCount 1)~}}<ol>{{~/if~}} | |
{{~#each pitches~}} | |
{{~#each pitches~}} | |
{{~#if (op ">" ../../pitchCount 1)~}}<li>{{~/if~}} | |
{{~> pitch-accent-item-disambiguation~}} | |
{{~> pitch-accent-item format=../../format~}} | |
{{~#if (op ">" ../../pitchCount 1)~}}</li>{{~/if~}} | |
{{~/each~}} | |
{{~/each~}} | |
{{~#if (op ">" pitchCount 1)~}}</ol>{{~/if~}} | |
{{~else~}} | |
{{~definition.reading~}} | |
{{~/if~}} | |
{{/inline}} | |
{{#*inline "pitch-accents"}} | |
{{~> pitch-accent-list format='text'~}} | |
{{/inline}} | |
{{#*inline "pitch-accent-graphs"}} | |
{{~> pitch-accent-list format='graph'~}} | |
{{/inline}} | |
{{#*inline "pitch-accent-positions"}} | |
{{~> pitch-accent-list format='position'~}} | |
{{/inline}} | |
{{! End Pitch Accents }} | |
{{#*inline "clipboard-image"}} | |
{{~#if (hasMedia "clipboardImage")~}} | |
<img src="{{#getMedia "clipboardImage"}}{{/getMedia}}" /> | |
{{~/if~}} | |
{{/inline}} | |
{{#*inline "clipboard-text"}} | |
{{~#if (hasMedia "clipboardText")}}{{#getMedia "clipboardText"}}{{/getMedia}}{{/if~}} | |
{{/inline}} | |
{{#*inline "conjugation"}} | |
{{~#if definition.reasons~}} | |
{{~#each definition.reasons~}} | |
{{~#if (op ">" @index 0)}} « {{/if~}} | |
{{.}} | |
{{~/each~}} | |
{{~/if~}} | |
{{/inline}} | |
{{#*inline "frequencies"}} | |
{{~#if (op ">" definition.frequencies.length 0)~}} | |
<ul style="text-align: left;"> | |
{{~#each definition.frequencies~}} | |
<li> | |
{{~#if (op "!==" ../definition.type "kanji")~}} | |
{{~#if (op "||" (op ">" ../uniqueExpressions.length 1) (op ">" ../uniqueReadings.length 1))~}}( | |
{{~#furigana expression reading~}}{{~/furigana~}} | |
) {{/if~}} | |
{{~/if~}} | |
{{~dictionary}}: {{frequency~}} | |
</li> | |
{{~/each~}} | |
</ul> | |
{{~/if~}} | |
{{/inline}} | |
{{#*inline "freq"}} | |
{{~! Frequency sorting from https://github.com/MarvNC/JP-Resources ~}} | |
{{~! v23.01.31.2 ~}} | |
{{~#scope~}} | |
{{~! Options ~}} | |
{{~#set "opt-ignored-freq-dict-regex"~}} ^(JLPT_Level)$ {{~/set~}} | |
{{~set "opt-no-freq-default-value" 999999 ~}} | |
{{~set "opt-freq-sorting-method" "min" ~}} {{~! "min", "first", "avg", "harmonic" ~}} | |
{{~! End of options ~}} | |
{{~! Do not change the code below unless you know what you are doing. ~}} | |
{{~set "result-freq" -1 ~}} {{~! -1 is chosen because no frequency dictionaries should have an entry as -1 ~}} | |
{{~set "t" 1 ~}} | |
{{~#each definition.frequencies~}} | |
{{~! rx-match-ignored-freq is not empty if ignored <=> rx-match-ignored-freq is empty if not ignored ~}} | |
{{~#set "rx-match-ignored-freq" ~}} | |
{{~#regexMatch (get "opt-ignored-freq-dict-regex") "gu"~}}{{this.dictionary}}{{~/regexMatch~}} | |
{{/set~}} | |
{{~#if (op "===" (get "rx-match-ignored-freq") "") ~}} | |
{{~#if (op "===" (get "opt-freq-sorting-method") "min") ~}} | |
{{~#if | |
(op "||" | |
(op "===" (get "result-freq") -1) | |
(op ">" (op "+" (get "result-freq")) (op "+" (regexMatch "\d" "g" this.frequency))) | |
) | |
~}} | |
{{~set "result-freq" (op "+" (regexMatch "\d" "g" this.frequency)) ~}} | |
{{~/if~}} | |
{{~else if (op "===" (get "opt-freq-sorting-method") "first") ~}} | |
{{~#if (op "===" (get "result-freq") -1) ~}} | |
{{~set "result-freq" (op "+" (regexMatch "\d" "g" this.frequency)) ~}} | |
{{~/if~}} | |
{{~else if (op "===" (get "opt-freq-sorting-method") "avg") ~}} | |
{{~#if (op "===" (get "result-freq") -1) ~}} | |
{{~set "result-freq" (op "+" (regexMatch "\d" "g" this.frequency)) ~}} | |
{{~else~}} | |
{{~! iterative mean formula: $S_{(t+1)} = S_t + \frac{1}{t+1} (x - S_t)$ ~}} | |
{{~set "result-freq" | |
(op "+" | |
(get "result-freq") | |
(op "/" | |
(op "-" | |
(op "+" (regexMatch "\d" "g" this.frequency)) | |
(get "result-freq") | |
) | |
(get "t") | |
) | |
) | |
}} | |
{{~/if~}} | |
{{~set "t" (op "+" (get "t") 1) ~}} | |
{{~else if (op "===" (get "opt-freq-sorting-method") "harmonic") ~}} | |
{{~#if (op ">" (op "+" (regexMatch "\d" "g" this.frequency)) 0) ~}} {{~! ensures only positive numbers are used ~}} | |
{{~#if (op "===" (get "result-freq") -1) ~}} | |
{{~set "result-freq" (op "/" 1 (op "+" (regexMatch "\d" "g" this.frequency))) ~}} | |
{{~else ~}} | |
{{~set "result-freq" | |
(op "+" | |
(get "result-freq") | |
(op "/" 1 (op "+" (regexMatch "\d" "g" this.frequency))) | |
) | |
}} | |
{{~set "t" (op "+" (get "t") 1) ~}} | |
{{~/if~}} | |
{{~/if~}} | |
{{~else~}} | |
(INVALID opt-freq-sorting-method value) | |
{{~/if~}} | |
{{~/if~}} | |
{{~/each~}} | |
{{~#if (op "===" (get "result-freq") -1) ~}} | |
{{~set "result-freq" (get "opt-no-freq-default-value") ~}} | |
{{~ else if (op "===" (get "opt-freq-sorting-method") "harmonic") ~}} | |
{{~set "result-freq" | |
(op "*" | |
(op "/" 1 (get "result-freq")) | |
(get "t") | |
) | |
~}} | |
{{~/if~}} | |
{{~get "result-freq"~}} | |
{{~/scope~}} | |
{{/inline}} | |
{{#*inline "stroke-count"}} | |
{{~#scope~}} | |
{{~#set "found" false}}{{/set~}} | |
{{~#each definition.stats.misc~}} | |
{{~#if (op "===" name "strokes")~}} | |
{{~#set "found" true}}{{/set~}} | |
Stroke count: {{value}} | |
{{~/if~}} | |
{{~/each~}} | |
{{~#if (op "!" (get "found"))~}} | |
Stroke count: Unknown | |
{{~/if~}} | |
{{~/scope~}} | |
{{/inline}} | |
{{#*inline "part-of-speech-pretty"}} | |
{{~#if (op "===" . "v1")~}}Ichidan verb | |
{{~else if (op "===" . "v5")~}}Godan verb | |
{{~else if (op "===" . "vk")~}}Kuru verb | |
{{~else if (op "===" . "vs")~}}Suru verb | |
{{~else if (op "===" . "vz")~}}Zuru verb | |
{{~else if (op "===" . "adj-i")~}}I-adjective | |
{{~else if (op "===" . "n")~}}Noun | |
{{~else~}}{{.}} | |
{{~/if~}} | |
{{/inline}} | |
{{#*inline "part-of-speech"}} | |
{{~#scope~}} | |
{{~#if (op "!==" definition.type "kanji")~}} | |
{{~#set "first" true}}{{/set~}} | |
{{~#each definition.expressions~}} | |
{{~#each wordClasses~}} | |
{{~#unless (get (concat "used_" .))~}} | |
{{~> part-of-speech-pretty . ~}} | |
{{~#unless (get "first")}}, {{/unless~}} | |
{{~#set (concat "used_" .) true~}}{{~/set~}} | |
{{~#set "first" false~}}{{~/set~}} | |
{{~/unless~}} | |
{{~/each~}} | |
{{~/each~}} | |
{{~#if (get "first")~}}Unknown{{~/if~}} | |
{{~/if~}} | |
{{~/scope~}} | |
{{/inline}} | |
{{#*inline "search-query"}} | |
{{~#multiLine}}{{context.fullQuery}}{{/multiLine~}} | |
{{/inline}} | |
{{#*inline "selection-text"}} | |
{{~#if (hasMedia "selectionText")}}{{#getMedia "selectionText"}}{{/getMedia}}{{/if~}} | |
{{/inline}} | |
{{#*inline "sentence-furigana"}} | |
{{~#if definition.cloze~}} | |
{{~#if (hasMedia "textFurigana" definition.cloze.sentence)~}} | |
{{#getMedia "textFurigana" definition.cloze.sentence escape=false}}{{/getMedia}} | |
{{~else~}} | |
{{definition.cloze.sentence}} | |
{{~/if~}} | |
{{~/if~}} | |
{{/inline}} | |
{{#*inline "pitch-accent-categories"}} | |
{{~#each (pitchCategories .)~}} | |
{{~#if @first}}{{.}}{{~/if}} | |
{{~/each~}} | |
{{/inline}} | |
{{~> (lookup . "marker") ~}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment