### Shell Script Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/shell/index.html This snippet demonstrates a typical shell script for cloning a repository, generating HTTPS credentials, and starting a server. It includes commands for key generation, certificate signing, and server startup, followed by a process to stop the server. ```shell #!/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 ``` -------------------------------- ### Install djangocodemirror for Development Source: https://github.com/sveetch/djangocodemirror/blob/master/docs/development.md Clone the repository and install the project in editable mode with development tools. ```default git clone https://github.com/sveetch/djangocodemirror.git cd djangocodemirror make install ``` -------------------------------- ### Prelude Installation in LiveScript Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/livescript/index.html Shows how to install the prelude, a collection of standard functions, onto a target object. This is a meta-programming utility for extending functionality. ```livescript # meta export installPrelude = !(target) -> unless target.prelude?isInstalled target <<< out$ # using out$ generated by livescript target <<< target.prelude.isInstalled = true export prelude = out$ ``` -------------------------------- ### Factor Code Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/factor/index.html This is an example of Factor code, demonstrating a simple time server. ```factor ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. ! A simple time server USING: accessors calendar calendar.format io io.encodings.ascii io.servers kernel threads ; IN: time-server : handle-time-client ( -- ) now timestamp>rfc822 print ; : ( -- threaded-server ) ascii "time-server" >>name 1234 >>insecure [ handle-time-client ] >>handler ; : start-time-server ( -- ) start-server drop ; MAIN: start-time-server ``` -------------------------------- ### Install djangocodemirror Package Source: https://github.com/sveetch/djangocodemirror/blob/master/docs/install.md Install the package using pip. For development, refer to the development installation guide. ```default pip install djangocodemirror ``` -------------------------------- ### Example CMakeLists.txt Configuration Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/cmake/index.html A comprehensive example of a CMakeLists.txt file demonstrating various directives, variable settings, and conditional logic. This is useful for understanding CMake syntax and structure. ```cmake # vim: syntax=cmake if(NOT CMAKE_BUILD_TYPE) # default to Release build for GCC builds set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE) endif() message(STATUS "cmake version ${CMAKE_VERSION}") if(POLICY CMP0025) cmake_policy(SET CMP0025 OLD) # report Apple's Clang as just Clang endif() if(POLICY CMP0042) cmake_policy(SET CMP0042 NEW) # MACOSX_RPATH endif() project (x265) cmake_minimum_required (VERSION 2.8.8) # OBJECT libraries require 2.8.8 include(CheckIncludeFiles) include(CheckFunctionExists) include(CheckSymbolExists) include(CheckCXXCompilerFlag) # X265_BUILD must be incremented each time the public API is changed set(X265_BUILD 48) configure_file("${PROJECT_SOURCE_DIR}/x265.def.in" "${PROJECT_BINARY_DIR}/x265.def") configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in" "${PROJECT_BINARY_DIR}/x265_config.h") SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}") # System architecture detection string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" SYSPROC) set(X86_ALIASES x86 i386 i686 x86_64 amd64) list(FIND X86_ALIASES "${SYSPROC}" X86MATCH) if("${SYSPROC}" STREQUAL "" OR X86MATCH GREATER "-1") message(STATUS "Detected x86 target processor") set(X86 1) add_definitions(-DX265_ARCH_X86=1) if("${CMAKE_SIZEOF_VOID_P}" MATCHES 8) set(X64 1) add_definitions(-DX86_64=1) endif() elseif(${SYSPROC} STREQUAL "armv6l") message(STATUS "Detected ARM target processor") set(ARM 1) add_definitions(-DX265_ARCH_ARM=1 -DHAVE_ARMV6=1) else() message(STATUS "CMAKE_SYSTEM_PROCESSOR value \"${CMAKE_SYSTEM_PROCESSOR}\" is unknown") message(STATUS "Please add this value near ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE}") endif() if(UNIX) list(APPEND PLATFORM_LIBS pthread) find_library(LIBRT rt) if(LIBRT) list(APPEND PLATFORM_LIBS rt) endif() find_package(Numa) if(NUMA_FOUND) list(APPEND CMAKE_REQUIRED_LIBS ${NUMA_LIBRARY}) check_symbol_exists(numa_node_of_cpu numa.h NUMA_V2) if(NUMA_V2) add_definitions(-DHAVE_LIBNUMA) message(STATUS "libnuma found, building with support for NUMA nodes") list(APPEND PLATFORM_LIBS ${NUMA_LIBRARY}) link_directories(${NUMA_LIBRARY_DIR}) include_directories(${NUMA_INCLUDE_DIR}) endif() endif() mark_as_advanced(LIBRT NUMA_FOUND) endif(UNIX) if(X64 AND NOT WIN32) option(ENABLE_PIC "Enable Position Independent Code" ON) else() option(ENABLE_PIC "Enable Position Independent Code" OFF) endif(X64 AND NOT WIN32) # Compiler detection if(CMAKE_GENERATOR STREQUAL "Xcode") set(XCODE 1) endif() if (APPLE) add_definitions(-DMACOS) endif() ``` -------------------------------- ### RPM Spec File Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/rpm/index.html This is an example of an RPM spec file. It includes package information, build, install, and file sections. ```rpm-spec # # spec file for package minidlna # # Copyright (c) 2011, Sascha Peilicke # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. Name: libupnp6 Version: 1.6.13 Release: 0 Summary: Portable Universal Plug and Play (UPnP) SDK Group: System/Libraries License: BSD-3-Clause Url: http://sourceforge.net/projects/pupnp/ Source0: http://downloads.sourceforge.net/pupnp/libupnp-%{version}.tar.bz2 BuildRoot: %{\_tmppath}/%{name}-%{version}-build %description The portable Universal Plug and Play (UPnP) SDK provides support for building UPnP-compliant control points, devices, and bridges on several operating systems. %package -n libupnp-devel Summary: Portable Universal Plug and Play (UPnP) SDK Group: Development/Libraries/C and C++ Provides: pkgconfig(libupnp) Requires: %{name} = %{version} %description -n libupnp-devel The portable Universal Plug and Play (UPnP) SDK provides support for building UPnP-compliant control points, devices, and bridges on several operating systems. %prep %setup -n libupnp-%{version} %build %configure --disable-static make %{?_smp_mflags} %install %makeinstall find %{buildroot} -type f -name '\*.la' -exec rm -f {} \; %post -p /sbin/ldconfig %postun -p /sbin/ldconfig %files %defattr(-,root,root,-) %doc ChangeLog NEWS README TODO %{\_libdir}/libixml.so.\* %{\_libdir}/libthreadutil.so.\* %{\_libdir}/libupnp.so.\* %files -n libupnp-devel %defattr(-,root,root,-) %{\_libdir}/pkgconfig/libupnp.pc %{\_libdir}/libixml.so %{\_libdir}/libthreadutil.so %{\_libdir}/libupnp.so %{\_includedir}/upnp/ %changelog ``` -------------------------------- ### Baseline Setup in CoffeeScript Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/coffeescript/index.html Establishes the root object (window or global) and saves the previous value of the '_' variable for baseline setup. ```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._ ``` -------------------------------- ### XQuery Syntax Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/xquery/index.html Demonstrates basic XQuery syntax including comments, variables, and element constructors. ```xquery xquery version "1.0-ml"; (: this is : a "comment" :) let $let := "test"function() $var {function()} {$var} let $joe:=1 return element element { attribute attribute { 1 }, element test { 'a' }, attribute foo { "bar" }, fn:doc() [ foo/@bar eq $let ], //x } (: a more 'evil' test :) (: Modified Blakeley example (: with nested comment :) ... :) declare private function local:declare() {()}; declare private function local:private() {()}; declare private function local:function() {()}; declare private function local:local() {()}; let $let := let $let := "let" return element element { attribute attribute { try { xdmp:version() } catch($e) { xdmp:log($e) } }, attribute fn:doc { "bar" castable as xs:string }, element text { text { "text" } }, fn:doc() [ child::eq/(@bar | attribute::attribute) eq $let ], //fn:doc } ``` -------------------------------- ### Asterisk Dialplan Configuration Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/asterisk/index.html This is an example of an Asterisk extensions.conf file, demonstrating various dialplan contexts, extensions, and commands. It serves as a reference for the syntax supported by the Asterisk dialplan mode. ```asterisk ; extensions.conf - the Asterisk dial plan ; ; If static is set to no, or omitted, then the pbx_config will rewrite ; this file when extensions are modified. Remember that all comments ; made in the file will be lost when that happens. 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) nexten => 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) ``` -------------------------------- ### HTML Example with XML Mode Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/xml/index.html This example demonstrates how the XML mode can parse and highlight HTML content. The indentation attempts a 'do what I mean' approach. ```html HTML Example The indentation tries to be somewhat "do what I mean"... but might not match your style. ``` -------------------------------- ### JSON-LD Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/javascript/json-ld.html An example of JSON-LD data structure, including context, name, description, image, and geolocation. ```json { "@context": { "name": "http://schema.org/name", "description": "http://schema.org/description", "image": { "@id": "http://schema.org/image", "@type": "@id" }, "geo": "http://schema.org/geo", "latitude": { "@id": "http://schema.org/latitude", "@type": "xsd:float" }, "longitude": { "@id": "http://schema.org/longitude", "@type": "xsd:float" }, "xsd": "http://www.w3.org/2001/XMLSchema#" }, "name": "The Empire State Building", "description": "The Empire State Building is a 102-story landmark in New York City.", "image": "http://www.civil.usherbrooke.ca/cours/gci215a/empire-state-building.jpg", "geo": { "latitude": "40.75", "longitude": "73.98" } } ``` -------------------------------- ### VB.NET Code Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/vb/index.html Illustrates a simple VB.NET class structure with a method. This is a basic example of VB.NET syntax. ```vb.net Class rocket Private quality as Double Public Sub launch() as String If quality > 0.8 launch = "Successful" Else launch = "Failed" End If End sub End class ``` -------------------------------- ### Compile-time String Formatting Example (D) Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/d/index.html Demonstrates how to format constants into a string at compile time using the Format template. This is analogous to string.format. ```d import std.metastrings; import std.stdio; void main() { string s = Format!("Arg %s = %s", "foo", 27); writefln(s); // "Arg foo = 27" } ``` -------------------------------- ### SQL Syntax Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/sql/index.html Demonstrates various SQL syntax elements supported by the mode, including keywords, variables, comments, and data types. ```sql -- SQL Mode for CodeMirror SELECT SQL_NO_CACHE DISTINCT @var1 AS `val1`, @'val2', @global.`sql_mode`, 1.1 AS `float_val`, .14 AS `another_float`, 0.09e3 AS `int_with_esp`, 0xFA5 AS `hex`, x'fa5' AS `hex2`, 0b101 AS `bin`, b'101' AS `bin2`, DATE '1994-01-01' AS `sql_date`, { T "1994-01-01" } AS `odbc_date`, 'my string', _utf8'your string', N'her string', TRUE, FALSE, UNKNOWN FROM DUAL -- space needed after '--' # 1 line comment /* multiline comment! */ LIMIT 1 OFFSET 0; ``` -------------------------------- ### YAML Front Matter Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/yaml-frontmatter/index.html This is an example of a file with YAML front matter, which is parsed by the yaml-frontmatter mode. The mode switches to a base mode after the front matter. ```yaml --- 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. --- ``` -------------------------------- ### Pascal Code Examples Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/pascal/index.html Illustrates various Pascal control flow structures and syntax. ```pascal while a <> b do writeln('Waiting') ``` ```pascal if a > b then writeln('Condition met') else writeln('Condition not met') ``` ```pascal for i := 1 to 10 do writeln('Iteration: ', i:1) ``` ```pascal repeat a := a + 1 until a = 10 ``` ```pascal case i of 0: write('zero'); 1: write('one'); 2: write('two') end ``` -------------------------------- ### SLIM Syntax Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/slim/index.html Illustrates various SLIM syntax elements including HTML tags, attributes, interpolation, and comments. ```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 ``` -------------------------------- ### Tornado Template Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/tornado/index.html This is an example of an HTML file with embedded Tornado template markup, demonstrating how variables and loops are structured. ```html My Tornado web application

