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

Evoke fill-in-blank from Anki Front Card Script #152

Open
hoanshiro opened this issue Oct 6, 2024 · 0 comments
Open

Evoke fill-in-blank from Anki Front Card Script #152

hoanshiro opened this issue Oct 6, 2024 · 0 comments

Comments

@hoanshiro
Copy link

hoanshiro commented Oct 6, 2024

Hi, many thanks for your contribution.
I create script to auto re-generate cloze text from field for each review

function randomTyping(text) {
    var words = text.split(' ');
    var choices = Array.from({ length: words.length }, () => Math.random() < 0.5);

    for (var i = 1; i < choices.length; i++) {
        if (choices[i] && choices[i - 1]) {
            choices[i] = false;
        }
    }

    for (var i = 0; i < words.length; i++) {
        if (choices[i]) {
            words[i] = "\{\{c1::" + words[i] + "}}"; // Correctly formatted cloze
        }
    }
    return words.join(' ');
}

var german = '{{German 1}}'; // Replace with your actual text or variable
var typing = randomTyping(german);
// input: Die Eltern und Kinder essen und sprechen über ihren Tag.
// output: Die {{c1::Eltern}} und {{c1::Kinder}} essen {{c1::und}} sprechen über {{c1::ihren}} Tag.

Now I want to use fill-in-black to parse above output, how can I evoke it in <script> block?
I researched and found that can use onBridgeCmd to send message to python backed but don't know how exactly integrated with this add-on.
Could you please help review and suggest solution to support this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant