Welcome to our community

Be a part of something great, join today!

Coding language syntax highlighting

Theia

Well-known member
Mar 30, 2016
92
I tried the code tags and its syntax highlighting feature in case of python. I was satisfied with the result, many thanks!

Screenshot_20200629-133131_Samsung Internet.jpg

However, I'd like to ask, if there was possible to add more coding languages? Fortran 90, for example, is one of my favourites, but there are some others too which might be useful, like R, gnuplot, octave, mathematica. How's the case? :unsure:
 

MarkFL

Administrator
Staff member
Feb 24, 2012
13,734
Yes, it is possible to add available languages to the code BBCode. In fact, we recently added LaTeX to the default XenForo package. Here is a page showing the additional languages that can be added:


On that page, of the ones you asked about, I see:
  • Fortran
  • R
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,679
Octave is an open source version of MatLab. And MatLab is in the list.
It's a good addition here as a mathematical language.

It looks like this (from a previous post):
MatLab:
function [t2, y2] = trapezoid_method(N)
   h=1/N;
   A=[-5 -2;-2 -100];
   y=[1;1];
   t2=[0];
   y2=[y];
   for (i=1:N)
      y=(eye(2)+h*A+h^2/2*A^2)*y;
      t2=[t2, i*h];
      y2=[y2, y];
   end for
end function

[t2, y2] = trapezoid_method(10)
 
Last edited:

MarkFL

Administrator
Staff member
Feb 24, 2012
13,734
Octave is an open source version of MatLab. And MatLab is in the list.
It's a good addition here as a mathematical language.
Okay, would you recommend any others? I will add Fortran and Matlab and R (if @Jameson would want that as I know he has used it for statistical analysis).
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,679
R is a good one. Pops up every now on then here.
We might add APL, SAS, which are also mathematical languages. I haven't seen them on MHB though, so it's probably not worth it.
The big missing one is Mathematica, which is the same as the well known Wolfram|Alpha.
 

MarkFL

Administrator
Staff member
Feb 24, 2012
13,734
R is a good one. Pops up every now on then here.
We might add APL, SAS, which are also mathematical languages. I haven't seen them on MHB though, so it's probably not worth it.
The big missing one is Mathematica, which is the same as the well known Wolfram|Alpha.
The js files needed to add support for each language are tiny, and if I'm doing one, I might as well do whatever else we want. I view you as MHB's resident coding guru, so I'll add whatever you think would be good. Maybe someone will add Mathematica in the future. :)
 

Jameson

Administrator
Staff member
Jan 26, 2012
4,029
This is an interesting topic! The software used in the academic math world is often very different than the business world from my experience. In school I used SAS and R almost entirely. Most companies today don't want to pay the huge cost of a SAS license and deal with the closed source nature of it either. R is still used for more advanced statistical projects I think, but Python has really taken over everywhere due to its extremely versatile nature.That's just my own view of the software changes and it's likely US centric.

So for this task though, I agree with @MarkFL if adding more languages is negligible then easiest to just add all of them or all within reason. Don't need to let something like highlighting syntax be the thing that makes a new user leave out of frustration. :p
 

MarkFL

Administrator
Staff member
Feb 24, 2012
13,734
Okay, I have added support for the following languages:
  • APL
  • Fortran
  • MatLab
  • R
  • SAS
I added them to the list of supported languages in alphabetical order, and XenForo doesn't preserve that order for some reason, but they're there. :)