This repository was archived by the owner on Dec 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
katex-menu #79
Merged
Merged
katex-menu #79
Changes from all commits
Commits
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 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,7 +99,7 @@ fun getKatexMenuWidth(): Dp { | |
| } | ||
|
|
||
| else -> { | ||
| 400.dp | ||
| 375.dp | ||
| } | ||
| } | ||
| } else { | ||
|
|
||
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,7 +48,7 @@ fun getWebView( | |
| fun onFracBinoSelected(eq: String) { | ||
| Handler(Looper.getMainLooper()).postAtFrontOfQueue { | ||
| val replaced = eq.replace("bra", "\\\\bra").replace("frac", "\\\\frac") | ||
| .replace("gen", "\\\\gen").replace("bin", "\\\\bin") | ||
| .replace("gen", "\\\\gen").replace("bin", "\\\\bin") | ||
| onSelectNotation(replaced, SelectedAnnotation.EQ) | ||
| } | ||
| } | ||
|
|
@@ -68,10 +68,7 @@ fun getWebView( | |
| @JavascriptInterface | ||
| fun onNormSelected(sel: String) { | ||
| Handler(Looper.getMainLooper()).postAtFrontOfQueue { | ||
| val replaced = sel.replace("l", "\\\\l").replace("gt", "\\\\gt") | ||
| .replace("sqrt", "\\\\sqrt").replace("pi", "\\\\pi") | ||
| .replace("ti", "\\\\ti").replace("div", "\\\\div").replace("a", "") | ||
| .replace("{x}", "{}").replace("b", "") | ||
| val replaced = sel.convertNormSel() | ||
|
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. issue (bug_risk): convertNormSel() is not defined in scope Please implement String.convertNormSel() (using latexNormMap), or revert to the previous replace chain to prevent compilation errors. |
||
| onSelectNotation(replaced, SelectedAnnotation.NORM) | ||
| } | ||
| } | ||
|
|
@@ -115,4 +112,42 @@ fun getWebView( | |
| loadUrl("file:///android_asset/katex-menu.html") | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private val latexNormMap = mapOf( | ||
| // comparisons | ||
| "lt" to "\\\\lt", | ||
| "gt" to "\\\\gt", | ||
| "le" to "\\\\le", | ||
| "ge" to "\\\\ge", | ||
|
|
||
| // fractions & roots | ||
| "times" to "\\\\times", | ||
| "div" to "\\\\div", | ||
| "sqrt{x}" to "\\\\sqrt{}", | ||
| "sqrt[a]{x}" to "\\\\sqrt[]{}", | ||
|
|
||
| // constants | ||
| "pi" to "\\\\pi", | ||
|
|
||
| // exponents & letters | ||
| "a^2" to "^2", | ||
| "a^{b}" to "^{}", | ||
| "|a|" to "||", | ||
|
|
||
| // punctuation & parens | ||
| "(" to "(", | ||
| ")" to ")", | ||
| "," to ",", | ||
| "." to ".", | ||
| "=" to "=", | ||
| "{}" to "{}", | ||
|
|
||
| // digits | ||
| "0" to "0", "1" to "1", "2" to "2", "3" to "3", "4" to "4", | ||
| "5" to "5", "6" to "6", "7" to "7", "8" to "8", "9" to "9" | ||
| ) | ||
|
|
||
|
|
||
|
|
||
| private fun String.convertNormSel(): String = latexNormMap[this] ?: this | ||
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
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
Oops, something went wrong.
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.
issue (bug_risk): Missing onIdle() call after catching exception
onIdle() should be called in the catch block to ensure the selection state is reset after an exception.