Author Topic: Formatting code in your posts ...  (Read 4439 times)

0 Members and 1 Guest are viewing this topic.

MP

  • Seagull
  • Posts: 15802
  • Don't be so open-minded that your brains fall out.
Formatting code in your posts ...
« on: March 17, 2005, 08:31:36 am »
If you include code in a post like this --



It will be published (left justified) like this --

(defun c:MyProgram ( / input )

;;  get input from user

(setq input (getstring "nEnter input: "))

;;  echo user's input

(princ (strcat "You entered <" input ">.\n"))

;;  shhh

(princ)

)

Whereas if you enclose the code in code tags like this --



It will be published like this --

Code: [Select]
(defun c:MyProgram ( / input )

    ;;  get input from user

    (setq input (getstring "nEnter input: "))

    ;;  echo user's input

    (princ (strcat "You entered <" input ">.\n"))

    ;;  shhh

    (princ)

)

Much easier to read.

:)
\|// Set goal. Experiment tirelessly until
|oo| practice has become expertise.  Loop.
|- | Dropbox | O'Reilly School | UltraEdit

Mark

  • Custom Title
  • Administrator
  • Seagull
  • Posts: 24083
Re: Formatting code in your posts ...
« Reply #1 on: December 13, 2011, 01:50:53 pm »
New Instructions:

Formatting your code for best results at the TheSwamp.org.

When posting code to the swamp please use CODE tags to automatically format the code, otherwise it will be formatted for standard text, i.e. it will be posted in a proportional font, will loose indentation etc.

TheSwamp.org offers two types of CODE formatting; a generic CODE tag, e.g. [code]...your code...[/code], which honors indentation and uses a fixed width font.

It displays your code like this:

Code: [Select]
(defun c:MyProgram ( / input )
    ;;  get input from user
    (setq input (getstring "nEnter input: "))
    ;;  echo user's input
    (princ (strcat "You entered <" input ">.\n"))
    ;;  shhh
    (princ)
)

To use this CODE tag, use the [code]...your code...[/code] format as noted above, for example:

[code]
      ...
      your code
      ...
[/code]


The other type of CODE formatting employs a custom tagging mechanism, e.g. [code=cadlisp-7]...your code...[/code]. It offers syntax highlighting (in addition to honoring indentation and the use of a fixed width font), and in some cases adds URL links to function names for quick help.

It displays your code like this:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:MyProgram ( / input )
  2.    ;;  get input from user
  3.    (setq input (getstring "nEnter input: "))
  4.    ;;  echo user's input
  5.    (princ (strcat "You entered <" input ">.\n"))
  6.    ;;  shhh
  7.    (princ)
  8. )

Note that some items above are URL linked to quick help, try it by clicking defun or setq above.

To use this CODE tag, use the [code=cadlisp-7]...your code...[/code] format mentioned above, for example:

[code=cadlisp-7]
      ...
      your code
      ...
[/code]


TheSwamp.org has added this second CODE formatting ability by using a program called GeSHi -- a generic syntax highlighter which is capable of highlighting over 200 different programming languages.

Some of the most popular languages supported on this forum are:

    [code=cadlisp-7]
    [code=csharp]
    [code=cpp]
    [code=cpp-qt]
    [code=html]
    [code=python]
    [code=vb]
    [code=vbnet]

TheSwamp.org  (serving the CAD community since 2003)