Add code tag to [code] [/code] block

  • Context: Suggestion 
  • Thread starter Thread starter jackmell
  • Start date Start date
jackmell
Messages
1,806
Reaction score
54
Hi. Is there a way to add a tag to code blocks to identify what type of code it is? For example, in the code:

Code:
this is mathematica code

I think it would look classy if the word "code" above the block could be an editable field and I could get it to say "Mathematica Code". That way, I wouldn't have to explicitly tell the reader what type of code it is.
 
Physics news on Phys.org
Greg Bernhardt said:
This would be easy to add. Anyone else?

Ok, thanks for replying. I assume when you update the software, you post a list of enhancement. I'll keep an eye out to see if you've decided to add this to the list of enhancements.
 
If I wrap the code for the quote below in CODE tags:

yuiop said:
[tex]\sqrt{1-\frac{v^2}{c^2}}[/tex]

I get:

Code:
[QUOTE=yuiop]
[tex]\sqrt{1-\frac{v^2}{c^2}}[/tex]
[/QUOTE]

The forum software is obviously still interpreting what is inside the code box. Shouldn't the CODE wrap disable all interpretation and reproduce what is inside the CODE box without interference?

If I wrap the same code in PHP tags I get:
PHP:
[QUOTE=yuiop]
[tex]\sqrt{1-\frac{v^2}{c^2}}[/tex]
[/QUOTE]

This is closer to a faithful reproduction and what the CODE wrap should be doing, but it is still not perfect because it strips out the backslash before \sqrt for example.

To simulate what (I think) the CODE wrap should be doing, I have added comment prime symbols:

PHP:
'

[QUOTE=yuiop]
 [tex]\sqrt{1-\frac{v^2}{c^2}}[/tex] 
[/QUOTE]

'

Is that what the CODE wrap should ideally be doing? I think it would be useful if it did faithfully reproduce whatever was put inside it. Being able to show exactly what code is used would be useful when helping newcomers to the forum, because you can show them exactly what to type in. I seem to recall there is some code to disable interpretation, but I cannot find any reference to it here. I also think a TEX wrapper button or at least an ITEX button in the advanced editor would be handy for wrapping inline tex symbols in ITEX tags.
 
Last edited:
yuiop said:
If I wrap the same code in PHP tags I get:
PHP:

Not sure what you're trying to do there. But I can think of two suggestions to implement this:

(1) Just have a [/mathematica], [/matlab], [/cpp], etc., operators that would label the blocks of text as Mathematica Code, Matlab Code, C++ Code, and so forth.

(2) Provide a parameter to the code command so that I can include any string to precede the word code. For example, I could write [code{Mathematica}] or [code{mynewcode}] and it would print Mathematica Code or mynewcode Code as a label for the block.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
1K
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
55
Views
7K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K