Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[object Object] for {glossary} when making anki cards through yomitan #246

Closed
Weroxig opened this issue Sep 23, 2023 · 9 comments · Fixed by #276
Closed

[object Object] for {glossary} when making anki cards through yomitan #246

Weroxig opened this issue Sep 23, 2023 · 9 comments · Fixed by #276
Labels
kind/bug The issue or PR is regarding a bug

Comments

@Weroxig
Copy link

Weroxig commented Sep 23, 2023

Description

<div style="text-align: left;">
	<ol>
		<li><i>(1, v5m, vt, JMdict Extra)</i> to read</li>
		<li><i>(1, v5m, vt, JMdict)</i> to read</li>
		<li><i>(2, JMdict Extra)</i> to recite (e.g. a sutra) | to chant</li>
		<li><i>(2, JMdict)</i> to recite (e.g. a sutra) | to chant</li>
		<li><i>(3, JMdict Extra)</i> [object Object]</li>
		<li><i>(3, JMdict)</i> [object Object]</li>
		<li><i>(4, JMdict Extra)</i> to decipher</li>
		<li><i>(4, JMdict)</i> to decipher</li>
		<li><i>(5, JMdict Extra)</i> [object Object]</li>
		<li><i>(5, JMdict)</i> [object Object]</li>
		<li><i>(6, JMdict Extra)</i> [object Object]</li>
		<li><i>(6, JMdict)</i> [object Object]</li>
	</ol>
</div>

This is {glossary} for 読め (beautified)

Browser version
Firefox nightly 119.0a1 (2023-09-20)
I also tried Firefox stable 117.0.1 (64-bit)

Yomichan version
23.8.19.0

Exported settings file
yomitan-settings-2023-09-23-06-58-13.zip

@Weroxig Weroxig added the kind/bug The issue or PR is regarding a bug label Sep 23, 2023
@dtop129
Copy link

dtop129 commented Sep 23, 2023

I have the same problem, happening only with Firefox, if I try switching to Chromium {glossary} works as expected

Using Firefox 117.0.1

@jarmanso7
Copy link

jarmanso7 commented Oct 3, 2023

@Weroxig I am trying to reproduce your issue to no avail. Are you using a custom Anki Card Template? Besides the exported settings file (thanks for that), can you also please provide:

  1. The dictionaries you are using
  2. the dictionary configuration you are using
  3. the anki card template you are using

1. Dictionaries

You have an option to export your dictionary collection at (Settings -> Backup -> Export Dictionary Collection). The result should be a rather heavy file in the format yomitan-dictionaries-2023-10-03-13-24-26.json:

image

2. Dictionary configuration

What I currently have is probably different than your setup (Settings -> Dictionaries -> Configure installed and enabled dictionaries...:

image

3. Anki card template

You can find the anki card template (handlebars) if you go to Settings -> Anki -> Configure Anki card templates..., inside the textbox. Make sure you copy all the contents until the last line inside the textbox and save it into a txt file:

image

@praschke
Copy link
Collaborator

praschke commented Oct 3, 2023

@jarmanso7 all you need to reproduce is yomitan, firefox, a dictionary with structured data like JMdict Extra, and to test {glossary}. i've reproduced this already.

@jarmanso7
Copy link

@praschke Okay, I guess the missing part of the puzzle for me is JMdic Extra then. Thanks for the help, I'll try with that.

@jarmanso7
Copy link

@praschke I was able to reproduce the issue. Thanks.

@jarmanso7
Copy link

jarmanso7 commented Oct 4, 2023

I've been investigating and I've hit a wall beyond which I'm unable to progress. This is what I've found out so far.

When creating an Anki card from Yomitan, at some point the function _renderTemplate at template-renderer.js is called. The value in the variable data is identical when debugging for both Firefox and Chrome. However, on passing data to instance(data) (a function that corresponds to Handlebars.compileAST at execution time) the values returned by this call and stored into the variable result already differ between Firefox and Chrome:

    _renderTemplate(instance, data) {
        const renderSetup = this._renderSetup;
        const renderCleanup = this._renderCleanup;
        let result;
        let additions1;
        let additions2;
        try {
            additions1 = (typeof renderSetup === 'function' ? renderSetup(data) : null);
            result = instance(data).trim();
        } finally {
            additions2 = (typeof renderCleanup === 'function' ? renderCleanup(data) : null);
        }
        return Object.assign({result}, additions1, additions2);
    }

For this reason, I believe there's some problem in the Handlebars processing (it may be related to Fix Handlebars not working on Firefox due to eval #171).

It is very difficult to debug inside Handlebars.min.js. @Aquafina-water-bottle, can you provide a way or would you kindly point me to the right direction to be able to debug a beautified/pretty version of Handlebars.min.js? Is it worth it (I've seen in the mentioned issue that using this library is a temporary fix)?.

Thank you.

@praschke
Copy link
Collaborator

praschke commented Oct 4, 2023

@jarmanso7 the sourcemap can be found at https://github.com/Aquafina-water-bottle/handlebars-noeval/raw/master/handlebars.min.js.map

jsyk, Aquafina hasn't been around for a while.

@jarmanso7
Copy link

@praschke I will try to set the sourcemaps. I am not a frontend developer which means each new step I take I have to learn it on the go, but hopefully I can get it to work. Thanks your your help

@jarmanso7
Copy link

@praschke Thank you very much!! I just came back here to let you guys know I ran out of time to continue to look into this issue, just to find it already solved. Thank you again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug The issue or PR is regarding a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants