-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Correct for Fortran literal number #1934
Conversation
In modern fortran you can set the kind of intrinsic data type. It means you can define additional intrinsic data type. When you do so, for literal constants you have to use the kind name attached to literal consonant using under score. Example: a = 12.23_dp
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.
Hi @kookma
Unfortunately tests are failing now. You can look right into Travis log (https://travis-ci.org/highlightjs/highlight.js/jobs/472075275) or run tests locally (the process is described here: https://highlightjs.readthedocs.io/en/latest/building-testing.html).
As I can see, the difference is the following:
-
Plus/minus sign before a number is not expected to be a part of that number. For example,
-.23
is expected to be-<span class="hljs-number">.23</span>
but was highlighted as<span class="hljs-number">-.23</span>
. -
A number can be ended with dot, which is a part of that number. For example,
1.
expected to be<span class="hljs-number">1.</span>
. But now it is highlighted as<span class="hljs-number">1</span>.
.
You should address these issues in the regexp, and also add a test (or couple of tests) for the introduced changes. The tests are in test/markup/fortran/
catalog.
@egor-rogov I understood you expect to remove the minus sign in the second example also! Am I right? |
@kookma |
@egor-rogov I will add some more tests and examples |
@egor-rogov |
@kookma |
@egor-rogov By the way I did not changed the cN class, I just changed the content of regexp string. Compare this with the original file in master branch. It seems I did something wrong during commit on myside |
@kookma Sure you can create a new PR. |
Closing based on comments above. Looking forward to a new pr. |
In modern fortran you can define the kind of intrinsic data type. It means you can define additional intrinsic data type. When you do so, for literal constants you have to use the kind name attached to literal consonant using under score (like a prefix
_newtype
).Example:
a = 12.23_dp
How the current code works
When using the current highlight.js to highlight a Fortran code contains such named constant, highlight.js fails to do the job! It highlights the remaining code (from the position of named constant) in a wrong way!
Note to line 4. The literal number has a
_DBL
suffix and it makes the current code breaks. The remaining highlighting is wrong.The Corrected code
The below image shows the corrected code output. As you can see the literal constant is highlighted correctly and there is no more error in the following texts.
Note to line four and following lines. The literal constants are highlighted correctly. Also note to line 5 the
WRITE
keyword in two image.