Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle special characters inside \text commands. #7

Merged
merged 3 commits into from Jul 16, 2018

Conversation

danielhollas
Copy link
Contributor

@danielhollas danielhollas commented Jul 5, 2018

ST for \text{(english text)} would fail because the unescaped parentheses were messing up the regexes.

The issue was reported on JIRA IC-129.

(Note of caution, this is my very first pull request so hopefully I am not messing something up 馃檪)

PS: I think I signed the CLA couple months ago...

e.g. \text{(english text)} would fail because
the unescaped paretheses were messing up the regexes
@@ -374,6 +374,16 @@ function rtrim(str) {
return str.replace(/\s+$/g, '');
}

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets not extend the RegExp object, but instead make this into a separate function, perhaps escapeForRegex?

Can you also please add a sentence at the top of this jsdoc comment to briefly describe what this function does, for example something like:

/**
 * Escape any string to create a regular expression.
 *
 * See: https://stackoverflow...

@@ -996,6 +996,39 @@ describe('TranslationAssistant (\\text{}, \\textbf{})', function() {
translated: '',
}], ['$\\textbf{Fl盲che}} = 12 \\textbf { Quadratzentimeter}$']);
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the tests!

Copy link
Contributor

@mpolyak mpolyak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for creating this fix @danielhollas

I left a request for change inline below, but otherwise it looks great.

Can you also please update the commit summary with a possible translations editor link where this fix can be tested live (if possible)?

@danielhollas
Copy link
Contributor Author

Awesome, will do. 馃憤

Sorry for a newbie question, but what is the process now? Should I make the requested changes and push a new commit (but where should I put the new summary?), or should I squash the commits and force-push to this branch?

@mpolyak
Copy link
Contributor

mpolyak commented Jul 12, 2018

You can make the code changes in a new commit, with the "final" summary (that can include the test plan link to verify fix in translations editor).

When I accept the pull request, I'll choose "Squash and merge" and pick the commit summary from your last commit (with the requested changes), this should end up in master of this repo.

@danielhollas
Copy link
Contributor Author

Okay, pushed the changes. Actually, you probably won't need to rebuild after all.

Per this doc, there should be some parameter after the '--loose' option.

So this works for me:
babel --loose all src/translation-assistant.js -o lib/translation-assistant.js

I did not commit this change but I do not understand why it works for you without that parameter.
My babel version is 5.8.38

@mpolyak
Copy link
Contributor

mpolyak commented Jul 16, 2018

So this works for me:
babel --loose all src/translation-assistant.js -o lib/translation-assistant.js

I did not commit this change but I do not understand why it works for you without that parameter.
My babel version is 5.8.38

@danielhollas, you're right! It's no longer working for me either without --loose all.
I'm guessing I used npm run watch_build, which does work.

I don't see a difference in output for npm run build with --loose all so it seems safe to update, perhaps in #8 or a new pull request?

@mpolyak mpolyak merged commit 2735e5b into Khan:master Jul 16, 2018
@danielhollas
Copy link
Contributor Author

Yep, I pushed the change to #8.

Actually, only now I realized how watch_build works -- it monitors and compiles continuously so when I thought it was stuck, it was simply waiting. I think it works without the all parameter only accidentally so I added it to watch_build as well and verified it does not change the build.

@danielhollas danielhollas deleted the bugfix branch July 16, 2018 20:16
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.

None yet

2 participants