Skip to content

Commit

Permalink
add class="antonym" for JMDict and Wiktextract
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Oct 3, 2024
1 parent 6017035 commit 7325b49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion pyglossary/plugins/jmdict.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ def br() -> "Element":
if i > 0:
with hf.element("big"):
hf.write(" | ")
with hf.element("a", href=f"bword://{word}"):
with hf.element(
"a",
href=f"bword://{word}",
attrib={"class": "antonym"},
):
hf.write(word)
hf.write(br())

Expand Down
10 changes: 6 additions & 4 deletions pyglossary/plugins/wiktextract.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,17 +508,19 @@ def addWordLink( # noqa: PLR6301
self,
hf: "T_htmlfile",
word: str,
wordClass: str = "",
) -> None:
i = word.find(" [")
if i >= 0:
word = word[:i]
if not word:
return
attrib = {"href": f"bword://{word}"}
if wordClass:
attrib["class"] = wordClass
with hf.element(
"a",
attrib={
"href": f"bword://{word}",
},
attrib=attrib,
):
hf.write(word)

Expand Down Expand Up @@ -563,7 +565,7 @@ def writeAntonyms(
word = item.get("word")
if not word:
continue
self.addWordLink(hf, word)
self.addWordLink(hf, word, wordClass="antonym")

def writeRelated(
self,
Expand Down

0 comments on commit 7325b49

Please sign in to comment.