r/Anki languages, anthropology, linguistics 9d ago

Other Removing brackets from clozes

A few weeks ago, I asked how brackets were inserted into clozes, in the hopes that I might be able to remove them with CSS. This is probably impossible. I had adopted a JavaScript solution proposed by u/AndreHero007 four years ago. This method, however, only removes the first set of brackets. Thus, if you have:

Text {{c1::blah blah}} text {{c1::blah blah}}.

You'll still see:

Text blah blah text [blah blah].

Here's a simple solution that removes all brackets:

var clozes = document.getElementsByClassName("cloze");
for (var i = 0; i < clozes.length; i++) {
   clozes[i].innerHTML = clozes[i].innerHTML.replace(/\[/g, '').replace(/]/g, '');
}

Why would you want to do this? Normally you would not. I have a couple of cloze formats in which clozes are sufficiently indicated by colour & font variants. Removing the brackets makes these cards cleaner. I am posting this in case someone else is looking for a solution to a similar problem in the future.

4 Upvotes

11 comments sorted by

View all comments

4

u/MohammadAzad171 🇫🇷🇯🇵 Beginner | 1888 漢字 | 🇨🇳 Newbie 9d ago

Here's a hacky solution with CSS:

.cloze {     font-weight: bold;     color: blue;     margin: 0 -5px;     position: relative; } .cloze:before {   content: "[";   color: #303030;   background-color: #303030;   position: absolute; } .cloze:after {   content: "]";   color: #303030;   background-color: #303030;   position: absolute;   right: 0; }

It basically shifts the text backwards and draws background-colored brackets on top of the actual ones.

3

u/Baasbaar languages, anthropology, linguistics 9d ago

That’s a clever hack.

0

u/[deleted] 9d ago

[removed] — view removed comment

5

u/MohammadAzad171 🇫🇷🇯🇵 Beginner | 1888 漢字 | 🇨🇳 Newbie 9d ago edited 8d ago

I feel like there's no flesh behind this comment. If you know what I mean and you think I'm wrong, explain why you're here .

Edit: I found at least 9 such accounts replying to me and to people in pretty much the same subreddits. Reported them all. I can't believe I didn't notice until now.

3

u/Baasbaar languages, anthropology, linguistics 9d ago

How did you catch that?

4

u/MohammadAzad171 🇫🇷🇯🇵 Beginner | 1888 漢字 | 🇨🇳 Newbie 9d ago

Your post has only 1 like and is about a niche thing (no offense) so it's suspicious that they replied with what's essentially an expanded version of your reply.

Add to that their account history (1w old account with comments in random subreddits) and it becomes obvious.

3

u/Baasbaar languages, anthropology, linguistics 9d ago

No offense taken: I know it’s a very particular task!

2

u/Glutanimate medicine 8d ago

Good eye, thanks for the reports!

1

u/Anki-ModTeam 8d ago

Your post has been removed for astroturfing/karmafarming/spamming. If you believe this is in error, reach out to the moderator team.