From: https://meta.stackexchange.com/a/184109/397248
- Check that the language is supported by highlight.js
Look at the list of highlight.js supported languages. If
your language is not on the list, it needs to be created within the
highlight.js project before it can be deployed by Stack Exchange.
If a language is already on the list but not used on Stack Exchange, please
raise a feature request here on Meta to have it deployed on the network.
Fortran is mentioned in the linked file:
| Fortran | fortran, f90, f95 | |
And https://highlightjs.org/static/demo/ has this example on it:
subroutine test_sub(k)
implicit none
!===============================
! This is a test subroutine
!===============================
integer, intent(in) :: k
double precision, allocatable :: a(:)
integer, parameter :: nmax=10
integer :: i
allocate (a(nmax))
do i=1,nmax
a(i) = dble(i)*5.d0
enddo
print *, 'Hello world'
write (*,*) a(:)
end subroutine test_sub
So the language is already supported by highlight.js.
- Check that the language is used by Stack Exchange
Look at the highlight-loader.js file on the dev CDN, open in
your favourite editor, and search for the language hint. For example,
searching for "dart" brings you to a line consisting of
hljs.registerLanguage('dart', ...
. This means that lang-dart
is an
available language hint. Searching for "psh" or "powershell" doesn't return
any results, meaning that psh is not supported by the Stack Exchange version
of highlight.js.
[...]
Language codes currently available on Stack Exchange
But not by StackExchange's version. It's not on the list of "Language codes"
and grep -i fortran highlightjs-loader.en.js
yields nothing.
With that, it seems that the next step forward is asking for Fortran support on
https://meta.stackexchange.com, as mentioned in the second item.
One such request already exists:
No syntax highlight for Fortran?
But it was closed and
answered with the following:
If this is a feature request for adding a specific language to the current
set of syntax highlighting
languages, then you should
refer to the linked FAQ:
Stack Exchange does not have its own syntax highlighting engine. It
uses Google Code
Prettify. Therefore, any
bugs and feature requests regarding syntax highlighting cannot be handled
by Stack Exchange and should be directed to the team behind Google Code
Prettify.
In the mean time (as suggested in
comment),
use
lang-pascal
as a partial alternative.
Since the close reason made sense at the time and since GCP is not used
anymore, I suppose that the right thing to do would be to request it again in a
new question.
Note: I don't personally use Fortran, so it wouldn't make sense for me to
request it. If you're reading this and want to do so, feel free to copy/paste
from my answer.
Original answer below, please ignore. Thanks @rene for the corrections.
> Does anyone know if Fortran support will be added soon?
It works now, thanks to highlight.js:
Goodbye, Prettify. Hello highlight.js! Swapping out our Syntax Highlighter
Example from https://highlightjs.org/static/demo/:
subroutine test_sub(k)
implicit none
!===============================
! This is a test subroutine
!===============================
integer, intent(in) :: k
double precision, allocatable :: a(:)
integer, parameter :: nmax=10
integer :: i
allocate (a(nmax))
do i=1,nmax
a(i) = dble(i)*5.d0
enddo
print *, 'Hello world'
write (*,*) a(:)
end subroutine test_sub