-
Notifications
You must be signed in to change notification settings - Fork 9
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
Currency symbols don't get highlighted if not followed by a number #264
Comments
This doesn't fix it, just captures the problem
It's probably the word boundary "\b" at the end of the 'currencies' regular
expression . I think I mostly expect currency symbols to be after the
number.
I've added a test case to reproduce this. Not sure how to fix it easily
though. You're welcome to have a go at it?
…On Mon, 28 Nov 2022 at 23:55, Pranesh Prakash ***@***.***> wrote:
In this example, I would expect both instances of ₹ to get highlighted,
but only the one followed by the number gets highlighted. So negative
numbers with the minus sign after the currency symbol, or currency symbols
following numbers don't get highlighted.
[image: image]
<https://user-images.githubusercontent.com/3080824/204282726-35c61df7-9bc0-404b-8041-032b06e41921.png>
—
Reply to this email directly, view it on GitHub
<#264>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAZYOKCDD36YTWMLPIVK43WKSTUFANCNFSM6AAAAAASNJUDH4>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Here's a robust pattern, that allows for rates in the form of In .NET/C#: in JS: Explanation:
I tried the JS version on my journal in You could translate it to the appropriate regex engine. |
Hmm. There is a philosophical thing here, should we match just known
allowed currencies or any string in the right place? Matching know
currencies would catch more typos, which is one thing that syntax
highlighting is useful for. Conversely, hledger accepts arbitrary
currencies, I suppose.
Could you explain / break down your regex into parts with comments? It’s
very long
…On Sun, 4 Dec 2022 at 02:36, Pranesh Prakash ***@***.***> wrote:
Here's a robust pattern, that allows for @@ and @ as well:
/(?<=\S+[ ]{2,}@?.*)("[^;\\\n]+"|[^@!,.:-\s\d]+)|(?<=\S[
]{2,}@?.*("[^;\\\n]+"|[^@!,.:-\s\d]+)(?=\s?-?\d+))/g
https://regex101.com/r/2X1aWc/1
—
Reply to this email directly, view it on GitHub
<#264 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAZYOJQFMUXX2ELMTS46ZTWLNSGXANCNFSM6AAAAAASNJUDH4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I edited my reply to add an explanation: |
In this example, I would expect both instances of
₹
to get highlighted, but only the one followed by the number gets highlighted. So negative numbers with the minus sign after the currency symbol, or currency symbols following numbers don't get highlighted.The text was updated successfully, but these errors were encountered: