-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
Added calls to replace_wl_with_plain_text in boxes_to_text and boxes_to_xml for String and Symbol #1136
Draft
GarkGarcia
wants to merge
5
commits into
master
Choose a base branch
from
unicode-replace-strings-symbols
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Added calls to replace_wl_with_plain_text in boxes_to_text and boxes_to_xml for String and Symbol #1136
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ff5980d
Added calls to replace_wl_with_plain_text in boxes_to_text and boxes_…
GarkGarcia bed0298
Fixed test-cases
GarkGarcia 1d86b68
Merge branch 'master' into unicode-replace-strings-symbols
mmatera 5c5c4d2
merge
mmatera 231a1e0
Merge remote-tracking branch 'upstream/master' into unicode-replace-s…
mmatera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
from typing import Any | ||
from itertools import chain | ||
from bisect import bisect_left | ||
from mathics_scanner.characters import replace_wl_with_plain_text | ||
from functools import lru_cache | ||
|
||
|
||
|
@@ -1906,7 +1907,16 @@ def do_copy(self) -> "Symbol": | |
return Symbol(self.name) | ||
|
||
def boxes_to_text(self, **options) -> str: | ||
return str(self.name) | ||
name = str(self.name) | ||
|
||
if "evaluation" in options: | ||
e = options["evaluation"] | ||
return replace_wl_with_plain_text(name, use_unicode=e.use_unicode) | ||
else: | ||
return name | ||
|
||
def boxes_to_xml(self, **options) -> str: | ||
return replace_wl_with_plain_text(str(self.name)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this depend on the option passed to the Evaluation object? |
||
|
||
def atom_to_boxes(self, f, evaluation) -> "String": | ||
return String(evaluation.definitions.shorten_name(self.name)) | ||
|
@@ -2725,6 +2735,10 @@ def boxes_to_text(self, show_string_characters=False, **options) -> str: | |
): | ||
value = value[1:-1] | ||
|
||
if "evaluation" in options: | ||
e = options["evaluation"] | ||
value = replace_wl_with_plain_text(value, e.use_unicode) | ||
|
||
return value | ||
|
||
def boxes_to_xml(self, show_string_characters=False, **options) -> str: | ||
|
@@ -2742,7 +2756,7 @@ def boxes_to_xml(self, show_string_characters=False, **options) -> str: | |
text = self.value | ||
|
||
def render(format, string): | ||
encoded_text = encode_mathml(string) | ||
encoded_text = encode_mathml(replace_wl_with_plain_text(string)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same that in Symbol |
||
return format % encoded_text | ||
|
||
if text.startswith('"') and text.endswith('"'): | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is worng. This is a property of formatting, not evaluation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rocky I agree, but I don't know where to place it.