Hard Clear Formatting

Is your feature request related to a problem? Please describe.
Using Yomichan there’s no way to add any to handle any format clearing with css…

It’s annoying because sometimes these dictionaries are wrapped in like 20 divs, nested anchor elements, random weird styles, and it messes up my definitions.

Describe the solution you’d like
I would like anything (setting, button, shortcut) that would let me hard reset them, as in just extract any innerText and re-paste deleting everything else, so its just strings.

Describe alternatives you’ve considered
Each time I need to go manually back to the definition, copy it, then re-paste. When you have a lot of cards to make it gets very tedious, as this isn’t the only step.

This isn’t a nit pick, I have a plugin that messes with the definition field, it completely breaks because of the def’s weird formatting, so I have to manually go in do it or else it just won’t work, and that’s important to me

I would appreciate it if u someone can add this :+1:

Or if someone could point me to a plugin or some kind of script…

1 Like

Anki already supports –

  1. Stripping the formatting when pasting (Adding/Editing - Anki Manual)
  2. Erasing the formatting (same link)
  3. Stripping the field formatting from the card template (Field Replacements - Anki Manual)

Is there a reason none of those is a solution for you?

But that’s not what I mean. Anki pastes the definitions not me, so there’s no way to control that by holding down shift when the note gets made, that still requires me go back out and manually copy the definition.

I’m looking at the Field Replacements and I’m not really sure how that works sry, if that does fix my problem could you show me how if you don’t mind?

Also, Ctrl + r only strips element styles, it doesn’t extract the InnerText, removing all elements wrapping it.

What I want is a button or some kind of shortcut that strips everything by just extracting the innerText, just like Ctrl + r (maybe Ctrl + Alt + Shift + r) but not just styles, it strips all elements and leaves the strings.

This feature is super simple to add in svelte, but I know maybe there might not be any room for a shortcut or anything in Anki anymore, it’s also pretty niche, so I’m just wondering if maybe it could actually be added, or if there’s a script/plugin out there somewhere that has this feature

… that doesn’t seem like it could be true. Is this something that the add-on is pulling in automatically? If so, this may be something you need to ask to be fixed on the add-on side.

The shortcut I posted should jump you directly to the “HTML Stripping” section of the page. You would need to change your {{FieldName}} to {{text:FieldName}} in your card template(s).

I’m not in the we-will-or-won’t-add-a-feature department. I’m just offering ideas that might let you live with the app as it currently is. Even when an idea for a new feature is adopted, it can take a few months for it to make it into a release.

… that doesn’t seem like it could be true. Is this something that the add-on is pulling in automatically? If so, this may be something you need to ask to be fixed on the add-on side.

My bad, I meant Yomichan is adding the definitions, through Anki Connect.

The shortcut I posted should jump you directly to the “HTML Stripping” section of the page. You would need to change your {{FieldName}} to {{text:FieldName}} in your card template(s).

Yea this didn’t work either, my card templates are barebones, the entire definition is wrapped in a single div, it’s just all the styling is being applied with Anki Connect, so it just pastes the html as is.

I’m not sure if it’s possible to do anything about this beforehand because the styling and format is so random, so I can’t know exactly what is wrapping the actual strings beforehand,

If you think there’s another anki feature that might help I will definitely try it but I think maybe I just have to write a script myself but I don’t know if that will work either

If you wanna see what I mean:

