Skip to content

Commit

Permalink
Fortran: Make single-line comments greedy. Update known failures and …
Browse files Browse the repository at this point in the history
…tests.
  • Loading branch information
Golmote committed Mar 26, 2018
1 parent 571f2c5 commit c083b78
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
5 changes: 4 additions & 1 deletion components/prism-fortran.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ Prism.languages.fortran = {
}
}
},
'comment': /!.*/,
'comment': {
pattern: /!.*/,
greedy: true
},
'boolean': /\.(?:TRUE|FALSE)\.(?:_\w+)?/i,
'number': /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[ED][+-]?\d+)?(?:_\w+)?/i,
'keyword': [
Expand Down
2 changes: 1 addition & 1 deletion components/prism-fortran.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 1 addition & 11 deletions examples/prism-fortran.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,4 @@ <h2>Full example</h2>
IF (.NOT. ALLOCATED(UNSAVED1)) ALLOCATE(UNSAVED1(10))
IF (.NOT. ALLOCATED(UNSAVED2)) ALLOCATE(UNSAVED2(10))
END SUBROUTINE SUB1
END PROGRAM MAIN</code></pre>

<h2>Known failures</h2>
<p>There are certain edge cases where Prism will fail.
There are always such cases in every regex-based syntax highlighter.
However, Prism dares to be open and honest about them.
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.
</p>

<h3>Commented string</h3>
<pre><code>! This "string" should not be highlighted</code></pre>
END PROGRAM MAIN</code></pre>
4 changes: 3 additions & 1 deletion tests/languages/fortran/comment_feature.test
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
!
! foobar
! This "string" should not be highlighted

----------------------------------------------------

[
["comment", "!"],
["comment", "! foobar"]
["comment", "! foobar"],
["comment", "! This \"string\" should not be highlighted"]
]

----------------------------------------------------
Expand Down

0 comments on commit c083b78

Please sign in to comment.