### Properties File Syntax Example Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/properties/index.html An example of the syntax supported by the properties mode, including key-value pairs, comments using # or !, and multi-line entries using backslashes. ```properties # This is a properties file a.key = A value another.key = http://example.com ! Exclamation mark as comment but.not=Within ! A value # indeed # Spaces at the beginning of a line spaces.before.key=value backslash=Used for multi\ line entries,\ that's convenient. # Unicode sequences unicode.key=This is \u0020 Unicode no.multiline=here # Colons colons : can be used too # Spaces spaces\ in\ keys=Not very common... ``` -------------------------------- ### C-like Language Syntax Examples Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/clike/index.html A collection of syntax examples for C, C++, Objective-C, Java, and Scala to be used for testing language mode highlighting. ```c #include #include #include typedef struct { void* arg_socket; int signal_fd; } acl_zmq_context; void* zmq_thread(void* context_pointer) { acl_zmq_context* context = (acl_zmq_context*)context_pointer; return 0; } ``` ```cpp #include namespace { enum Enum { VAL1, VAL2, VAL3 }; int Helper(const MyType& param) { return 0; } } ``` ```objective-c #import @implementation YourAppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { return YES; } ``` ```java public class Class implements MyInterface { public static final MyType member; @Override public MyType method() { return member; } } ``` ```scala object FilterTest extends App { def filter(xs: List[Int], threshold: Int) = { xs.filter(_ < threshold) } } ``` -------------------------------- ### Cython Example Syntax Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/python/index.html Example of Cython code demonstrating C-type declarations and decorators for performance optimization. ```python import numpy as np cimport cython from libc.math cimport sqrt @cython.boundscheck(False) @cython.wraparound(False) def pairwise_cython(double[:, ::1] X): cdef int M = X.shape[0] cdef int N = X.shape[1] cdef double tmp, d cdef double[:, ::1] D = np.empty((M, M), dtype=np.float64) for i in range(M): for j in range(M): d = 0.0 for k in range(N): tmp = X[i, k] - X[j, k] d += tmp * tmp D[i, j] = sqrt(d) return np.asarray(D) ``` -------------------------------- ### Puppet Module Example: automysqlbackup Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/puppet/index.html A comprehensive Puppet module for installing and configuring AutoMySQLBackup, a tool for periodic MySQL backups. It defines parameters for backup directories, installation paths, and configuration options, and ensures necessary packages are installed. ```puppet # == Class: automysqlbackup # # Puppet module to install AutoMySQLBackup for periodic MySQL backups. # # class { 'automysqlbackup': # backup_dir => '/mnt/backups', # } class automysqlbackup ( $bin_dir = $automysqlbackup::params::bin_dir, $etc_dir = $automysqlbackup::params::etc_dir, $backup_dir = $automysqlbackup::params::backup_dir, $install_multicore = undef, $config = {}, $config_defaults = {}, ) inherits automysqlbackup::params { # Ensure valid paths are assigned validate_absolute_path($bin_dir) validate_absolute_path($etc_dir) validate_absolute_path($backup_dir) # Create a subdirectory in /etc for config files file { $etc_dir: ensure => directory, owner => 'root', group => 'root', mode => '0750' } # Create an example backup file, useful for reference file { "${etc_dir}/automysqlbackup.conf.example": ensure => file, owner => 'root', group => 'root', mode => '0660', source => 'puppet:///modules/automysqlbackup/automysqlbackup.conf' } # Add files from the developer file { "${etc_dir}/AMB_README": ensure => file, source => 'puppet:///modules/automysqlbackup/AMB_README' } file { "${etc_dir}/AMB_LICENSE": ensure => file, source => 'puppet:///modules/automysqlbackup/AMB_LICENSE' } # Install the actual binary file file { "${bin_dir}/automysqlbackup": ensure => file, owner => 'root', group => 'root', mode => '0755', source => 'puppet:///modules/automysqlbackup/automysqlbackup' } # Create the base backup directory file { $backup_dir: ensure => directory, owner => 'root', group => 'root', mode => '0755' } # If you'd like to keep your config in hiera and pass it to this class if !empty($config) { create_resources('automysqlbackup::backup', $config, $config_defaults) } # If using RedHat family, must have the RPMforge repo's enabled if $install_multicore { package { ['pigz', 'pbzip2']: ensure => installed } } } ``` -------------------------------- ### Full Editor.md Configuration and Dynamic Content Appending Source: https://github.com/pandao/editor.md/blob/master/examples/auto-height.html A complete setup example including path configuration, feature enabling (tex, emoji, etc.), and a jQuery click handler to append markdown content from an external file. ```javascript var testEditor; $(function() { testEditor = editormd("test-editormd", { width : "90%", autoHeight : true, path : "../lib/", htmlDecode : "style,script,iframe", tex : true, emoji : true, taskList : true, flowChart : true, sequenceDiagram : true }); $("#append-btn").click(function(){ $.get("./test.md", function(md){ testEditor.appendMarkdown(md); }); }); }); ``` -------------------------------- ### Python Example Syntax Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/python/index.html Example of Python code demonstrating class definitions, decorators, and basic logic that the mode is designed to highlight. ```python import os from package import ParentClass @nonsenseDecorator def doesNothing(): pass class ExampleClass(ParentClass): @staticmethod def example(inputStr): a = list(inputStr) a.reverse() return ''.join(a) def __init__(self, mixin = 'Hello'): self.mixin = mixin ``` -------------------------------- ### TOML Example Syntax Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/toml/index.html This snippet showcases the basic syntax of the TOML (Tom's Obvious, Minimal Language) format. It includes examples of key-value pairs, tables, arrays, and dates. TOML is designed for configuration files. ```toml # This is a TOML document. Boom. title = "TOML Example" [owner] name = "Tom Preston-Werner" organization = "GitHub" bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." dob = 1979-05-27T07:32:00Z # First class dates? Why not? [database] server = "192.168.1.1" ports = [ 8001, 8001, 8002 ] connection_max = 5000 enabled = true [servers] # You can indent as you please. Tabs or spaces. TOML don't care. [servers.alpha] ip = "10.0.0.1" dc = "eqdc10" [servers.beta] ip = "10.0.0.2" dc = "eqdc10" [clients] data = [ ["gamma", "delta"], [1, 2] ] # Line breaks are OK when inside arrays hosts = [ "alpha", "omega" ] ``` -------------------------------- ### Groovy Scripting Examples Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/groovy/index.html A collection of Groovy scripts demonstrating file system traversal using regex patterns and enum-based logic for currency conversion. These examples illustrate the syntax supported by the Groovy mode. ```groovy //Pattern for groovy script def p = ~/.*\.groovy/ new File( 'd:\\scripts' ).eachFileMatch(p) {f -> // imports list def imports = [] f.eachLine { // condition to detect an import instruction ln -> if ( ln =~ '^import .*' ) { imports << "${ln - 'import '}" } } // print thmen if ( ! imports.empty ) { println f imports.each{ println " $it" } } } /* Coin changer demo code */ enum UsCoin { quarter(25), dime(10), nickel(5), penny(1) UsCoin(v) { value = v } final value } def plural(word, count) { if (count == 1) return word word[-1] == 'y' ? word[0..-2] + "ies" : word + "s" } def change(currency, amount) { currency.values().inject([]){ list, coin -> int count = amount / coin.value amount = amount % coin.value list += "$count ${plural(coin.toString(), count)}" } } ``` -------------------------------- ### YAML Syntax Examples Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/yaml/index.html This snippet provides examples of various YAML syntaxes, including lists, indented blocks, inline blocks, and multi-line strings. These examples demonstrate how YAML uses indentation and specific characters to structure data. ```yaml --- # Favorite movies - Casablanca - North by Northwest - The Man Who Wasn't There --- # Shopping list [milk, pumpkin pie, eggs, juice] --- # Indented Blocks, common in YAML data files, use indentation and new lines to separate the key: value pairs name: John Smith age: 33 --- # Inline Blocks, common in YAML data streams, use commas to separate the key: value pairs between braces {name: John Smith, age: 33} --- receipt: Oz-Ware Purchase Invoice date: 2007-08-06 customer: given: Dorothy family: Gale items: - part_no: A4786 descrip: Water Bucket (Filled) price: 1.47 quantity: 4 - part_no: E1628 descrip: High Heeled "Ruby" Slippers size: 8 price: 100.27 quantity: 1 bill-to: &id001 street: | 123 Tornado Alley Suite 16 city: East Centerville state: KS ship-to: *id001 specialDelivery: > Follow the Yellow Brick Road to the Emerald City. Pay no attention to the man behind the curtain. ... ``` -------------------------------- ### FlowChart Syntax Example Source: https://github.com/pandao/editor.md/blob/master/examples/flowchart.html This snippet shows the basic syntax for creating a flowchart using the flowchart.js library. It defines nodes for start, operation, condition, and end, and connects them to illustrate a simple user login flow. ```flow st=>start: User login op=>operation: Operation cond=>condition: Successful Yes or No? e=>end: Into admin st->op->cond cond(yes)->e cond(no)->op ``` -------------------------------- ### NGINX Server Configuration Example Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/nginx/index.html A comprehensive NGINX configuration example showing server blocks, URL rewriting, location directives, and PHP-FPM integration. This configuration is typical for Magento environments. ```nginx server { listen 173.255.219.235:80; server_name website.com.au; rewrite / $scheme://www.$host$request_uri permanent; } server { listen 173.255.219.235:80; server_name www.website.com.au; root /data/www; index index.html index.php; location / { try_files $uri $uri/ @handler; expires 30d; } location /app/ { deny all; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include /rs/confs/nginx/fastcgi_params; } } ``` -------------------------------- ### Underscore.coffee - Baseline Setup and Helpers Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/coffeescript/index.html This section of Underscore.coffee demonstrates the baseline setup, including establishing the root object (window/global), saving previous underscore variables, and defining helper functions like escapeRegExp. It also sets up references to native Array and Object prototypes for efficiency. ```coffeescript # Establish the root object, `window` in the browser, or `global` on the server. root = this # Save the previous value of the `_` variable. previousUnderscore = root._ ### Multiline comment ### # Establish the object that gets thrown to break out of a loop iteration. # `StopIteration` is SOP on Mozilla. breaker = if typeof(StopIteration) is 'undefined' then '__break__' else StopIteration #### Docco style single line comment (title) # Helper function to escape **RegExp** contents, because JS doesn't have one. escapeRegExp = (string) -> string.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1') # Save bytes in the minified (but not gzipped) version: ArrayProto = Array.prototype ObjProto = Object.prototype # Create quick reference variables for speed access to core prototypes. slice = ArrayProto.slice unshift = ArrayProto.unshift toString = ObjProto.toString hasOwnProperty = ObjProto.hasOwnProperty propertyIsEnumerable = ObjProto.propertyIsEnumerable # All **ECMA5** native implementations we hope to use are declared here. nativeForEach = ArrayProto.forEach nativeMap = ArrayProto.map nativeReduce = ArrayProto.reduce nativeReduceRight = ArrayProto.reduceRight nativeFilter = ArrayProto.filter nativeEvery = ArrayProto.every nativeSome = ArrayProto.some nativeIndexOf = ArrayProto.indexOf nativeLastIndexOf = ArrayProto.lastIndexOf nativeIsArray = Array.isArray nativeKeys = Object.keys # Create a safe reference to the Underscore object for use below. _ = (obj) -> new wrapper(obj) # Export the Underscore object for **CommonJS**. if typeof(exports) != 'undefined' then exports._ = _ # Export Underscore to global scope. root._ = _ # Current version. _.VERSION = '1.1.0' ``` -------------------------------- ### SLIM Templating Syntax Examples Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/slim/index.html A collection of examples showcasing various SLIM templating syntax elements. This includes HTML structure, attribute definitions, conditional logic, loops, comments, and text interpolation. ```slim body table - for user in users td id="user_#{user.id}" class=user.role a href=user_action(user, :edit) Edit #{user.name} a href=(path_to_user user) = user.name body h1(id="logo") = page_logo h2[id="tagline" class="small tagline"] = page_tagline h2[id="tagline" class="small tagline"] = page_tagline h1 id = "logo" = page_logo h2 [ id = "tagline" ] = page_tagline / comment second line /! html comment second line link a.slim href="work" disabled=false running==:atom Text bold .clazz data-id="test" == 'hello' unless quark | Text mode #{12} Second line = x ||= :ruby_atom #menu.left - @env.each do |x| li: a = x *@dyntag attr="val" .first *{:class => [:second, :third]} Text .second class=["text","more"] .third class=:text,:symbol ``` -------------------------------- ### Verilog/SystemVerilog Syntax Example Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/verilog/index.html Demonstrates various Verilog/SystemVerilog language constructs including literals, macro definitions, module definitions, class definitions, and tasks. ```verilog // Literals 1'b0 1'bx 1'bz 16'hDC78 'hdeadbeef 'b0011xxzz 1234 32'd5678 3.4e6 -128.7 // Macro definition `define BUS_WIDTH = 8; // Module definition module block( input clk, input rst_n, input [`BUS_WIDTH-1:0] data_in, output [`BUS_WIDTH-1:0] data_out ); always @(posedge clk or negedge rst_n) begin if (~rst_n) begin data_out <= 8'b0; end else begin data_out <= data_in; end if (~rst_n) data_out <= 8'b0; else data_out <= data_in; if (~rst_n) begin data_out <= 8'b0; end else begin data_out <= data_in; end end endmodule // Class definition class test; /** * Sum two integers */ function int sum(int a, int b); int result = a + b; string msg = $sformatf("%d + %d = %d", a, b, result); $display(msg); return result; endfunction task delay(int num_cycles); repeat(num_cycles) #1; endtask endclass ``` -------------------------------- ### Initialize Editor.md with Options Source: https://github.com/pandao/editor.md/blob/master/examples/page-break.html Initializes the Editor.md instance with specified dimensions and path to libraries. This is the fundamental setup for using the editor. ```javascript var testEditor; $(function() { testEditor = editormd("test-editormd", { width : "90%", height : 720, path : "../lib/" }); }); ``` -------------------------------- ### Shell Script Server Management Workflow Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/shell/index.html A bash script example that clones a repository, generates SSL credentials, starts a Node.js server in HTTPS mode, and provides a mechanism to terminate the process. ```bash #!/bin/bash # clone the repository git clone http://github.com/garden/tree # generate HTTPS credentials cd tree openssl genrsa -aes256 -out https.key 1024 openssl req -new -nodes -key https.key -out https.csr openssl x509 -req -days 365 -in https.csr -signkey https.key -out https.crt cp https.key{,.orig} openssl rsa -in https.key.orig -out https.key # start the server in HTTPS mode cd web sudo node ../server.js 443 'yes' >> ../node.log & # here is how to stop the server for pid in `ps aux | grep 'node ../server.js' | awk '{print $2}'` ; do sudo kill -9 $pid 2> /dev/null done exit 0 ``` -------------------------------- ### R Language Syntax Example Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/r/index.html Example R code demonstrating list creation, function definition, and return values, used for testing the R mode implementation. ```r X = list(height=5.4, weight=54) print(X) square <- function(x) { return(x*x) } cube <- function(x=5) { return(x*x*x); } powers <- function(x) { parcel = list(x2=x*x, x3=x*x*x, x4=x*x*x*x); return(parcel); } ``` -------------------------------- ### F# Language Syntax Examples Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/mllike/index.html Basic F# syntax examples including recursive functions, discriminated unions, records, and pipeline operations. ```F# module CodeMirror.FSharp let rec fib = function | 0 -> 0 | 1 -> 1 | n -> fib (n - 1) + fib (n - 2) type Point = { x : int; y : int } type Color = | Red | Green | Blue [0 .. 10] |> List.map ((+) 2) |> List.fold (fun x y -> x + y) 0 |> printf "%i" ``` -------------------------------- ### Forth Syntax Example Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/forth/index.html A sample implementation of an insertion sort algorithm written in Forth, demonstrating the syntax supported by the mode. ```forth \ Insertion sort : cell- 1 cells - ; : insert ( start end -- start ) dup @ >r ( r: v ) begin 2dup < while r@ over cell- @ < while cell- dup @ over cell+ ! repeat then r> swap ! ; : sort ( array len -- ) 1 ?do dup i cells + insert loop drop ; ``` -------------------------------- ### Gas Mode Initialization Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/gas/index.html Example of how to initialize CodeMirror with the Gas mode, including optional architecture configuration. ```APIDOC ## Gas Mode Initialization ### Description Initializes CodeMirror with the Gas mode, which supports AT&T assembler syntax. The `architecture` parameter can be specified for enhanced syntax highlighting of registers and directives. ### Method JavaScript Initialization ### Endpoint N/A (Client-side JavaScript) ### Parameters #### Configuration Options - **`mode`** (object) - Required - Configuration for the editor mode. - **`name`** (string) - Required - Set to "gas" for Gas mode. - **`architecture`** (string) - Optional - Specifies the target architecture. Can be one of: `"ARM"`, `"ARMv6"`, or `"x86"`. ### Request Example ```javascript var editor = CodeMirror.fromTextArea(document.getElementById("code"), { lineNumbers: true, mode: { name: "gas", architecture: "ARMv6" // or "ARM", "x86" } }); ``` ### Response N/A (Client-side initialization) ### MIME types defined `text/x-gas` ``` -------------------------------- ### Soy (Closure Template) Example Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/soy/index.html This snippet shows an example of a Soy (Closure Template) file structure, including namespace declaration, template definitions with parameters, conditional rendering, and JavaScript execution. ```soy {namespace example} /**** * Says hello to the world. ***/ {template .helloWorld} {@param name: string} {@param? score: number} Hello {$name}!
{if $score} {$score} points {else} no score {/if}
{/template} {template .alertHelloWorld kind="js"} alert('Hello World'); {/template} ``` -------------------------------- ### Pascal Example Code Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/pascal/index.html This snippet showcases various Pascal control structures and syntax, including loops, conditionals, and case statements. It serves as an example for syntax highlighting. ```pascal (* Example Pascal code *) while a <> b do writeln('Waiting'); if a > b then writeln('Condition met') else writeln('Condition not met'); for i := 1 to 10 do writeln('Iteration: ', i:1); repeat a := a + 1 until a = 10; case i of 0: write('zero'); 1: write('one'); 2: write('two') end; ``` -------------------------------- ### Example Cypher Query Syntax Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/cypher/index.html An example of Cypher query syntax, demonstrating pattern matching, WHERE clauses, and RETURN statements. This highlights the structure and keywords recognized by the Cypher mode. ```cypher MATCH (joe { name: 'Joe' })-[:knows*2..2]-(friend_of_friend) WHERE NOT (joe)-[:knows]-(friend_of_friend) RETURN friend_of_friend.name, COUNT(*) ORDER BY COUNT(*) DESC , friend_of_friend.name ``` -------------------------------- ### Haxe and Hxml Syntax Examples Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/haxe/index.html Sample code demonstrating the syntax supported by the Haxe and Hxml modes in CodeMirror. ```haxe import one.two.Three; @attr("test") class Foo extends Three { public function new() { noFoo = 12; } public static inline function doFoo(obj:{k:Int, l:Float}):Int { for(i in 0...10) { obj.k++; trace(i); var var1 = new Array(); if(var1.length > 1) throw "Error"; } return obj.k; } } ``` ```hxml -cp test -js path/to/file.js #-remap nme:flash --next -D source-map-content -cmd 'test' -lib lime ``` -------------------------------- ### SPARQL Query Example Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/sparql/index.html An example SPARQL query demonstrating various clauses like PREFIX, SELECT, WHERE, OPTIONAL, UNION, MINUS, and FILTER. This query retrieves information about creators and their names. ```sparql PREFIX a: PREFIX dc: PREFIX foaf: PREFIX rdfs: # Comment! SELECT ?given ?family WHERE { { ?annot a:annotates . ?annot dc:creator ?c . OPTIONAL {?c foaf:givenName ?given ; foaf:familyName ?family } } UNION { ?c !foaf:knows/foaf:knows? ?thing. ?thing rdfs } MINUS { ?thing rdfs:label "剛柔流"@jp } FILTER isBlank(?c) } ``` -------------------------------- ### Smalltalk Example: Seaside Counter Component Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/smalltalk/index.html A simple Smalltalk example demonstrating a Seaside web component for a counter. It includes initialization, state management, and rendering logic for incrementing and decrementing the count via HTML anchors. ```smalltalk " This is a test of the Smalltalk code " Seaside.WAComponent subclass: #MyCounter [ | count | MyCounter class >> canBeRoot ^true ] initialize super initialize. count := 0. ] states ^{ self } ] renderContentOn: html [ html heading: count. html anchor callback: [ count := count + 1 ]; with: '++'. html space. html anchor callback: [ count := count - 1 ]; with: '--'. ] ] ``` -------------------------------- ### Asterisk Dialplan Configuration Example Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/asterisk/index.html A sample Asterisk dialplan configuration file (extensions.conf). It demonstrates various contexts, extensions, macros, and functions used in Asterisk. ```asterisk ; extensions.conf - the Asterisk dial plan ; [general] ; static=yes #include "/etc/asterisk/additional_general.conf" [iaxprovider] switch => IAX2/user:[key]@myserver/mycontext [dynamic] #exec /usr/bin/dynamic-peers.pl [trunkint] ; International long distance through trunk exten => _9011.,1,Macro(dundi-e164,${EXTEN:4}) exten => _9011.,n,Dial(${GLOBAL(TRUNK)}/${FILTER(0-9,${EXTEN:${GLOBAL(TRUNKMSD)}})}) [local] ; Master context for local, toll-free, and iaxtel calls only ignorepat => 9 include => default [demo] include => stdexten ; We start with what to do when a call first comes in. exten => s,1,Wait(1) ; Wait a second, just for fun same => n,Answer ; Answer the line same => n,Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds same => n,Set(TIMEOUT(response)=10) ; Set Response Timeout to 10 seconds same => n(restart),BackGround(demo-congrats) ; Play a congratulatory message same => n(instruct),BackGround(demo-instruct) ; Play some instructions same => n,WaitExten ; Wait for an extension to be dialed. exten => 2,1,BackGround(demo-moreinfo) ; Give some more information. exten => 2,n,Goto(s,instruct) exten => 3,1,Set(LANGUAGE()=fr) ; Set language to french exten => 3,n,Goto(s,restart) ; Start with the congratulations exten => 1000,1,Goto(default,s,1) ; We also create an example user, 1234, who is on the console and has ; voicemail, etc. ; exten => 1234,1,Playback(transfer,skip) ; "Please hold while..." ; (but skip if channel is not up) exten => 1234,n,Gosub(${EXTEN},stdexten(${GLOBAL(CONSOLE)})) exten => 1234,n,Goto(default,s,1) ; exited Voicemail exten => 1235,1,Voicemail(1234,u) ; Right to voicemail exten => 1236,1,Dial(Console/dsp) ; Ring forever exten => 1236,n,Voicemail(1234,b) ; Unless busy ; # for when they're done with the demo exten => #,1,Playback(demo-thanks) ; "Thanks for trying the demo" exten => #,n,Hangup ; Hang them up. ; A timeout and "invalid extension rule" exten => t,1,Goto(#,1) ; If they take too long, give up exten => i,1,Playback(invalid) ; "That's not valid, try again" ; Create an extension, 500, for dialing the ; Asterisk demo. exten => 500,1,Playback(demo-abouttotry); Let them know what's going on exten => 500,n,Dial(IAX2/guest@pbx.digium.com/s@default) ; Call the Asterisk demo exten => 500,n,Playback(demo-nogo) ; Couldn't connect to the demo site exten => 500,n,Goto(s,6) ; Return to the start over message. ; Create an extension, 600, for evaluating echo latency. exten => 600,1,Playback(demo-echotest) ; Let them know what's going on exten => 600,n,Echo ; Do the echo test exten => 600,n,Playback(demo-echodone) ; Let them know it's over exten => 600,n,Goto(s,6) ; Start over ; You can use the Macro Page to intercom a individual user exten => 76245,1,Macro(page,SIP/Grandstream1) ; or if your peernames are the same as extensions exten => _7XXX,1,Macro(page,SIP/${EXTEN}) ; System Wide Page at extension 7999 exten => 7999,1,Set(TIMEOUT(absolute)=60) exten => 7999,2,Page(Local/Grandstream1@page&Local/Xlite1@page&Local/1234@page/n) ; Give voicemail at extension 8500 exten => 8500,1,VoicemailMain exten => 8500,n,Goto(s,6) ``` -------------------------------- ### SCSS Syntax Example Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/css/scss.html This is an example of SCSS code, showcasing various features like variables, nesting, mixins, and extends. This code is intended to be highlighted by the CodeMirror SCSS mode. ```scss /* Some example SCSS */ @import "compass/css3"; $variable: #333; $blue: #3bbfce; $margin: 16px; .content-navigation { #nested { background-color: black; } border-color: $blue; color: darken($blue, 9%); } .border { padding: $margin / 2; margin: $margin / 2; border-color: $blue; } @mixin table-base { th { text-align: center; font-weight: bold; } td, th { padding: 2px; } } table.hl { margin: 2em 0; td.ln { text-align: right; } } li { font: { family: serif; weight: bold; size: 1.2em; } } @mixin left($dist) { float: left; margin-left: $dist; } #data { @include left(10px); @include table-base; } .source { @include flow-into(target); border: 10px solid green; margin: 20px; width: 200px; } .new-container { @include flow-from(target); border: 10px solid red; margin: 20px; width: 200px; } body { margin: 0; padding: 3em 6em; font-family: tahoma, arial, sans-serif; color: #000; } @mixin yellow() { background: yellow; } .big { font-size: 14px; } .nested { @include border-radius(3px); @extend .big; p { background: whitesmoke; a { color: red; } } } #navigation a { font-weight: bold; text-decoration: none !important; } h1 { font-size: 2.5em; } h2 { font-size: 1.7em; } h1:before, h2:before { content: "::"; } code { font-family: courier, monospace; font-size: 80%; color: #418A8A; } ``` -------------------------------- ### OCaml Language Syntax Examples Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/mllike/index.html A collection of OCaml code snippets demonstrating recursion, pattern matching, polymorphism, imperative features, and graphics using Glut. ```OCaml let rec sum xs = match xs with | [] -> 0 | x :: xs' -> x + sum xs' let rec qsort = function | [] -> [] | pivot :: rest -> let is_less x = x < pivot in let left, right = List.partition is_less rest in qsort left @ [pivot] @ qsort right let rec fib_aux n a b = match n with | 0 -> a | _ -> fib_aux (n - 1) (a + b) a let square x = x * x;; let rec sort = function | [] -> [] | x :: l -> insert x (sort l) and insert elem = function | [] -> [elem] | x :: l -> if elem < x then elem :: x :: l else x :: insert elem l;; ``` -------------------------------- ### ECL Syntax Example Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/ecl/index.html A sample snippet demonstrating ECL syntax, including multiline comments, single-line comments, record definitions, and dataset operations. ```ecl /* sample useless code to demonstrate ecl syntax highlighting this is a multiline comment! */ // this is a singleline comment! import ut; r := record string22 s1 := '123'; integer4 i1 := 123; end; #option('tmp', true); d := dataset('tmp::qb', r, thor); output(d); ``` -------------------------------- ### Example Gas Syntax Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/gas/index.html A sample of GNU Assembler code demonstrating standard directives, labels, and comments that the Gas mode is designed to highlight. ```assembly .syntax unified .global main /* * A * multi-line * comment. */ @ A single line comment. main: push {sp, lr} ldr r0, =message bl puts mov r0, #0 pop {sp, pc} message: .asciz "Hello world!
" ``` -------------------------------- ### Kotlin HttpServer Implementation Example Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/kotlin/index.html A sample Kotlin class demonstrating an HTTP server implementation using Netty, which serves as a test case for the Kotlin syntax highlighting mode. ```kotlin package org.wasabi.http import java.util.concurrent.Executors import java.net.InetSocketAddress import org.wasabi.app.AppConfiguration import io.netty.bootstrap.ServerBootstrap import io.netty.channel.nio.NioEventLoopGroup import io.netty.channel.socket.nio.NioServerSocketChannel import org.wasabi.app.AppServer public class HttpServer(private val appServer: AppServer) { val bootstrap: ServerBootstrap val primaryGroup: NioEventLoopGroup val workerGroup: NioEventLoopGroup { primaryGroup = NioEventLoopGroup() workerGroup = NioEventLoopGroup() bootstrap = ServerBootstrap() bootstrap.group(primaryGroup, workerGroup) bootstrap.channel(javaClass()) bootstrap.childHandler(NettyPipelineInitializer(appServer)) } public fun start(wait: Boolean = true) { val channel = bootstrap.bind(appServer.configuration.port)?.sync()?.channel() if (wait) { channel?.closeFuture()?.sync() } } public fun stop() { primaryGroup.shutdownGracefully() workerGroup.shutdownGracefully() primaryGroup.terminationFuture().sync() workerGroup.terminationFuture().sync() } } ``` -------------------------------- ### Perl Syntax Example Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/perl/index.html A sample Perl script demonstrating various syntax features supported by the mode, including variable declarations, heredocs, regex operations, and POD documentation. ```perl #!/usr/bin/perl use Something qw(func1 func2); # strings my $s1 = qq'single line'; our $s2 = q(multi- line); =item Something Example. =cut my $html=<<'HTML'; hi! HTML print "first,".join(',', 'second', qq~third~); if($s1 =~ m\[(?{$1}=$$.' predefined variables'; $s2 =~ s/\-line//ox; $s1 =~ s\[ line \] \[ block \]ox; } 1; __END__ ``` -------------------------------- ### Stylus Syntax Example Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/stylus/index.html A sample snippet showcasing Stylus features like variables, mixins, and nested selectors that are supported by the CodeMirror Stylus mode. ```stylus font-size-base = 16px link-color = #428bca tab-focus() outline thin dotted a color link-color &:hover color darken(link-color, 15%) ``` -------------------------------- ### CSS Example for CodeMirror Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/css/index.html This snippet demonstrates typical CSS syntax that would be highlighted by the CodeMirror CSS mode. It includes imports, basic styling, and font definitions. ```css /* Some example CSS */ @import url("something.css"); body { margin: 0; padding: 3em 6em; font-family: tahoma, arial, sans-serif; color: #000; } #navigation a { font-weight: bold; text-decoration: none !important; } h1 { font-size: 2.5em; } h2 { font-size: 1.7em; } h1:before, h2:before { content: "::"; } code { font-family: courier, monospace; font-size: 80%; color: #418A8A; } ``` -------------------------------- ### Example Dockerfile Content Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/dockerfile/index.html A sample Dockerfile demonstrating common instructions like FROM, RUN, WORKDIR, and CMD. This content is intended to be used within the CodeMirror editor to test the syntax highlighting capabilities. ```dockerfile # Install Ghost blogging platform and run development environment # VERSION 1.0.0 FROM ubuntu:12.10 MAINTAINER Amer Grgic "amer@livebyt.es" WORKDIR /data/ghost RUN apt-get update RUN apt-get install -y python g++ make software-properties-common --force-yes RUN add-apt-repository ppa:chris-lea/node.js RUN apt-get update RUN apt-get install -y unzip RUN apt-get install -y curl RUN apt-get install -y rlwrap RUN apt-get install -y nodejs RUN curl -L https://ghost.org/zip/ghost-latest.zip -o /tmp/ghost.zip RUN unzip -uo /tmp/ghost.zip -d /data/ghost ADD ./config.example.js /data/ghost/config.js RUN cd /data/ghost/ && npm install --production EXPOSE 2368 CMD ["npm","start"] ``` -------------------------------- ### Jade Template Syntax Example Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/jade/index.html A sample snippet of Jade template code that demonstrates common syntax patterns such as doctype declaration, tag nesting, and conditional logic. ```jade doctype html html head title= "Jade Templating CodeMirror Mode Example" body div.header h1 Welcome to this Example div.spots if locals.spots each spot in spots div.spot.well h3= spot.title else h3 There are no spots currently available. ``` -------------------------------- ### GFM Fenced Code Block Example Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/gfm/index.html This is an example of a fenced code block within GitHub Flavored Markdown, demonstrating syntax highlighting for JavaScript. The triple backticks denote the start and end of the code block, and 'javascript' specifies the language for highlighting. ```markdown ```javascript for (var i = 0; i < items.length; i++) { console.log(items[i], i); // log them } ``` ``` -------------------------------- ### Initialize Basic Editor.md Instance Source: https://context7.com/pandao/editor.md/llms.txt Demonstrates how to create a simple Editor.md instance with default settings. It requires HTML structure with a textarea and includes necessary CSS and JavaScript files. The output is a split view of Markdown source and HTML preview. ```html
``` -------------------------------- ### Basic Editor Initialization Source: https://context7.com/pandao/editor.md/llms.txt Demonstrates how to create a simple Markdown editor instance with default settings. ```APIDOC ## Basic Editor Initialization Creates a simple Markdown editor instance with default settings. The editor automatically loads required dependencies and renders with a split view showing the Markdown source on the left and HTML preview on the right. ### Method HTML/JavaScript ### Endpoint N/A (Client-side library) ### Parameters N/A ### Request Example ```html
``` ### Response N/A (Client-side rendering) ``` -------------------------------- ### TypeScript Class Example Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/javascript/typescript.html A basic example of a TypeScript class structure that can be used to test syntax highlighting within the CodeMirror editor. ```typescript class Greeter { greeting: string; constructor (message: string) { this.greeting = message; } greet() { return "Hello, " + this.greeting; } } var greeter = new Greeter("world"); var button = document.createElement('button'); button.innerText = "Say Hello"; button.onclick = function() { alert(greeter.greet()); }; document.body.appendChild(button); ``` -------------------------------- ### Configure and Switch Editor Themes Source: https://context7.com/pandao/editor.md/llms.txt Demonstrates how to initialize the editor with specific themes and switch them dynamically at runtime. It covers the main editor, CodeMirror, and preview area themes. ```javascript var editor = editormd("editor", { width: "90%", height: 720, path: "lib/", theme: "dark", previewTheme: "dark", editorTheme: "pastel-on-dark" }); console.log(editormd.editorThemes); editor.setTheme("default"); editor.setEditorTheme("monokai"); editor.setCodeMirrorTheme("eclipse"); editor.setPreviewTheme("default"); editor.config({ theme: "dark", previewTheme: "dark", editorTheme: "ambiance" }); ``` -------------------------------- ### Sass Language Syntax Example Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/sass/index.html An example of Sass syntax, demonstrating variable definitions, global attributes, and scoped styles. This is illustrative and not directly executable code. ```sass // Variable Definitions $page-width: 800px $sidebar-width: 200px $primary-color: #eeeeee // Global Attributes body font: family: sans-serif size: 30em weight: bold // Scoped Styles #contents width: $page-width #sidebar float: right width: $sidebar-width #main width: $page-width - $sidebar-width background: $primary-color h2 color: blue #footer height: 200px ``` -------------------------------- ### Go Web Server with Beego Source: https://github.com/pandao/editor.md/blob/master/examples/change-mode.html A Go web application using the Beego framework to create a simple 'hello world' service. It defines a controller and a router to handle requests to the root URL. Dependencies include the Beego framework. ```Go package main import ( "github.com/astaxie/beego" ) type MainController struct { beego.Controller } func (this *MainController) Get() { this.Ctx.WriteString("hello world") } func main() { beego.Router("/", &MainController{}) beego.Run() } ``` -------------------------------- ### Initialize CodeMirror Python and Cython Editors Source: https://github.com/pandao/editor.md/blob/master/lib/codemirror/mode/python/index.html Demonstrates how to instantiate CodeMirror instances for Python and Cython text areas with specific configuration options like line numbering and indentation. ```javascript var editor = CodeMirror.fromTextArea(document.getElementById("code"), { mode: {name: "python", version: 3, singleLineStringErrors: false}, lineNumbers: true, indentUnit: 4, matchBrackets: true }); CodeMirror.fromTextArea(document.getElementById("code-cython"), { mode: {name: "text/x-cython", version: 2, singleLineStringErrors: false}, lineNumbers: true, indentUnit: 4, matchBrackets: true }); ```