Prev Next srccode

Displaying In Line Source Code

Syntax
See Also
Optional
Purpose
file_ext
Letter Case
Delimiter Sequence
Example
     Factorial Program

Syntax
$srccode%file_ext%source%$$

See Also
get started , srcfile , codep

Optional
This command is optional and only supported when the source_highlight library are successfully found; see the output printed by the cmake command .

Purpose
This command will display the specified program source code with highlighting and for the language corresponding to the specified file extension.

file_ext
The file extension file_ext does not include the dot .

Letter Case
Upper case letters versus lower case letters does not matter in file_ext . For example, the R programming language would correspond to file_ext equal to R or r.

Delimiter Sequence
     %file_ext%source%
is a delimiter sequence where % can be any character that is not a letter.

Example
All the characters, except the end of line character, in the first and last line of the srccode command are ignored. (There must be at least two newlines in text.) This enables the inclusion of source code that is actually compiled. For example, the input
 
     $tabsize 4$$
     $subhead Factorial Program$$ */
     $srccode%py%
          def factorial(n) :
               if n == 1 :
                    return 1
               return n * factorial(n-1)
          end
     /* %$$
would create the following output

Factorial Program
    def factorial(n) :
        if n == 1 :
            return 1
        return n * factorial(n-1)
    end

Input File: omh/srccode.omh