<div style="text-align: left;"><ol><li><span><span data-sc-name="見出部"><span data-sc-name="見出仮名" lang="ja" style="font-weight: bold;">ひ<span data-sc-name="語構成" style="margin-right: 0.5em;"></span>しょ</span><span data-sc-name="アクセントG" style="font-size: 0.7em; vertical-align: super; margin-left: 0.25em; margin-right: 0.25em;"><span data-sc-name="アクセント"><span data-sc-name="accent">[2]</span></span></span><span data-sc-name="表記G" lang="ja">【<span data-sc-name="標準表記" lang="ja">避暑</span>】</span></span><div data-sc-name="解説部"><div data-sc-name="大語義"><span data-sc-name="品詞G"><span data-sc-name="品詞subG" lang="ja">(<span data-sc-name="品詞" lang="ja">名</span>)</span><span data-sc-name="用法" lang="ja" style="font-size: 0.7em; vertical-align: super;">スル</span></span><div data-sc-name="準大語義"><div data-sc-name="中語義"><div data-sc-name="語義G"><span data-sc-name="語釈" lang="ja">夏の暑さを避けるために涼しい土地へ行くこと。</span><span data-sc-name="対義語G" lang="ja">⇔<span data-sc-name="対義語"><span data-sc-name="ref"><a href="#"><span lang="ja">避寒</span></a></span></span>。</span><div data-sc-name="季語G" lang="ja"><span style="vertical-align: text-bottom; margin-right: 0.25em;"><a target="_blank" rel="noreferrer noopener" href="yomitan_dictionary_media_1_2024-05-13-03-17-52-467.svg" style="cursor:inherit;display:inline-block;position:relative;line-height:1;max-width:100%;color:inherit;"><span title="季" style="display:inline-block;white-space:nowrap;max-width:100%;max-height:100vh;position:relative;vertical-align:top;line-height:0;overflow:hidden;font-size:1px;font-size:1em;width: 1em;"><span style="display:inline-block;width:0;vertical-align:top;font-size:0;padding-top: 100%;"></span><span style="--image:none;position:absolute;left:0;top:0;width:100%;height:100%;-webkit-mask-repeat:no-repeat;-webkit-mask-position:center center;-webkit-mask-mode:alpha;-webkit-mask-size:contain;-webkit-mask-image:var(--image);mask-repeat:no-repeat;mask-position:center center;mask-mode:alpha;mask-size:contain;mask-image:var(--image);background-color:currentColor;--image: url(&quot;yomitan_dictionary_media_1_2024-05-13-03-17-52-467.svg&quot;);"></span><img alt="" src="yomitan_dictionary_media_1_2024-05-13-03-17-52-467.svg" style="display:inline-block;vertical-align:top;object-fit:contain;border:none;outline:none;position:absolute;left:0;top:0;width:100%;height:100%;opacity:0;"><span style="position:absolute;left:0;top:0;width:100%;height:100%;display:table;table-layout:fixed;white-space:normal;font-size:initial;line-height:initial;color:initial;"></span></span><span style="display:none;line-height:initial;">Image</span></a></span><span data-sc-name="季語" lang="ja">夏</span>。</div><div data-sc-name="用例" lang="ja">「軽井沢へ<span data-sc-name="見出相当部" style="font-weight: bold;">━</span>に行く」</div><div data-sc-name="用例" lang="ja">「別荘の設が有つて、例年必ず其処へ<span data-sc-name="見出相当部" style="font-weight: bold;">━</span>する<span data-sc-name="出典" lang="ja">/<span data-sc-name="書名" lang="ja">婦系図</span><span data-sc-name="付記" lang="ja">(鏡花)</span></span>」</div></div></div></div></div></div></span></li><li><span><a href="#"><span lang="ja">避暑地</span></a></span></li><li><span><div data-sc-pixiv="parent-link" style="font-weight: bold;"><a href="#"><span lang="ja">←夏</span></a></div><ul data-sc-pixiv="summary"><li lang="ja">暑い時期に暑さを逃れて涼しい場所へ行く事。</li></ul><div data-sc-pixiv="main-text-title" lang="ja" style="font-weight: bold;">概要</div><ul data-sc-pixiv="main-text" style="list-style-type: none;"><li lang="ja">夏場の暑い時期に、暑さを逃れて快適に暮らす目的で涼しい地域へ行って過ごす事。<br>日本では明治時代に外国人によって始められ、富裕な日本人も行うようになった。<br>海辺や高原が避暑地として人気があるが、エアコンが普及してからは都会の喫茶店や商業施設、公共施設もまた避暑スポットとして良く使われるようになった。</li></ul><div data-sc-pixiv="related-tags" style="margin-bottom: 0.4em;"><div lang="ja" style="font-weight: bold;">関連記事</div><ul data-sc-pixiv="related-tags" style="list-style-type: none;"><div lang="ja"><a href="#"><span lang="ja">残暑見舞い</span></a>・<a href="#"><span lang="ja">暑中見舞い</span></a>・<a href="#"><span lang="ja">日本の夏</span></a>・<a href="#"><span lang="ja">夏の風物詩</span></a>・<a href="#"><span lang="ja">熱帯夜</span></a></div></ul></div><div data-sc-pixiv="footer"><span data-sc-pixiv="read-more-link"><a target="_blank" rel="noreferrer noopener" href="yomitan_dictionary_media_2_2024-05-13-03-17-52-467.png" style="cursor:inherit;display:inline-block;position:relative;line-height:1;max-width:100%;color:inherit;vertical-align:middle;"><span style="display:inline-block;white-space:nowrap;max-width:100%;max-height:100vh;position:relative;vertical-align:top;line-height:0;overflow:hidden;font-size:1px;font-size:1em;width: 1em;"><span style="display:inline-block;width:0;vertical-align:top;font-size:0;padding-top: 100%;"></span><span style="--image:none;position:absolute;left:0;top:0;width:100%;height:100%;-webkit-mask-repeat:no-repeat;-webkit-mask-position:center center;-webkit-mask-mode:alpha;-webkit-mask-size:contain;-webkit-mask-image:var(--image);mask-repeat:no-repeat;mask-position:center center;mask-mode:alpha;mask-size:contain;mask-image:var(--image);background-color:currentColor;display:none;--image: url(&quot;yomitan_dictionary_media_2_2024-05-13-03-17-52-467.png&quot;);"></span><img alt="pixiv" src="yomitan_dictionary_media_2_2024-05-13-03-17-52-467.png" style="display:inline-block;vertical-align:top;object-fit:contain;border:none;outline:none;position:absolute;left:0;top:0;width:100%;height:100%;"><span style="position:absolute;left:0;top:0;width:100%;height:100%;display:table;table-layout:fixed;white-space:normal;font-size:initial;line-height:initial;color:initial;"></span></span><span style="display:none;line-height:initial;">Image</span></a> <a href="https://dic.pixiv.net/a/避暑"><span lang="ja">pixivで読む</span><span style="display:none;"></span></a></span></div></span></li><li><span><ul data-sc-wikipedia="abstract"><li lang="ja">避暑(ひしょ)とは、一時的に涼しい場所に移ることで夏の暑さを避けること。</li></ul><ul data-sc-wikipedia="continue-reading" style="list-style-type: &quot;⧉&quot;;"><li><a href="https://ja.wikipedia.org/wiki/避暑"><span lang="ja">続きを読む</span><span style="display:none;"></span></a></li></ul></span></li></ol></div>

