X Tutup
Skip to content

Do not make bold sub words and ignore case#348

Merged
sinaatalay merged 1 commit intorendercv:mainfrom
abassel:fix/fix_bold_words
Feb 9, 2025
Merged

Do not make bold sub words and ignore case#348
sinaatalay merged 1 commit intorendercv:mainfrom
abassel:fix/fix_bold_words

Conversation

@abassel
Copy link
Contributor

@abassel abassel commented Feb 9, 2025

First of all: Thank you for sharing this wonderful project with us. It helped me a lot to automate my resume during my job search.

I came across few bolding issues few days ago and fixed them in my local machine but before I could open the PR I noticed you fixed part of them. This PRs is fixing the issues where occurrences of subword gets bold. Lets say I want to bold java and I get the java part of javascript bold. Also it supports different case(AWS vs Aws vs aws)The fix uses regular expressions to have a more robust bold. Additionally I added doctests but I only could run them if I changed the imports like below:

@@ -11,8 +11,8 @@ from typing import Annotated, Literal, Optional
 
 import pydantic
 
-from . import computers
-from .base import RenderCVBaseModelWithExtraKeys
+from rendercv.data.models import computers
+from rendercv.data.models.base import RenderCVBaseModelWithExtraKeys

Then test by executing the command:
python3 -m doctest -f rendercv/data/models/entry_types.py -v

I did not add the import change to the commit since imports can get tricky.

The final output should be:

Screenshot 2025-02-09 at 3 30 35 AM

Screenshot 2025-02-09 at 3 07 32 AM

ps: the diff for the other code that you just fixed is below. I don't think it is needed but just putting it here to register a different solution:

diff --git a/rendercv/data/reader.py b/rendercv/data/reader.py
index b29a8e2..2c4f520 100644
--- a/rendercv/data/reader.py
+++ b/rendercv/data/reader.py
@@ -31,19 +31,14 @@ def make_given_keywords_bold_in_sections(
     if sections_input is None:
         return None
 
-    for section_title, entries in sections_input.items():
-        new_entries = []
-        for entry in entries:
+    for entries in sections_input.values():
+        for i, entry in enumerate(entries):
             if isinstance(entry, str):
-                new_entry = entry_types.make_keywords_bold_in_a_string(entry, keywords)
+                entries[i] = entry_types.make_keywords_bold_in_a_string(entry, keywords)
             elif callable(getattr(entry, "make_keywords_bold", None)):
-                new_entry = entry.make_keywords_bold(keywords)  # type: ignore
-            else:
-                new_entry = entry
-
-            new_entries.append(new_entry)
-
-        sections_input[section_title] = new_entries
+                entries[i] = entry.make_keywords_bold(  # NOQA: PLW2901 # type: ignore
+                    keywords
+                )
 
     return sections_input

Thank you!

@abassel abassel marked this pull request as ready for review February 9, 2025 08:40
@sinaatalay
Copy link
Member

Thank you!

Your code for make_given_keywords_bold_in_sections is definitely better code than the current one. If you could add that to the PR (or to another PR), that would be great!

@abassel
Copy link
Contributor Author

abassel commented Feb 9, 2025

Glad to help. Just added the code.

@sinaatalay sinaatalay merged commit 375490c into rendercv:main Feb 9, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup