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

MathJax Clozes? #67

Open
Michael35699 opened this issue Jun 7, 2021 · 0 comments
Open

MathJax Clozes? #67

Michael35699 opened this issue Jun 7, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@Michael35699
Copy link

Describe the bug
A clear and concise description of what the bug is.

  • Anki client: AnkiDesktop Windows 10 2.1.44

Debug information
I have been playing with clozes, specifically for the ones inside MathJax. It works fine in the recipes cloze.hide and cloze.reveal, but cloze.show doesn't seem to use the field inactiveEllipser, as it keeps using HTML.

Method 1 (preferred method)

Basically, when a cloze is defined as inactive, it just injects HTML. I don't know if this is intentional. I am trying to use this with my math cards, and I'm having a bit of struggle. Thank you :)

I cannot upload files apparently, but this would be my closet setup.

/* cSpell:disable */
/** USED */
const elements = closet.template.anki.getQaChildNodes();
const memory = chooseMemory("closet__1");
const filterManager = closet.FilterManager.make(preset, memory.map);

const output = [[elements, memory, filterManager]];

const texCloze = {
  inactiveEllipser: () => String.raw`\left[\ldots\right]`,
  get frontStylizer() {
    return this.backStylizer.toStylizer({ mapper: (v) => String.raw`\left[${v}\right]` });
  },
  frontEllipser: (tag) => ([
    tag.values[1]
      ? tag.values[1]
      : String.raw`\ldots`
  ]),
  backStylizer: closet.Stylizer.make({
    processor: v => String.raw`{\color{cornflowerblue}{${v}}}`,
  }),
  backEllipser: (tag) => ([tag.values]),
};

/* here goes the setup - change it to fit your own needs */
{
  globalThis.target = closet.browser.recipes.occlusionEditor()(filterManager.registrar);

  filterManager.install(

    /* TeX CLOZE */

    closet.flashcard.recipes.cloze.show({
      tagname: "txc",
      ...texCloze,
    }),
    closet.flashcard.recipes.cloze.reveal({
      tagname: "txch",
      ...texCloze,
    }),
    closet.flashcard.recipes.cloze.hide({
      tagname: "txcr",
      ...texCloze,
    }),
  );
}
@Michael35699 Michael35699 added the bug Something isn't working label Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants