# Syntax highlighting [INSTALLED, WAITING ON FEEDBACK]

#### dwsmith

##### Well-known member
Can syntax highlighting be implemented when we use the code tags? The code in the tags would be easier to follow with the eyes if we had such a feature.

#### Jameson

Staff member
Re: syntax highlighting

Using the PHP tags will highlight some, although I'm not sure if it's exactly what you're looking for.

#### dwsmith

##### Well-known member
Re: syntax highlighting

Using the PHP tags will highlight some, although I'm not sure if it's exactly what you're looking for.
Something like this:

#### Jameson

Staff member
Re: Syntax highlighting

Sorry to get back to you a bit late on this but I'm on vacation.

I still believe the PHP BBcode button will do the trick. How does this look?

PHP:
<html>
<body>

<?php
if (isset($_COOKIE["user"])) echo "Welcome " .$_COOKIE["user"] . "!<br>";
else
echo "Welcome guest!<br>";
?>

</body>
</html>

#### Ackbach

##### Indicium Physicus
Staff member
Re: Syntax highlighting

Sorry to get back to you a bit late on this but I'm on vacation.

I still believe the PHP BBcode button will do the trick. How does this look?

PHP:
<html>
<body>

<?php
if (isset($_COOKIE["user"])) echo "Welcome " .$_COOKIE["user"] . "!<br>";
else
echo "Welcome guest!<br>";
?>

</body>
</html>
I could be wrong, but I think dwsmith is talking about typing up $\LaTeX$ code on this forum, and when we do that, it is helpful to have syntax highlighting in the editor so as to see where there are problems.

PHP:
$$\int_{- \infty}^{ \infty}e^{-x^{2}} \, dx= \sqrt{ \pi}.$$
Wrapping $\LaTeX$ code with php tags gives some syntax highlighting, but only in the post, and not in the editor.

#### Jameson

Staff member
Re: Syntax highlighting

Hmm, if that's the case then I would say that one can simply hit "Preview" to check the code in the editor but that's not really needed. If there are problems with Latex syntax, Mathjax will not render the bit in question or will render it but highlight a problem in red. I think coding some sort of immediate Latex syntax checker into the editor would be a large project.

#### dwsmith

##### Well-known member
Re: Syntax highlighting

Hmm, if that's the case then I would say that one can simply hit "Preview" to check the code in the editor but that's not really needed. If there are problems with Latex syntax, Mathjax will not render the bit in question or will render it but highlight a problem in red. I think coding some sort of immediate Latex syntax checker into the editor would be a large project.
PHP highlighting removes \ from the code and who knows what else it may remove that would affect compiling of the Latex code. I would like the highlighting so if I post a chunk of code, it is easier for people to read.

For instance, take my post here, this looks horrible to read unless you copy to your own editor. If we had highlighting, people could easily follow it from the site.

Last edited:

#### Jameson

Staff member
Re: Syntax highlighting

I might have found something we can use, but it needs to be tested more. There is syntax-highlighting freeware called Geshi and someone wrote a vBulletin plugin for it. It has functionality for a bunch of languages, including $\LaTeX$. Here is what it looks like when in use. What do you think?

#### dwsmith

##### Well-known member
Re: Syntax highlighting

I might have found something we can use, but it needs to be tested more. There is syntax-highlighting freeware called Geshi and someone wrote a vBulletin plugin for it. It has functionality for a bunch of languages, including $\LaTeX$. Here is what it looks like when in use. What do you think?

View attachment 1076
When will it be implemented?

#### Jameson

Staff member
Re: Syntax highlighting

Testing that this works.

[LATEXS]% Example LaTeX document for GP111 - note % sign indicates a comment
\documentstyle[11pt]{article}
% Default margins are too wide all the way around. I reset them here
\setlength{\topmargin}{-.5in}
\setlength{\textheight}{9in}
\setlength{\oddsidemargin}{.125in}
\setlength{\textwidth}{6.25in}
\begin{document}
\title{LaTeX Typesetting By Example}
\author{Phil Farrell\\
Stanford University School of Earth Sciences}
\renewcommand{\today}{November 2, 1994}
\maketitle
Compare the typeset output side-by-side with the input document.[/LATEXS]

Before I make any announcement about this, is this highlighting pattern good enough for us to use long term?

#### dwsmith

##### Well-known member
How do we make use of it? Is there a button for it?

#### Jameson

Staff member
How do we make use of it? Is there a button for it?
I was holding off on explaining this until I got positive feedback. For now you must type out the BBCode tags:

[LATEXS]...[/LATEXS]

(the "S" stands for source code and using this convention will make knowing the BBCode tag for another programming language easy - the name of it with an "S")

I can change this though and if we want to choose a different tag name then we should decide that now. Once we do that I can work on adding a button to the toolbar.

#### Chris L T521

##### Well-known member
Staff member
I was holding off on explaining this until I got positive feedback. For now you must type out the BBCode tags:

[LATEXS]...[/LATEXS]

(the "S" stands for source code and using this convention will make knowing the BBCode tag for another programming language easy - the name of it with an "S")

I can change this though and if we want to choose a different tag name then we should decide that now. Once we do that I can work on adding a button to the toolbar.
I think TEXSRC (TeX Source Code) would be a better bbtag, but that's just me; it just flows better in my head.

#### Jameson

Staff member
Hmm, that thread looks perfect now to me. Is it fixed on your end as well?

#### dwsmith

##### Well-known member
Hmm, that thread looks perfect now to me. Is it fixed on your end as well?
It is not fixed on my end--still looks the same.

#### Jameson

Staff member
How does that look to you? To me there aren't any errors.
It works for me.