Skip to content

[BUILD-1010] feat: Preserve custom CSS on AnkiHub note types#1088

Merged
RisingOrange merged 9 commits intomainfrom
feat/preserve-css-below-ankihub-end-comment
Jan 29, 2025
Merged

[BUILD-1010] feat: Preserve custom CSS on AnkiHub note types#1088
RisingOrange merged 9 commits intomainfrom
feat/preserve-css-below-ankihub-end-comment

Conversation

@RisingOrange
Copy link
Collaborator

@RisingOrange RisingOrange commented Jan 26, 2025

We are preserving HTML below the ankihub end comment on the note type card templates, but we don't have that for the note type styling.
This task makes it so that content below a special ankihub end comment is preserved for the note type styling.

It also fixes an issue where more and more white space is added to the note type templates.

Related PR for the AnKing note types add-on: AnKing-VIP/anking_notes_addon#34

Related issues

AnKing-VIP/AnKing-Note-Types#219 (comment)

Proposed changes

  • Change the note_type_with_updated_templates function (from ankihub.main.utils.py) to note_type_with_updated_templates_and_css
    • The function now updates the note type styling as well
    • The function was refactored
    • Fixed an issue where the note type templates end up with increasing amounts of white space at the end
  • Refactor code to always use note_type_with_updated_templates_and_css when updating note types
    • Previously other, similar, code was used to modify the note type when creating a deck, or on Anki startup (invoked by entry_point._adjust_ankihub_note_type_templates)
  • Add and update tests

How to reproduce

  • Start Anki, go to Tools -> Note Types
  • Choose an AnkiHub note type, click on Cards
  • Switch to the Styling tab
  • Scroll to the end of the Styling content
  • The AnkiHub end comment should be at the end
  • Put some text above the end comment and some text below the end comment
  • Sync some changes to the deck the note type belongs to
  • Check the Styling tab of the note type
    • The text you added above the comment shouldn't be there
    • The text you added below the comment should be still there

It's the same behavior for the other tabs besides Styling (Front Template and Back Template), which we already had previously

@RisingOrange RisingOrange force-pushed the feat/preserve-css-below-ankihub-end-comment branch from be2b7bc to d0a538d Compare January 26, 2025 14:49
@RisingOrange RisingOrange changed the title feat: Preserve css below ankihub end comment feat: Preserve custom CSS on AnkiHub note types Jan 28, 2025
@RisingOrange RisingOrange changed the title feat: Preserve custom CSS on AnkiHub note types [BUILD-1010] feat: Preserve custom CSS on AnkiHub note types Jan 28, 2025
@RisingOrange RisingOrange requested a review from a team January 28, 2025 20:50
@RisingOrange RisingOrange requested a review from abdnh January 28, 2025 21:53
@RisingOrange RisingOrange merged commit ce931d2 into main Jan 29, 2025
7 checks passed
@RisingOrange RisingOrange deleted the feat/preserve-css-below-ankihub-end-comment branch January 29, 2025 08:58
@sentry
Copy link

sentry bot commented Feb 5, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ CardTypeError: O modelo do cartão ⁨1⁩ tem um problema.
    Field '⁨ankihub_id⁩' not found.
    anki._backend in _run_command View Issue

Did you find this useful? React with a 👍 or 👎

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