Skip to content

Commit c083b78

Browse files
committed
Fortran: Make single-line comments greedy. Update known failures and tests.
1 parent 571f2c5 commit c083b78

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

components/prism-fortran.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ Prism.languages.fortran = {
1212
}
1313
}
1414
},
15-
'comment': /!.*/,
15+
'comment': {
16+
pattern: /!.*/,
17+
greedy: true
18+
},
1619
'boolean': /\.(?:TRUE|FALSE)\.(?:_\w+)?/i,
1720
'number': /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[ED][+-]?\d+)?(?:_\w+)?/i,
1821
'keyword': [

components/prism-fortran.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-fortran.html

+1-11
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,4 @@ <h2>Full example</h2>
6868
IF (.NOT. ALLOCATED(UNSAVED1)) ALLOCATE(UNSAVED1(10))
6969
IF (.NOT. ALLOCATED(UNSAVED2)) ALLOCATE(UNSAVED2(10))
7070
END SUBROUTINE SUB1
71-
END PROGRAM MAIN</code></pre>
72-
73-
<h2>Known failures</h2>
74-
<p>There are certain edge cases where Prism will fail.
75-
There are always such cases in every regex-based syntax highlighter.
76-
However, Prism dares to be open and honest about them.
77-
If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
78-
</p>
79-
80-
<h3>Commented string</h3>
81-
<pre><code>! This "string" should not be highlighted</code></pre>
71+
END PROGRAM MAIN</code></pre>

tests/languages/fortran/comment_feature.test

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
!
22
! foobar
3+
! This "string" should not be highlighted
34

45
----------------------------------------------------
56

67
[
78
["comment", "!"],
8-
["comment", "! foobar"]
9+
["comment", "! foobar"],
10+
["comment", "! This \"string\" should not be highlighted"]
911
]
1012

1113
----------------------------------------------------

0 commit comments

Comments
 (0)