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

  • Thread starter Thread starter jackmell
  • Start date Start date
AI Thread Summary
The discussion centers on the desire to enhance code blocks in forum posts by allowing users to specify the type of code, such as "Mathematica Code," through an editable tag. Participants express that this feature would improve clarity without needing to explain the code type explicitly. There is also a concern about the current behavior of the CODE wrap, which does not fully disable interpretation, leading to issues with reproducing code accurately. Suggestions include creating specific tags for different programming languages or allowing a parameter in the code command to customize the label. Implementing these changes could facilitate better communication and support for newcomers in the forum.
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:
\sqrt{1-\frac{v^2}{c^2}}

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.
 
I want to thank those members who interacted with me a couple of years ago in two Optics Forum threads. They were @Drakkith, @hutchphd, @Gleb1964, and @KAHR-Alpha. I had something I wanted the scientific community to know and slipped a new idea in against the rules. Thank you also to @berkeman for suggesting paths to meet with academia. Anyway, I finally got a paper on the same matter as discussed in those forum threads, the fat lens model, got it peer-reviewed, and IJRAP...
About 20 years ago, in my mid-30s (and with a BA in economics and a master's in business), I started taking night classes in physics hoping to eventually earn the science degree I'd always wanted but never pursued. I found physics forums and used it to ask questions I was unable to get answered from my textbooks or class lectures. Unfortunately, work and life got in the way and I never got further the freshman courses. Well, here it is 20 years later. I'm in my mid-50s now, and in a...

Similar threads

Back
Top