-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FR] Support 'R:TLFi' template #679
Comments
No, we should not keep it. |
Unfortunately, I have to reopen this issue... {{R:TLFi}} is different from {{R|TLFi}}. We only want to render the first one and not the second one. Currently we cannot make the difference because {{R:TLFi}} is converted to {{R|TLFi}} early in the process. I'm not sure if the PR is doing more good than harm... so I would propose to revert it for now... See |
An idea: when cleaning the HTML, we could convert |
BoboTiG#693) This reverts commit 68aabb6.
Another one at : https://fr.wiktionary.org/w/index.php?title=barricade It's a good idea, but if we make a template handler for XXX, we could just let it alone and do a template handler for R:XXX directly ? |
That makes more sense yes :) |
Very early here: ebook-reader-dict/wikidict/utils.py Line 507 in 69bc586
|
Another approach could be to convert |
Very quickly, without the patterns list: diff --git a/wikidict/utils.py b/wikidict/utils.py
index 213099b..89e6177 100644
--- a/wikidict/utils.py
+++ b/wikidict/utils.py
@@ -368,6 +368,9 @@ def clean(text: str) -> str:
text = sub(r"<<([^/>]+)>>", "\\1", text)
text = sub(r"<<(?:[^/>]+)/([^>]+)>>", "\\1", text)
+ # {{formatnum:-1000000}} -> {{formatnum|-1000000}}
+ text = sub(r"{{(formatnum):([^}]+)}}", "{{\\1|\\2}}", text)
+
return text.strip()
@@ -504,12 +507,6 @@ def transform(word: str, template: str, locale: str) -> str:
parts = [p.strip("\u200e") for p in parts] # Left-to-right mark
tpl = parts[0]
- # {{formatnum:-1000000}}
- if ":" in tpl:
- parts_raw = template.split(":")
- parts = [p.strip() for p in parts_raw]
- tpl = parts[0]
-
# Stop early
if not tpl or tpl in templates_ignored[locale]:
return "" |
I don't get why it's better to do it in cleanup but having a way to choose which one we want to convert is definitely a win. We could first try everything but R:TLFi See PR #696 |
The later would ease adding patterns to ignore for each locale. The former is working too, and maybe could we move to another solution later. |
I'm not sure if we rely on this code for formatnum only ? Do you know ? |
I am not sure. Let's do it and see later if we need to adapt. |
Wikicode:
Output:
Expected:
Model link, if any: https://fr.wiktionary.org/wiki/Mod%C3%A8le:R:TLFi
Not sure if we want to keep "→ consulter cet ouvrage"
@BoboTiG WDYT ?
The text was updated successfully, but these errors were encountered: