Change bold and italics typst source generation#303
Merged
sinaatalay merged 14 commits intorendercv:mainfrom Jan 20, 2025
Merged
Change bold and italics typst source generation#303sinaatalay merged 14 commits intorendercv:mainfrom
sinaatalay merged 14 commits intorendercv:mainfrom
Conversation
Change templater to use #strong and #emph instead of * and _ respectively.
engineeringresumes_empty_long_second_row.pdf 0 of 1 pages differ. engineeringresumes_empty_short_second_row.pdf 0 of 1 pages differ. engineeringresumes_filled_long_second_row.pdf 13 of 39 pages differ. engineeringresumes_filled_short_second_row.pdf 14 of 45 pages differ. The diff is one extra comma which tbh, was probably supposed to be there anyway: Old: `Bogaziçi University in Mechanical Engineering: - Istanbul, Turkey` New: `Bogaziçi University, in Mechanical Engineering: - Istanbul, Turkey`
moderncv_empty_long_second_row.pdf 0 of 1 pages differ. moderncv_empty_short_second_row.pdf 0 of 1 pages differ. moderncv_filled_long_second_row.pdf 14 of 46 pages differ. moderncv_filled_short_second_row.pdf 14 of 46 pages differ. Same diff as for engineeringresumes -- one extra comma which, was probably supposed to be there anyway: Old: `Bogaziçi University in Mechanical Engineering: - Istanbul, Turkey` New: `Bogaziçi University, in Mechanical Engineering: - Istanbul, Turkey`
Contributor
Author
|
Filtered: rendercv/renderer/templater.py | 102 +++++++++++++++++++++++++++++++----------
tests/test_renderer.py | 77 +++++++++++++++++++++++++++++--
2 files changed, 149 insertions(+), 30 deletions(-)Full: $ git diff 93e8dff efe308ae --compact-summary
rendercv/renderer/templater.py | 102 +-
tests/test_renderer.py | 77 +-
.../test_create_a_typst_file/classic_filled.typ | 1226 +++++------
.../engineeringclassic_filled.typ | 1226 +++++------
.../engineeringresumes_filled.typ | 1098 +++++-----
.../test_create_a_typst_file/moderncv_filled.typ | 1098 +++++-----
.../test_create_a_typst_file/sb2nov_filled.typ | 2186 ++++++++++----------
.../classic_filled_long_second_row/John_Doe_CV.typ | 1226 +++++------
.../John_Doe_CV.typ | 1226 +++++------
.../John_Doe_CV.typ | 1226 +++++------
.../John_Doe_CV.typ | 1226 +++++------
.../John_Doe_CV.typ | 1098 +++++-----
.../John_Doe_CV.typ | 1098 +++++-----
.../John_Doe_CV.typ | 1098 +++++-----
.../John_Doe_CV.typ | 1098 +++++-----
.../sb2nov_filled_long_second_row/John_Doe_CV.typ | 2186 ++++++++++----------
.../sb2nov_filled_short_second_row/John_Doe_CV.typ | 2186 ++++++++++----------
.../classic_empty_long_second_row.pdf | Bin 11573 -> 11573 bytes
.../classic_empty_short_second_row.pdf | Bin 11573 -> 11573 bytes
.../classic_filled_long_second_row.pdf | Bin 391668 -> 391668 bytes
.../classic_filled_short_second_row.pdf | Bin 387470 -> 387470 bytes
.../engineeringclassic_empty_long_second_row.pdf | Bin 8725 -> 8725 bytes
.../engineeringclassic_empty_short_second_row.pdf | Bin 8725 -> 8725 bytes
.../engineeringclassic_filled_long_second_row.pdf | Bin 240983 -> 240983 bytes
.../engineeringclassic_filled_short_second_row.pdf | Bin 270517 -> 270517 bytes
.../engineeringresumes_empty_long_second_row.pdf | Bin 10716 -> 10716 bytes
.../engineeringresumes_empty_short_second_row.pdf | Bin 10716 -> 10716 bytes
.../engineeringresumes_filled_long_second_row.pdf | Bin 218962 -> 218919 bytes
.../engineeringresumes_filled_short_second_row.pdf | Bin 239838 -> 239822 bytes
.../moderncv_empty_long_second_row.pdf | Bin 9361 -> 9361 bytes
.../moderncv_empty_short_second_row.pdf | Bin 9361 -> 9361 bytes
.../moderncv_filled_long_second_row.pdf | Bin 255185 -> 255169 bytes
.../moderncv_filled_short_second_row.pdf | Bin 255185 -> 255169 bytes
.../sb2nov_empty_long_second_row.pdf | Bin 12077 -> 12077 bytes
.../sb2nov_empty_short_second_row.pdf | Bin 12077 -> 12077 bytes
.../sb2nov_filled_long_second_row.pdf | Bin 386938 -> 386938 bytes
.../sb2nov_filled_short_second_row.pdf | Bin 398126 -> 398126 bytes
37 files changed, 10281 insertions(+), 10400 deletions(-)
|
|
Ran into the original issue with typing asterisks, solved in seconds by installing this pull request into my env. Thank you! |
sinaatalay
approved these changes
Jan 19, 2025
Member
sinaatalay
left a comment
There was a problem hiding this comment.
This was very helpful, thank you. I made some changes here following your comments. I'm glad you loved the code!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #293 and, coincidentally fixes #294.
Does not conflict with #299.
Changes
*to#sym.ast.basic. Sometimes a zero-width joiner is also added (if asterisk appears in the middle of a word).#strong[]and#emph[]instead of#[**]and#[__]respectively. This means that the typst templates are more robust to multilines.greedy_on_not_found: bool = Truekwarg toreplace_placeholders_with_actual_values. The default preserves previous behaviour in jinja template mode.input_template_to_typstnow strips a bunch of extra special characters from beginning and end of the string. This is in order to (mostly) preserve the previous behaviour, but ought to be removed later when a better solution is implemented.tests/testdata(that's most of the lines diff:+10251, -10251).Notes
Bar one minor difference, all the pdf files are pixel-identical. Checked with
diff-pdfon default settings. The minor difference is inengineeringresumeandmoderncvtemplates, where the comm in the middle of the template used to be gobbled up (in mu opinion unnecessarily) byreplace_placeholders_with_actual_valuesininput_template_to_typst.Old:
Bogaziçi University in Mechanical Engineering: - Istanbul, TurkeyNew:
Bogaziçi University, in Mechanical Engineering: - Istanbul, TurkeyThe whole business with gobbling up non-alphanumeric characters by
replace_placeholders_with_actual_valuesshoudl, in my opinion, be done differently. I assume it happens like that to make the way it works jinja templates easier, or maybe to cater for situations like**NAME** -- **LOCATION**, when NAME is not specified. Thereplace_placeholders_...func would then gobble up the--. I don't think that's a good way of doing it though. It's clever but it introduces more issues than it's worth and it's really unexpected. I've left it behind a flag here, but I would suggest in the future to completely remove it and follow the example of the template forEducationEntry.j2.typwhich just lists a bunch of cases with (very helpful)// YES DATE, YES DEGREE,// YES DATE, NO DEGREE, etc. It's a bunch of work but I think it'd make that part of the code cleaner. I've re-added kind-of gobbling at the end ofinput_template_to_typstwithoutput = re.sub(r"^[^\w\s#\[\]\n\(\)]*", "", output)akalstrip not (word or space or # or [ or ] or newline or ( or ). I think, after removing the gobble fromreplace_placeholders_...` this should go too. It's there just to retain the current behaviour.Overall, I really like the codebase, it's really clean and it was really fun to work on this! 😃 Thanks for an amazing project!