{{ title }}

    {% for item in items %}
  • {% item.name %}
  • {% empty %}
  • You have no items in your list.
  • {% end %>
``` -------------------------------- ### Sass Syntax Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/sass/index.html Demonstrates typical Sass syntax including variable definitions, global attributes, and scoped styles. ```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 } ``` -------------------------------- ### Turtle Syntax Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/turtle/index.html This is an example of Turtle syntax, commonly used for RDF data serialization. It demonstrates prefixes and triples. ```turtle @prefix foaf: . @prefix geo: . @prefix rdf: . a foaf:Person; foaf:interest ; foaf:based_near [ geo:lat "34.0736111" ; geo:lon "-118.3994444" ] ``` -------------------------------- ### Lua Syntax Highlighting Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/lua/index.html Demonstrates Lua syntax highlighting with multi-line and single-line comments, function definitions, local variables, tables, conditional statements, and string literals. This example is for showcasing the mode's capabilities. ```lua --[[ example useless code to show lua syntax highlighting this is multiline comment ]] function blahblahblah(x) local table = { "asd" = 123, "x" = 0.34, } if x ~= 3 then print( x ) elseif x == "string" my_custom_function( 0x34 ) else unknown_function( "some string" ) end --single line comment end function blablabla3() for k,v in ipairs( table ) do --abcde.. y=[[ x=[[ x is a multi line string ]] but its definition is iside a highest level string! ]=] print(" \"\" ") s = math.sin( x ) end end ``` -------------------------------- ### Erlang Module Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/erlang/index.html Demonstrates a simple Erlang module with record definition, export functions, and a function to expand records. This code serves as an example of Erlang syntax and structure. ```erlang %% - -module('ex'). -author('mats cronqvist'). -export([demo/0, rec_info/1]). -record(demo,{a="One",b="Two",c="Three",d="Four"}). rec_info(demo) -> record_info(fields,demo). demo() -> expand_recs(?MODULE,#demo{a="A",b="BB"}). expand_recs(M,List) when is_list(List) -> [expand_recs(M,L)||L<-List]; expand_recs(M,Tup) when is_tuple(Tup) -> case tuple_size(Tup) of L when L < 1 -> Tup; L -> try Fields = M:rec_info(element(1,Tup)), L = length(Fields)+1, lists:zip(Fields,expand_recs(M,tl(tuple_to_list(Tup)))) catch _:_ -> list_to_tuple(expand_recs(M,tuple_to_list(Tup))) end end; expand_recs(_,Term) -> Term. ``` -------------------------------- ### Verilog/SystemVerilog Code Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/verilog/index.html This is a comprehensive example showcasing various Verilog and SystemVerilog constructs including literals, macro definitions, module definitions, class definitions, functions, tasks, and system 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 ``` -------------------------------- ### ECL Syntax Highlighting Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/ecl/index.html Demonstrates ECL syntax with comments and basic code structures. This is useful for showcasing the capabilities of the ECL mode. ```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); ``` -------------------------------- ### Initialize CodeMirror with PHP Mode Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/php/index.html Example of initializing a CodeMirror editor from a textarea, configured for PHP mode with specific editor settings. ```javascript var editor = CodeMirror.fromTextArea(document.getElementById("code"), { lineNumbers: true, matchBrackets: true, mode: "application/x-httpd-php", indentUnit: 4, indentWithTabs: true }); ``` -------------------------------- ### Gas Assembler Syntax Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/gas/index.html This is an example of Gas assembler syntax, including unified syntax, global directives, multi-line comments, single-line comments, and basic assembly instructions. ```gas .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!
" ``` -------------------------------- ### mIRC Mode Setup and Configuration Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/mirc/index.html Defines initial setup for the mIRC mode, including setting default values for nickname display and storage limits. Adjust MaxNicks to control the number of nicknames stored per hostmask. ```mirc ;AKA Nick Tracker by Ford_Lawnmower irc.GeekShed.net #Script-Help ;*********************************************************************; ;**Start Setup ;Change JoinDisplay, below, for On Join AKA Display. On = 1 - Off = 0 alias -l JoinDisplay { return 1 } ;Change MaxNicks, below, to the number of nicknames you want to store for each hostmask. I wouldn't go over 400 with this ;/ alias -l MaxNicks { return 20 } ;Change AKALogo, below, To the text you want displayed before each AKA result. alias -l AKALogo { return 06 05A06K07A 06 } ``` -------------------------------- ### TiddlyWiki Formatting Examples Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/tiddlywiki/index.html Illustrates various text formatting options available in TiddlyWiki markup. ```tiddlywiki ''bold'' ``` ```tiddlywiki //italic// ``` ```tiddlywiki __underlined__ ``` ```tiddlywiki --strikethrough-- ``` ```tiddlywiki super^^script^^ ``` ```tiddlywiki sub~~script~~ ``` ```tiddlywiki @@highlighted@@ ``` ```tiddlywiki {{{preformatted}}} ``` -------------------------------- ### Cypher Query Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/cypher/index.html A sample Cypher query demonstrating the syntax highlighting provided by the mode. ```cypher // Cypher Mode for CodeMirror, using the neo theme 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 ``` -------------------------------- ### Smalltalk Code Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/smalltalk/index.html A sample Smalltalk class definition for a counter component, demonstrating basic Smalltalk syntax. ```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: '--'. ] ] ``` -------------------------------- ### Dart Class and Method Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/dart/index.html Demonstrates Dart syntax for defining a class with instance variables, constructors, and methods, including error handling. ```dart import 'dart:math' show Random; void main() { print(new Die(n: 12).roll()); } // Define a class. class Die { // Define a class variable. static Random shaker = new Random(); // Define instance variables. int sides, value; // Define a method using shorthand syntax. String toString() => '$value'; // Define a constructor. Die({int n: 6}) { if (4 <= n && n <= 20) { sides = n; } else { // Support for errors and exceptions. throw new ArgumentError(/\* \*/); } } // Define an instance method. int roll() { return value = shaker.nextInt(sides) + 1; } } ``` -------------------------------- ### Sample Dockerfile Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/dockerfile/index.html A sample Dockerfile demonstrating common instructions and syntax. ```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 # Install dependencies for nginx installation 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 # Install unzip RUN apt-get install -y unzip # Install curl RUN apt-get install -y curl # Install nodejs & npm RUN apt-get install -y rlwrap RUN apt-get install -y nodejs # Download Ghost v0.4.1 RUN curl -L https://ghost.org/zip/ghost-latest.zip -o /tmp/ghost.zip # Unzip Ghost zip to /data/ghost RUN unzip -uo /tmp/ghost.zip -d /data/ghost # Add custom config js to /data/ghost ADD ./config.example.js /data/ghost/config.js # Install Ghost with NPM RUN cd /data/ghost/ && npm install --production # Expose port 2368 EXPOSE 2368 # Run Ghost CMD ["npm","start"] ``` -------------------------------- ### Python Delimiters Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/python/index.html Illustrates the use of various delimiters such as parentheses, brackets, braces, and punctuation marks. ```python # Delimiters () [] {} , : ` = ; @ . # Note that @ and . require the proper context on Python 2. += -= *= /= %= &= |= ^= //= >>= <<= **= ``` -------------------------------- ### Serve Live Documentation Source: https://github.com/sveetch/djangocodemirror/blob/master/docs/development.md Build and serve the documentation locally, with automatic rebuilding upon file changes. Access it at http://localhost:8002/. Ensure documentation is built at least once before using this command. ```default make livedocs ``` -------------------------------- ### Import Foundation Components Source: https://github.com/sveetch/djangocodemirror/blob/master/sandbox/demo/data/scss.txt Imports all available Foundation components. This is typically used for full project setups. ```scss @import "foundation/components/alert-boxes", "foundation/components/block-grid", "foundation/components/breadcrumbs", "foundation/components/button-groups", "foundation/components/buttons", "foundation/components/dropdown", "foundation/components/dropdown-buttons", "foundation/components/flex-video", "foundation/components/forms", "foundation/components/grid", "foundation/components/inline-lists", "foundation/components/keystrokes", "foundation/components/labels", "foundation/components/pagination", "foundation/components/panels", "foundation/components/side-nav", "foundation/components/sub-nav", "foundation/components/tables", "foundation/components/tabs", "foundation/components/top-bar", "foundation/components/type", "foundation/components/visibility"; ``` -------------------------------- ### Python Literals Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/python/index.html Demonstrates various numeric and string literal formats recognized by the Python mode. ```python # Literals 1234 0.0e101 .123 0b01010011100 0o01234567 0x0987654321abcdef 7 2147483647 3L 79228162514264337593543950336L 0x100000000L 79228162514264337593543950336 0xdeadbeef 3.14j 10.j 10j .001j 1e100j 3.14e-10j # String Literals 'For\'' "God\"" """so loved the world""" '''that he gave his only begotten\' ''' 'that whosoever believeth \ in him' '' ``` -------------------------------- ### Python Code Example with Decorators and Classes Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/python/index.html A sample Python code snippet demonstrating imports, decorators, class definitions, and static methods. ```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 ``` -------------------------------- ### Example Yacas Code Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/yacas/index.html This is an example of Yacas code demonstrating graph manipulation and type checking. ```yacas // example yacas code Graph(edges_IsList) <-- [ Local(v, e, f, t); vertices := {}; ForEach (e, edges) [ If (IsList(e), e := Head(e)); {f, t} := Tail(Listify(e)); DestructiveAppend(vertices, f); DestructiveAppend(vertices, t); ]; Graph(RemoveDuplicates(vertices), edges); ]; 10 # IsGraph(Graph(vertices_IsList, edges_IsList)) <-- True; 20 # IsGraph(_x) <-- False; Edges(Graph(vertices_IsList, edges_IsList)) <-- edges; Vertices(Graph(vertices_IsList, edges_IsList)) <-- vertices; AdjacencyList(g_IsGraph) <-- [ Local(l, vertices, edges, e, op, f, t); l := Association'Create(); vertices := Vertices(g); ForEach (v, vertices) Association'Set(l, v, {}); edges := Edges(g); ForEach(e, edges) [ If (IsList(e), e := Head(e)); {op, f, t} := Listify(e); DestructiveAppend(Association'Get(l, f), t); If (String(op) = "<->", DestructiveAppend(Association'Get(l, t), f)); ]; l; ]; ``` -------------------------------- ### Example CSS Code Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/css/index.html This is an example of CSS code that would be highlighted by the CodeMirror CSS mode. ```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; } ``` -------------------------------- ### Stylus Syntax Highlighting Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/stylus/index.html Demonstrates basic Stylus syntax including selectors, properties, variables, and mixins. This is useful for understanding how the mode highlights Stylus code. ```stylus /* Stylus mode */ #id, .class, article font-family Arial, sans-serif #id, .class, article { font-family: Arial, sans-serif; } // Variables font-size-base = 16px line-height-base = 1.5 font-family-base = "Helvetica Neue", Helvetica, Arial, sans-serif text-color = lighten(#000, 20%) body { font: 400 16px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif; color: #333; } // Variables link-color = darken(#428bca, 6.5%) link-hover-color = darken(link-color, 15%) link-decoration = none link-hover-decoration = false // Mixin tab-focus() { outline: thin dotted; outline: 5px auto -webkit-focus-ring-color; outline-offset: -2px; } a { color: link-color if link-decoration { text-decoration: link-decoration } &:hover, &:focus { color: link-hover-color } if link-hover-decoration { text-decoration: link-hover-decoration } &:focus { tab-focus() } } a:hover, a:focus { color: #2f6ea7; } a:focus { outline: thin dotted; outline: 5px auto -webkit-focus-ring-color; outline-offset: -2px; } ``` -------------------------------- ### Python Identifiers and Unicode Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/python/index.html Shows examples of standard and Unicode identifiers, including those with special characters and accents. ```python # Identifiers __a__ a.b a.b.c #Unicode identifiers on Python3 # a = x\ddot a⃗ = ẍ # a = v\dot a⃗ = v̇ #F\vec = m \cdot a\vec F⃗ = m•a⃗ ``` -------------------------------- ### Underscore.coffee Example Header Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/coffeescript/index.html This header is part of the Underscore.coffee example, providing copyright and licensing information for the Underscore library. ```coffeescript **Underscore.coffee # (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.** # Underscore is freely distributable under the terms of the # [MIT license](http://en.wikipedia.org/wiki/MIT_License). # Portions of Underscore are inspired by or borrowed from # [Prototype.js](http://prototypejs.org/api), Oliver Steele's # [Functional](http://osteele.com), and John Resig's # [Micro-Templating](http://ejohn.org). # For all details and documentation: # http://documentcloud.github.com/underscore/ ``` -------------------------------- ### Objective-C AppDelegate Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/clike/index.html Shows Objective-C syntax for an AppDelegate, including multi-line comments, import statements, class implementation, and a method definition. Demonstrates C-style character array declaration. ```objectivec /* This is a longer comment That spans two lines */ #import @implementation YourAppDelegate // This is a one-line comment - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ char myString[] = "This is a C character array"; int test = 5; return YES; } ``` -------------------------------- ### Build Project Documentation Source: https://github.com/sveetch/djangocodemirror/blob/master/docs/development.md Generate the project's documentation using Sphinx. This command builds the documentation files. ```default make docs ``` -------------------------------- ### Oz Code Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/oz/index.html An example of Oz code demonstrating function definitions, concurrency, and basic data structures. ```oz declare fun {Ints N Max} if N == Max then nil else {Delay 1000} N|{Ints N+1 Max} end end fun {Sum S Stream} case Stream of nil then S [] H|T then S|{Sum H+S T} end end local X Y in thread X = {Ints 0 1000} end thread Y = {Sum 0 X} end {Browse Y} end ``` -------------------------------- ### MUMPS Routine Example Source: https://github.com/sveetch/djangocodemirror/blob/master/djangocodemirror/static/CodeMirror/mode/mumps/index.html This is an example of a MUMPS routine, demonstrating syntax for variables, control flow, and function calls. ```mumps ; Lloyd Milligan ; 03-30-2015 ; ; MUMPS support for Code Mirror - Excerpts below from routine ^XUS ; CHECKAV(X1) ;Check A/V code return DUZ or Zero. (Called from XUSRB) N %,%1,X,Y,IEN,DA,DIK S IEN=0 ;Start CCOW I $E(X1,1,7)=\"~~TOK~~\" D Q:IEN>0 IEN . I $E(X1,8,9)=\"~1\" S IEN=$$CHKASH^XUSRB4($E(X1,8,255)) . I $E(X1,8,9)=\"~2\" S IEN=$$CHKCCOW^XUSRB4($E(X1,8,255)) . Q ;End CCOW S X1=$$UP(X1) S:X1\\[\":\" XUTT=1,X1=$TR(X1,\":\") S X=$P(X1,\":\") Q:X=\"^\" -1 S:XUF %1=\"Access: \"\_X Q:X'விற்கு1.20ANP 0 S X=$$EN^XUSHSH(X) I '$D(^VA(200,\"A\",X)) D LBAV Q 0 S %1=\"\",IEN=$O(^VA(200,\"A\",X,0)),XUF(.3)=IEN D USER(IEN) S X=$P(X1,\":\",2) S:XUF %1=\"Verify: \"\_X S X=$$EN^XUSHSH(X) I $P(XUSER(1),\"^\",2)'=X D LBAV Q 0 I $G(XUFAC(1)) S DIK=\"^XUSEC(4,\",DA=XUFAC(1) D ^DIK Q IEN ; ; Spell out commands ; SET2() ;EF. Return error code (also called from XUSRB) NEW %,X SET XUNOW=$$HTFM^XLFDT($H),DT=$P(XUNOW,\".\") KILL DUZ,XUSER SET (DUZ,DUZ(2))=0,(DUZ(0),DUZ(\"AG\"),XUSER(0),XUSER(1),XUTT,%UCI)=\"\ ```