Yes, it does seem that Yomichan is in the best position from keeping this unnecessary html away from you.

I don’t know what you tried, but works fine for me. I added your sample to the HTML view of a field. This is what it looks like displayed on a card template with and without HTML stripping.

I don’t know what you tried, but works fine for me. I added your sample to the HTML view of a field. This is what it looks like displayed on a card template with and without HTML stripping.

Actually you’re right, it did work, but the plugin I’m using parses the definition on flip not once, but every time you view it, this messes with it as well, and I still want some elements to work as well like li, ul, ol, and div, not remove all of them as you view the note, so basically it needs to be hardcoded without a script it seems… I now realize that its probably not possible for Anki to fix this problem, I will try to find something inside of Yomichan instead

1 Like

I would like to bump this as Yomichan is sunset and It’s fork has no plans to implement something for this, I’m wondering if this could be done still…?

I don’t know what you’re trying to do but did you try opening an issue in Yomitan’s repo?

If they rejected this, tatsumoto might still help. You should look into ajatt-tools.

i have ajatt tools, but this doesn’t really pertain to Japanese, more so html, as I’m just simply trying to strip my definition of any html, so it’s just the text,

I’m also open to any alternatives or if someone has any scripts I could use…But I also personally think that a lot of people using Anki might also find this useful

No I’m saying that you may use their fork of Yomichan and if they add such a feature you can export cards without HTML to begin with.

as Yomichan is sunset and It’s fork has no plans to implement something for this

I’m already using the fork, I asked in their discord they don’t plan on adding it

I don’t know what is “the fork”. Fork is a copy of another repository. So there are other forks too. Actively updated and maintained. Is Yomitan promoting the idea that only they are a valid fork of Yomichan?

Sorry i don’t really get your point…and “the” just refers to the subject we were talking about, which is Yomitan…

I use Yomitan, have been using it for a while, I’m not gonna go around to every fork asking for this specific feature, then spend days migrating all my stuff over to that fork if they happen to add it.

I’m just simply asking if Anki can add this feature, or if anyone has an idea on a script or something…not really about anything else

I thought you had a chance with tatsumoto but anyways, I hope you find something on Anki’s side. I do know another program that let’s you sentence mine without all the weird nested elements, but if you’re using Yomitan, you also probably know about that.