Skip to content

fix: Strip AnkiHub modifications from question side#1256

Merged
abdnh merged 2 commits intomainfrom
strip-mods-from-qfmt
Mar 10, 2026
Merged

fix: Strip AnkiHub modifications from question side#1256
abdnh merged 2 commits intomainfrom
strip-mods-from-qfmt

Conversation

@abdnh
Copy link
Contributor

@abdnh abdnh commented Mar 9, 2026

Related issues

None. Just a small issue I noticed while testing note type updates.

Proposed changes

The ANKIHUB MODFICATIONS section should be stripped from the question side too, as we add metadata (note/user ID) there.

How to reproduce

  • Reset local changes to a deck you own.
  • Confirm AnkiHub > Deck Management > Publish style/template updates is disabled

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a minor issue where AnkiHub modification metadata was not being consistently stripped from note types. It extends the existing stripping logic to include the question side of note templates, ensuring that this specific metadata is removed from both question and answer formats. This change improves the cleanliness and consistency of note type handling within the system.

Highlights

  • Regex Adjustment: Modified the ANKIHUB_SNIPPET_RE regular expression to optionally match up to two newlines before the AnkiHub snippet marker, improving its robustness.
  • Question Side Stripping: Implemented the stripping of ANKIHUB MODIFICATIONS sections from the question side (qfmt) of note type templates, aligning it with the existing logic for the answer side (afmt).
  • Test Coverage Update: Updated integration tests to assert the presence of the ANKIHUB_SNIPPET_MARKER in the updated question format (updated_qfmt), ensuring the modifications are correctly handled during note type updates.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • ankihub/main/utils.py
    • Updated ANKIHUB_SNIPPET_RE to include optional newline characters at the beginning of the regex pattern.
    • Applied the ANKIHUB_SNIPPET_RE to template["qfmt"] to remove AnkiHub modifications from the question format.
  • tests/addon/test_integration.py
    • Added an assertion to check for the presence of ANKIHUB_SNIPPET_MARKER in updated_qfmt within test_note_type_templates_and_css_are_updated.
    • Removed a comment indicating that the AnkiHub snippet was only on the back template.
Activity
  • No specific pull request activity (comments, reviews, or progress updates) was provided in the context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@abdnh abdnh merged commit 69fd33f into main Mar 10, 2026
8 checks passed
@abdnh abdnh deleted the strip-mods-from-qfmt branch March 10, 2026 12:56
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

Successfully merging this pull request may close these issues.

2 participants