Skip to content

Commit 99db9af

Browse files
wolearycmortii
authored andcommitted
fixed morphs accidentally merging (#322)
1 parent 86cded7 commit 99db9af

File tree

3 files changed

+4
-43
lines changed

3 files changed

+4
-43
lines changed

ankimorphs/recalc/anki_data_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ def __init__( # pylint:disable=too-many-arguments
7373
) -> None:
7474
fields_list = anki.utils.split_fields(anki_row_data.note_fields)
7575
expression_field = fields_list[expression_field_index]
76-
expression = anki.utils.strip_html(expression_field)
76+
expression = anki.utils.strip_html(
77+
# this prevents morphs accidentally merging
78+
expression_field.replace("<br>", "\n")
79+
)
7780

7881
tags_list = tag_manager.split(anki_row_data.note_tags)
7982

-26 KB
Binary file not shown.

docs/src/user_guide/known-problems.md

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -45,48 +45,6 @@
4545
</details>
4646
4747

48-
<details>
49-
<summary style="display:list-item">Morphs don't split correctly</summary>
50-
51-
> Anki stores text on cards as HTML, and this can cause some weird/unexpected problems. One such problems is that
52-
> line breaks are actually stored as `<br>`.
53-
>
54-
> Here is how it looks on the card:
55-
>
56-
>```plaintext
57-
>Hello.
58-
>Goodbye.
59-
>```
60-
>
61-
>This is how it is actually stored:
62-
>
63-
>```plaintext
64-
>Hello.<br>Goodbye.
65-
>```
66-
>
67-
>Most morphemizers completely ignore the unicode equivalent of `<br>`, which results in them interpreting the text as:
68-
>
69-
>```plaintext
70-
>Hello.Goodbye.
71-
>```
72-
>
73-
>To fix this problem, we can use the [find and replace feature](https://docs.ankiweb.net/browsing.html#find-and-replace)
74-
> in Anki to add a whitespace between before the `<br>` on all our cards:
75-
![find_and_replace_split.png](../img/find_and_replace_split.png)
76-
> Where the `Find` field has this:
77-
>```plaintext
78-
>(\S)<br>
79-
>```
80-
>The `(\S)` part finds a non-whitespace character and saves it for later.
81-
>
82-
>And then the `Replace With` field has this:
83-
>```plaintext
84-
>${1} <br>
85-
>```
86-
>The `${1}` part re-inserts the `(\S)` character that was found earlier.
87-
</details>
88-
89-
9048
<details>
9149
<summary style="display:list-item">Incorrect highlighting of ignored names</summary>
9250

0 commit comments

Comments
 (0)