Skip to content

Support single-glossary-X-first handlebars #2309

@WilliamWickerson

Description

@WilliamWickerson

I've been using the glossary-first-brief handlebar so far to construct Anki cards, but I recently switched my primary dictionary and want to continue using my old primary dictionary to create cards. Ideally I'd be able to use like single-glossary-jmdict-2025-08-01-first-brief but that's not currently an option.

After some prototyping, the following change to glossary-first allows the expected behavior:

{{~#*inline "glossary-first"~}}
    <div style="text-align: left;" class="yomitan-glossary">
    {{~#scope~}}
        {{~#if (op "===" definition.type "term")~}}
            {{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}}
            {{~#if definition.glossaryScopedStyles~}}
                <style>{{{definition.glossaryScopedStyles}}}</style>
            {{~/if~}}
        {{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}}
            {{~set "foundFirst" false~}}
            {{~#each definition.definitions~}}
                {{~#unless (op "&&" ../selectedDictionary (op "!=" ../selectedDictionary dictionary))~}}
                    {{~#unless (get "foundFirst")~}}
                    	{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
                    	{{~#if glossaryScopedStyles~}}
                        	<style>{{{glossaryScopedStyles}}}</style>
                    	{{~/if~}}
                        {{~set "foundFirst" true~}}
                    {{~/unless~}}
                {{~/unless~}}
            {{~/each~}}
        {{~/if~}}
    {{~/scope~}}
    </div>
{{~/inline~}}

{{#*inline "single-glossary-jmdict-2025-08-01-first-brief"}}
    {{~> glossary-first selectedDictionary='JMdict [2025-08-01]' brief=true}}
{{/inline}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/enhancementThe issue or PR is a new feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions