Before posting source code, please read this....

  • Context: MHB 
  • Thread starter Thread starter MarkFL
  • Start date Start date
  • Tags Tags
    Code Source
Click For Summary
SUMMARY

The MHB Community discussion highlights the tools available for formatting source code in forum posts, specifically focusing on buttons that preserve whitespace and indentation for better readability. Users can utilize buttons for general code, HTML, and PHP, or apply keyboard shortcuts for fixed-width font and noparse tags. Suggestions were made to enhance user experience by improving tooltip descriptions for less obvious tags, which have been implemented with additional JavaScript. A new button for the [m] tags was also introduced, along with an explanatory tooltip.

PREREQUISITES
  • Understanding of forum posting tools and formatting options
  • Familiarity with HTML and PHP code structures
  • Knowledge of keyboard shortcuts for text formatting
  • Basic JavaScript for tooltip enhancements
NEXT STEPS
  • Explore advanced HTML formatting techniques for forums
  • Learn about JavaScript tooltip implementation for user interfaces
  • Research best practices for code readability in online discussions
  • Investigate keyboard shortcuts for efficient text editing in various platforms
USEFUL FOR

This discussion is beneficial for forum moderators, web developers, and users who frequently post code snippets, as well as anyone looking to enhance their online communication through improved formatting tools.

MarkFL
Gold Member
MHB
Messages
13,284
Reaction score
12
Hello, MHB Community! (Wave)

We have several tools on our toolbar that make posted source code stand out and preserve whitespace so that your indentation is preserved, making it easier to read and copy/paste for those who wish to take it and run it for testing.

For general code, you will find this button useful:

View attachment 5302

Next to that button, you will find buttons specifically for HTML and PHP code. Click the appropriate button, and then paste your code in between the generated tags, or paste your code into your post, then select it, and click the appropriate button to wrap the selected text in the tags.

Thanks! :D
 

Attachments

  • codetoolbar.png
    codetoolbar.png
    18.5 KB · Views: 169
Technology news on Phys.org
I have a related question and a suggestion.

Is there a button for fixed-width font?

It might be better to change the bubble hints to provide the description of the tag rather than just the tag's name. For example, I may not know what the sp tags does.
 
Evgeny.Makarov said:
Is there a button for fixed-width font?

No, but we do have keyboard shortcuts for it and the noparse tags:

[CTRL][M] = [m][/m] tags - monospace, with gray background.
[CTRL][Q] = [noparse][/noparse] tags.

Evgeny.Makarov said:
It might be better to change the bubble hints to provide the description of the tag rather than just the tag's name. For example, I may not know what the sp tags does.

Great suggestion! (Yes) I have added some javascript to do just that for several of the less obvious tags. :)

edit: I added a button for the [m][/m] tags:

View attachment 5316

And added an explanation of the button to its tooltip. (Yes)
 

Attachments

  • mlinebutton.png
    mlinebutton.png
    8.3 KB · Views: 137

Similar threads

  • · Replies 22 ·
Replies
22
Views
6K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
Replies
11
Views
2K
  • Sticky
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 15 ·
Replies
15
Views
7K
  • · Replies 3 ·
Replies
3
Views
2K