├── .dokx ├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── complex.lua ├── conv.c ├── convolution.lua ├── doc ├── _highlight │ ├── LICENSE │ ├── README.md │ ├── classref.txt │ ├── highlight.pack.js │ └── styles │ │ ├── arta.css │ │ ├── ascetic.css │ │ ├── brown_paper.css │ │ ├── brown_papersq.png │ │ ├── dark.css │ │ ├── default.css │ │ ├── docco.css │ │ ├── far.css │ │ ├── foundation.css │ │ ├── github.css │ │ ├── googlecode.css │ │ ├── idea.css │ │ ├── ir_black.css │ │ ├── magula.css │ │ ├── mono-blue.css │ │ ├── monokai.css │ │ ├── monokai_sublime.css │ │ ├── obsidian.css │ │ ├── pojoaque.css │ │ ├── pojoaque.jpg │ │ ├── railscasts.css │ │ ├── rainbow.css │ │ ├── school_book.css │ │ ├── school_book.png │ │ ├── solarized_dark.css │ │ ├── solarized_light.css │ │ ├── sunburst.css │ │ ├── tomorrow-night-blue.css │ │ ├── tomorrow-night-bright.css │ │ ├── tomorrow-night-eighties.css │ │ ├── tomorrow-night.css │ │ ├── tomorrow.css │ │ ├── vs.css │ │ ├── xcode.css │ │ └── zenburn.css ├── _markdown │ └── signal │ │ ├── README.md │ │ ├── complex.md │ │ ├── convolution.md │ │ ├── extramath.md │ │ ├── ffi.md │ │ ├── fft.md │ │ ├── init.md │ │ └── wavelet.md ├── index.html ├── search.js ├── signal │ ├── complex.html │ ├── convolution.html │ ├── extra │ │ └── README.html │ ├── extramath.html │ ├── ffi.html │ ├── fft.html │ ├── index.html │ ├── init.html │ ├── style.css │ └── wavelet.html ├── style-page.css └── style.css ├── extramath.lua ├── ffi.lua ├── fft.lua ├── init.c ├── init.lua ├── rocks └── signal-scm-1.rockspec ├── tests ├── cceps.lua ├── dct.lua ├── fft.lua ├── fftM.lua ├── hilbert.lua ├── poly.lua ├── rceps.lua ├── rcunwrap.lua ├── rcwrap.lua ├── rfftM.lua ├── stft.lua ├── test.lua ├── unwrap.lua └── wavelet.lua └── wavelet.lua /.dokx: -------------------------------------------------------------------------------- 1 | return { 2 | packageName = 'signal', 3 | includeLocal = false, 4 | githubURL = 'soumith/torch-signal' 5 | 6 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *~ 3 | \#* 4 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR) 2 | CMAKE_POLICY(VERSION 2.6) 3 | IF(LUAROCKS_PREFIX) 4 | MESSAGE(STATUS "Installing Torch-Signal through Luarocks") 5 | STRING(REGEX REPLACE "(.*)lib/luarocks/rocks.*" "\\1" CMAKE_INSTALL_PREFIX "${LUAROCKS_PREFIX}") 6 | MESSAGE(STATUS "Prefix inferred from Luarocks: ${CMAKE_INSTALL_PREFIX}") 7 | ENDIF() 8 | FIND_PACKAGE(Torch REQUIRED) 9 | 10 | FILE(GLOB luasrc *.lua) 11 | #FILE(GLOB src *.c) 12 | SET(src "init.c") 13 | ADD_TORCH_PACKAGE(signal "${src}" "${luasrc}" "Signal Processing Toolbox") 14 | 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Soumith Chintala 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, this 11 | list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | * Neither the name of the {organization} nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # torch-signal 2 | A signal processing toolbox for Torch-7 3 | 4 | - Fourier Transforms (real & complex) (1D, 2D, 3D) 5 | - Cosine Transforms (1D, 2D, 3D) 6 | - Short-time Fourier Transforms 7 | - Spectrogram 8 | - Hilbert Transform 9 | - Complex Cepstral Analysis, Real Cepstrums 10 | 11 | 12 | ## Quickstart 13 | Install fftw3 on your OS: 14 | 15 | OSX (Homebrew): 16 | ```bash 17 | brew install fftw 18 | ``` 19 | 20 | Ubuntu: 21 | ```bash 22 | sudo apt-get install libfftw3 23 | OR 24 | sudo apt-get install libfftw3-3 25 | ``` 26 | 27 | Install torch-signal: 28 | ```bash 29 | luarocks install https://raw.github.com/soumith/torch-signal/master/rocks/signal-scm-1.rockspec 30 | ``` 31 | 32 | (add sudo for ubuntu) 33 | 34 | For documentation, go to: 35 | http://soumith.github.io/torch-signal/signal/ 36 | 37 | For examples, see tests/ 38 | -------------------------------------------------------------------------------- /complex.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | All functions in here expect either a 2D Nx2 Complex tensor 3 | ]]-- 4 | 5 | local complex = {} 6 | 7 | function complex.angle(h) 8 | return torch.atan2(h[{{},2}],h[{{},1}]) 9 | end 10 | 11 | function complex.exp(h) 12 | local out = h:clone() 13 | local real = h[{{},1}] 14 | local imag = h[{{},2}] 15 | out[{{},1}] = torch.exp(real):cmul(torch.cos(imag)) 16 | out[{{},2}] = torch.exp(real):cmul(torch.sin(imag)); 17 | return out 18 | end 19 | 20 | function complex.abs(h) 21 | local hsquare = torch.pow(h,2) 22 | if h:dim() == 2 and h:size(2) == 2 then 23 | return torch.sqrt(hsquare[{{},1}] + hsquare[{{},2}]) 24 | elseif h:dim() == 3 and h:size(3) == 2 then 25 | return torch.sqrt(hsquare[{{},{},1}] + hsquare[{{},{},2}]) 26 | else 27 | error('unsupported dimensions') 28 | end 29 | end 30 | 31 | function complex.real(h) 32 | return h[{{},1}] 33 | end 34 | 35 | function complex.imag(h) 36 | return h[{{},2}] 37 | end 38 | 39 | function complex.conj(h) 40 | local out = h:clone() 41 | out[{{},2}]:mul(-1) 42 | return out 43 | end 44 | 45 | function complex.prod(h) 46 | local out = torch.ones(1,2):typeAs(h) 47 | out[1] = h[1] 48 | for i=2,h:size(1) do 49 | -- (x1 + iy1) * (x2 + iy2) = (x1x2 - y1y2) + i(x1y2 + y1x2) 50 | local real = (out[1][1]* h[i][1] - out[1][2] * h[i][2]) 51 | local imag = (out[1][1]* h[i][2] + out[1][2] * h[i][1]) 52 | out[1][1] = real 53 | out[1][2] = imag 54 | end 55 | return out 56 | end 57 | 58 | function complex.cmul(a1,b1, noargcheck) 59 | local a,b 60 | if noargcheck then 61 | a=a1; b=b1 62 | else 63 | if a1:dim() == 1 then -- assume that imag is 0 64 | a = torch.DoubleTensor(a1:size(1), 2):zero() 65 | a[{{}, 1}] = a1 66 | elseif a1:dim() == 2 and a1:size(2) == 2 then 67 | a = a1 68 | else 69 | error('Input has to be 1D Tensor of size N (purely real 1D tensor) or ' .. 70 | '2D Tensor of size Nx2 (Complex 1D tensor)') 71 | end 72 | if b1:dim() == 1 then -- assume that imag is 0 73 | b = torch.DoubleTensor(b1:size(1), 2):zero() 74 | b[{{}, 1}] = b1 75 | elseif b1:dim() == 2 and b1:size(2) == 2 then 76 | b = b1 77 | else 78 | error('Input has to be 1D Tensor of size N (purely real 1D tensor) or ' .. 79 | '2D Tensor of size Nx2 (Complex 1D tensor)') 80 | end 81 | end 82 | local c = a:clone():zero() 83 | a = a:contiguous() 84 | b = b:contiguous() 85 | c = c:contiguous() 86 | local cd = torch.data(c) 87 | local ad = torch.data(a) 88 | local bd = torch.data(b) 89 | for i=0,a:size(1)-1 do 90 | -- (x1 + iy1) * (x2 + iy2) = (x1x2 - y1y2) + i(x1y2 + y1x2) 91 | local re = i*2 92 | local im = i*2 + 1 93 | cd[re] = (ad[re]* bd[re] - ad[im] * bd[im]) 94 | cd[im] = (ad[re]* bd[im] + ad[im] * bd[re]) 95 | end 96 | return c 97 | end 98 | 99 | function complex.dot(a,b) 100 | if not(a:dim() == 2 and a:size(2) == 2 and b:dim() == 2 and b:size(2) == 2) then 101 | error('Inputs have to be 2D Tensor of size Nx2 (complex 1D tensor)') 102 | end 103 | if a:size(1) ~= b:size(1) then 104 | error('Both inputs need to have same number of elements') 105 | end 106 | local c = torch.sum(complex.cmul(a,b, true), 1) 107 | return c 108 | end 109 | 110 | function complex.mm(a,b) 111 | if not(a:dim() == 3 and a:size(3) == 2 and b:dim() == 3 and b:size(3) == 2) then 112 | error('Inputs have to be 3D Tensor of size NxMx2 (complex 2D tensor)') 113 | end 114 | if a:size(2) ~= b:size(1) then 115 | error('Matrix-Matrix product requires NxM and MxP matrices.') 116 | end 117 | local c = torch.zeros(a:size(1), b:size(2), 2):typeAs(a) 118 | for i=1,c:size(1) do 119 | for j=1,c:size(2) do 120 | c[i][j] = complex.dot(a[{i,{},{}}], b[{{},j,{}}]) 121 | -- print(c[i][j]) 122 | end 123 | end 124 | return c 125 | end 126 | 127 | function complex.diag(x) 128 | if x:dim() == 2 and x:size(2) == 2 then 129 | local y = torch.zeros(x:size(1), x:size(1), 2) 130 | y[{{},1}] = torch.diag(x[{{},1}]) 131 | y[{{},2}] = torch.diag(x[{{},2}]) 132 | return y 133 | elseif x:dim() == 3 and x:size(3) == 2 then 134 | local yr = torch.diag(x[{{},{},1}]) 135 | local y = torch.zeros(yr:size(1),2) 136 | y[{{},1}] = yr 137 | y[{{},2}] = torch.diag(x[{{},{},2}]) 138 | return y 139 | else 140 | error('Input has to be 2D Tensor of size Nx2 or ' .. 141 | '3D Tensor of size NxMx2 (Complex 2D tensor)') 142 | end 143 | end 144 | 145 | --[[ 146 | Polynomial with specified roots 147 | 148 | Function is super unoptimized 149 | ]]-- 150 | function complex.poly(x) 151 | local e 152 | if x:dim() == 2 and x:size(1) == x:size(2) then 153 | e = torch.eig(x) -- square polynomial 154 | -- TODO: Strip out infinities in case the eigen values have any 155 | elseif x:dim() == 1 then 156 | e = x 157 | else 158 | error('Input should be a 1D Tensor or a 2D square tensor') 159 | end 160 | 161 | -- Expand recursion formula 162 | local n = e:size(1) 163 | if x:dim() == 1 then 164 | local c = torch.zeros(n+1) -- purely real 165 | c[1] = 1 166 | for j=1,n do 167 | c[{{2,(j+1)}}] = c[{{2,(j+1)}}] - torch.mul(c[{{1,j}}],e[j]) 168 | end 169 | return c 170 | else 171 | local c = torch.zeros(n+1,2) -- complex 172 | c[1][1] = 1 173 | for j=1,n do 174 | -- c(2:(j+1)) = c(2:(j+1)) - e(j).*c(1:j); 175 | c[{{2,(j+1)}, 1}] = c[{{2,(j+1)}, 1}] - torch.mul(c[{{1,j}, 1}],e[j][1]) 176 | c[{{2,(j+1)}, 2}] = c[{{2,(j+1)}, 2}] - torch.mul(c[{{1,j}, 2}],e[j][2]) 177 | end 178 | -- The result should be real if the roots are complex conjugates. 179 | local c1 = torch.sort(e[{{torch.ge(e[{{},2}], 0)},2}]) 180 | local c2 = torch.sort(e[{{torch.le(e[{{},2}], 0)},2}]) 181 | if c1:size(1) == c2:size(1) and torch.eq(c1, c2):sum() == c1:size(1) then 182 | c = complex.real(c); 183 | end 184 | return c 185 | end 186 | end 187 | 188 | return complex 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | -------------------------------------------------------------------------------- /conv.c: -------------------------------------------------------------------------------- 1 | /* conv1d with a stride option. only does valid convolutions 2 | accumulates in y 3 | y is output , yn is output size 4 | x is input 5 | k is kernel, kn is kernel size 6 | stride is convolution stride 7 | */ 8 | void signal_(conv1d)(real *y, real *x, real *k, const long yn, const long kn, long stride) { 9 | long yi, ki; 10 | for (yi = 0; yi < yn; ++yi) { 11 | real * xi = x + yi * stride; 12 | for (ki = 0; ki < kn; ++ki) 13 | y[yi] += xi[ki] * k[ki]; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /convolution.lua: -------------------------------------------------------------------------------- 1 | local signal = {} 2 | local C = require 'signal.ffi' 3 | 4 | --[[ 5 | 1D valid convolution with stride 6 | ]]-- 7 | function signal.conv1d(input, kernel, stride, mode) 8 | kernel = kernel:typeAs(input) 9 | local input_data = input:data() 10 | local kernel_data = kernel:data() 11 | 12 | local input_size = input:size(1) 13 | local kernel_size = kernel:size(1) 14 | 15 | mode = mode or 'valid' 16 | local output_size = 0 17 | if mode == 'valid' then 18 | output_size = math.floor((input_size - kernel_size + stride)/stride) 19 | elseif mode == 'same' then 20 | output_size = math.floor(math.max(input_size/stride, kernel_size/stride)) 21 | else 22 | error("Supported modes are 'valid' or 'same'") 23 | end 24 | local output = torch.zeros(output_size):typeAs(input) 25 | local output_data = output:data() 26 | 27 | if input:type() == 'torch.FloatTensor' then 28 | C['signal_conv1d_float'](output_data, input_data, kernel_data, output_size, kernel_size, stride) 29 | else 30 | C['signal_conv1d_double'](output_data, input_data, kernel_data, output_size, kernel_size, stride) 31 | end 32 | return output 33 | end 34 | 35 | return signal 36 | -------------------------------------------------------------------------------- /doc/_highlight/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006, Ivan Sagalaev 2 | All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of highlight.js nor the names of its contributors 12 | may be used to endorse or promote products derived from this software 13 | without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY 16 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /doc/_highlight/README.md: -------------------------------------------------------------------------------- 1 | # Highlight.js 2 | 3 | Highlight.js highlights syntax in code examples on blogs, forums and, 4 | in fact, on any web page. It's very easy to use because it works 5 | automatically: finds blocks of code, detects a language, highlights it. 6 | 7 | Autodetection can be fine tuned when it fails by itself (see "Heuristics"). 8 | 9 | 10 | ## Basic usage 11 | 12 | Link the library and a stylesheet from your page and hook highlighting to 13 | the page load event: 14 | 15 | ```html 16 | 17 | 18 | 19 | ``` 20 | 21 | This will highlight all code on the page marked up as `
..
`.
22 | If you use different markup or need to apply highlighting dynamically, read
23 | "Custom initialization" below.
24 |
25 | - You can download your own customized version of "highlight.pack.js" or
26 | use the hosted one as described on the download page:
27 | `) pass `true` into the third parameter of `highlightBlock` 121 | to make highlight.js use `"}else{r+=O[0]}Q=B.lR.lastIndex;O=B.lR.exec(N)}return r+N.substr(Q)}function z(){if(B.sL&&!e[B.sL]){return l(w)}var N=B.subLanguageMode=="continuous"?B.top:undefined;var r=B.sL?d(B.sL,w,true,N):g(w);if(B.r>0){v+=r.keyword_count;A+=r.r}B.top=r.top;return''+r.value+""}function L(){return B.sL!==undefined?z():I()}function K(O,r){var N=O.cN?'':"";if(O.rB){x+=N;w=""}else{if(O.eB){x+=l(r)+N;w=""}else{x+=N;w=r}}B=Object.create(O,{parent:{value:B}})}function D(N,r){w+=N;if(r===undefined){x+=L();return 0}var P=o(r,B);if(P){x+=L();K(P,r);return P.rB?0:r.length}var Q=s(B,r);if(Q){var O=B;if(!(O.rE||O.eE)){w+=r}x+=L();do{if(B.cN){x+=""}A+=B.r;B=B.parent}while(B!=Q.parent);if(O.eE){x+=l(r)}w="";if(Q.starts){K(Q.starts,"")}return O.rE?0:r.length}if(t(r,B)){throw new Error('Illegal lexem "'+r+'" for mode "'+(B.cN||"
` in the output: 122 | 123 | ```javascript 124 | $('div.code').each(function(i, e) {hljs.highlightBlock(e, null, true)}); 125 | ``` 126 | 127 | 128 | ## Heuristics 129 | 130 | Autodetection of a code's language is done using a simple heuristic: 131 | the program tries to highlight a fragment with all available languages and 132 | counts all syntactic structures that it finds along the way. The language 133 | with greatest count wins. 134 | 135 | This means that in short fragments the probability of an error is high 136 | (and it really happens sometimes). In this cases you can set the fragment's 137 | language explicitly by assigning a class to the `` element: 138 | 139 | ```html 140 |
141 | ``` 142 | 143 | You can use class names recommended in HTML5: "language-html", 144 | "language-php". Classes also can be assigned to the `...
` element. 145 | 146 | To disable highlighting of a fragment altogether use "no-highlight" class: 147 | 148 | ```html 149 |150 | ``` 151 | 152 | 153 | ## Export 154 | 155 | File export.html contains a little program that allows you to paste in a code 156 | snippet and then copy and paste the resulting HTML code generated by the 157 | highlighter. This is useful in situations when you can't use the script itself 158 | on a site. 159 | 160 | 161 | ## Meta 162 | 163 | - Version: 7.5 164 | - URL: http://highlightjs.org/ 165 | 166 | For the license terms see LICENSE files. 167 | For authors and contributors see AUTHORS.en.txt file. 168 | -------------------------------------------------------------------------------- /doc/_highlight/classref.txt: -------------------------------------------------------------------------------- 1 | This is a full list of available classes corresponding to languages' 2 | syntactic structures. The parentheses after language name contain identifiers 3 | used as class names in `...
` element. 4 | 5 | Python ("python"): 6 | 7 | keyword keyword 8 | built_in built-in objects (None, False, True and Ellipsis) 9 | number number 10 | string string (of any type) 11 | comment comment 12 | decorator @-decorator for functions 13 | function function header "def some_name(...):" 14 | class class header "class SomeName(...):" 15 | title name of a function or a class inside a header 16 | params everything inside parentheses in a function's or class' header 17 | 18 | Python profiler results ("profile"): 19 | 20 | number number 21 | string string 22 | built_in built-in function entry 23 | filename filename in an entry 24 | summary profiling summary 25 | header header of table of results 26 | keyword column header 27 | function function name in an entry (including parentheses) 28 | title actual name of a function in an entry (excluding parentheses) 29 | prompt interpreter prompt (>>> or ...) 30 | 31 | Ruby ("ruby"): 32 | 33 | keyword keyword 34 | string string 35 | subst in-string substitution (#{...}) 36 | comment comment 37 | yardoctag YARD tag 38 | function function header "def some_name(...):" 39 | class class header "class SomeName(...):" 40 | title name of a function or a class inside a header 41 | parent name of a parent class 42 | symbol symbol 43 | 44 | Haml ("haml"): 45 | 46 | tag any tag starting with "%" 47 | title tag's name 48 | attribute tag's attribute 49 | keyword tag's attribute that is a keyword 50 | string attribute's value that is a string 51 | value attribute's value, shorthand id or class for tag 52 | comment comment 53 | doctype !!! declaration 54 | bullet line defined by variable 55 | 56 | Perl ("perl"): 57 | 58 | keyword keyword 59 | comment comment 60 | number number 61 | string string 62 | regexp regular expression 63 | sub subroutine header (from "sub" till "{") 64 | variable variable starting with "$", "%", "@" 65 | operator operator 66 | pod plain old doc 67 | 68 | PHP ("php"): 69 | 70 | keyword keyword 71 | number number 72 | string string (of any type) 73 | comment comment 74 | phpdoc phpdoc params in comments 75 | variable variable starting with "$" 76 | preprocessor preprocessor marks: "" 77 | 78 | Scala ("scala"): 79 | 80 | keyword keyword 81 | number number 82 | string string 83 | comment comment 84 | annotation annotation 85 | javadoc javadoc comment 86 | javadoctag @-tag in javadoc 87 | class class header 88 | title class name inside a header 89 | params everything in parentheses inside a class header 90 | inheritance keywords "extends" and "with" inside class header 91 | 92 | Go ("go"): 93 | 94 | comment comment 95 | string string constant 96 | number number 97 | keyword language keywords 98 | constant true false nil iota 99 | typename built-in plain types (int, string etc.) 100 | built_in built-in functions 101 | 102 | HTML, XML ("xml"): 103 | 104 | tag any tag from "<" till ">" 105 | attribute tag's attribute with or without value 106 | value attribute's value 107 | comment comment 108 | pi processing instruction ( ... ?>) 109 | doctype declaration 110 | cdata CDATA section 111 | 112 | Lasso ("lasso"): 113 | 114 | preprocessor delimiters and interpreter flags 115 | shebang Lasso 9 shell script header 116 | comment single- or multi-line comment 117 | javadoc doc comment 118 | keyword keyword 119 | literal keyword representing a value 120 | built_in built-in types and variables 121 | number number 122 | string string 123 | variable variable reference starting with "#" or "$" 124 | tag tag literal 125 | attribute named or rest parameter in method signature 126 | class type, trait, or method header 127 | title name following "define" inside a header 128 | 129 | CSS ("css"): 130 | 131 | tag tag in selectors 132 | id #some_name in selectors 133 | class .some_name in selectors 134 | at_rule @-rule till first "{" or ";" 135 | attr_selector attribute selector (square brackets in a[href^=http://]) 136 | pseudo pseudo classes and elemens (:after, ::after etc.) 137 | comment comment 138 | rules everything from "{" till "}" 139 | attribute property name inside a rule 140 | value property value inside a rule, from ":" till ";" or 141 | till the end of rule block 142 | number number within a value 143 | string string within a value 144 | hexcolor hex color (#FFFFFF) within a value 145 | function CSS function within a value 146 | important "!important" symbol 147 | 148 | SCSS ("scss"): 149 | 150 | tag tag in selectors 151 | id #some_name in selectors 152 | class .some_name in selectors 153 | at_rule @-rule till first "{" or ";" 154 | attr_selector attribute selector (square brackets in a[href^=http://]) 155 | pseudo pseudo classes and elemens (:after, ::after etc.) 156 | comment comment 157 | rules everything from "{" till "}" 158 | attribute property name inside a rule 159 | value property value inside a rule, from ":" till ";" or 160 | till the end of rule block 161 | number number within a value 162 | string string within a value 163 | hexcolor hex color (#FFFFFF) within a value 164 | function CSS function within a value 165 | important "!important" symbol 166 | variable variable starting with "$" 167 | preprocessor keywords after @ 168 | 169 | Markdown ("markdown"): 170 | 171 | header header 172 | bullet list bullet 173 | emphasis emphasis 174 | strong strong emphasis 175 | blockquote blockquote 176 | code code 177 | horizontal_rule horizontal rule 178 | link_label link label 179 | link_url link url 180 | 181 | AsciiDoc ("asciidoc"): 182 | 183 | header heading 184 | bullet list or labeled bullet 185 | emphasis emphasis 186 | strong strong emphasis 187 | blockquote blockquote 188 | code inline or block code 189 | horizontal_rule horizontal rule 190 | link_label link or image label 191 | link_url link or image url 192 | comment comment 193 | attribute document attribute, block attributes 194 | label admonition label 195 | 196 | Django ("django"): 197 | 198 | keyword HTML tag in HTML, default tags and default filters in templates 199 | tag any tag from "<" till ">" 200 | comment comment 201 | doctype declaration 202 | attribute tag's attribute with or withou value 203 | value attribute's value 204 | template_tag template tag {% .. %} 205 | variable template variable {{ .. }} 206 | template_comment template comment, both {# .. #} and {% comment %} 207 | filter filter from "|" till the next filter or the end of tag 208 | argument filter argument 209 | 210 | Handlebars ("handlebars"): 211 | 212 | expression expression to be evaluated 213 | variable variable 214 | begin-block the beginning of a block 215 | end-block the ending of a block 216 | string string 217 | 218 | JSON ("json"): 219 | 220 | number number 221 | literal "true", "false" and "null" 222 | string string value 223 | attribute name of an object property 224 | value value of an object property 225 | 226 | JavaScript ("javascript"): 227 | 228 | keyword keyword 229 | comment comment 230 | number number 231 | literal special literal: "true", "false" and "null" 232 | string string 233 | regexp regular expression 234 | function header of a function 235 | title name of a function inside a header 236 | params parentheses and everything inside them in a function's header 237 | 238 | CoffeeScript ("coffeescript"): 239 | 240 | keyword keyword 241 | comment comment 242 | number number 243 | literal special literal: "true", "false" and "null" 244 | built_in built-in objects and functions ("window", "console", "require", etc...) 245 | string string 246 | subst #{ ... } interpolation in double-quoted strings 247 | regexp regular expression 248 | function header of a function 249 | class header of a class 250 | title name of a function variable inside a header 251 | params parentheses and everything inside them in a function's header 252 | property @-property within class and functions 253 | 254 | ActionScript ("actionscript"): 255 | 256 | comment comment 257 | string string 258 | number number 259 | keyword keywords 260 | literal literal 261 | reserved reserved keyword 262 | title name of declaration (package, class or function) 263 | preprocessor preprocessor directive (import, include) 264 | type type of returned value (for functions) 265 | package package (named or not) 266 | class class/interface 267 | function function 268 | param params of function 269 | rest_arg rest argument of function 270 | 271 | VBScript ("vbscript"): 272 | 273 | keyword keyword 274 | number number 275 | string string 276 | comment comment 277 | built_in built-in function 278 | 279 | VB.Net ("vbnet"): 280 | 281 | keyword keyword 282 | built_in built-in types 283 | literal "true", "false" and "nothing" 284 | string string 285 | comment comment 286 | xmlDocTag xmldoc tag ("'''", "", "<..>") 287 | preprocessor preprocessor directive 288 | 289 | HTTP ("http"): 290 | 291 | request first line of a request 292 | status first line of a response 293 | attribute header name 294 | string header value or query string in a request line 295 | number status code 296 | 297 | Lua ("lua"): 298 | 299 | keyword keyword 300 | number number 301 | string string 302 | comment comment 303 | built_in built-in operator 304 | function header of a function 305 | title name of a function inside a header 306 | params everything inside parentheses in a function's header 307 | long_brackets multiline string in [=[ .. ]=] 308 | 309 | Delphi ("delphi"): 310 | 311 | keyword keyword 312 | comment comment (of any type) 313 | number number 314 | string string 315 | function header of a function, procedure, constructor and destructor 316 | title name of a function, procedure, constructor or destructor 317 | inside a header 318 | params everything inside parentheses in a function's header 319 | class class' body from "= class" till "end;" 320 | 321 | Java ("java"): 322 | 323 | keyword keyword 324 | number number 325 | string string 326 | comment commment 327 | annotaion annotation 328 | javadoc javadoc comment 329 | class class header from "class" till "{" 330 | title class name inside a header 331 | params everything in parentheses inside a class header 332 | inheritance keywords "extends" and "implements" inside class header 333 | 334 | C++ ("cpp"): 335 | 336 | keyword keyword 337 | number number 338 | string string and character 339 | comment comment 340 | preprocessor preprocessor directive 341 | stl_container instantiation of STL containers ("vector<...>") 342 | 343 | Objective C ("objectivec"): 344 | 345 | keyword keyword 346 | built_in Cocoa/Cocoa Touch constants and classes 347 | number number 348 | string string 349 | comment comment 350 | preprocessor preprocessor directive 351 | class interface/implementation, protocol and forward class declaration 352 | variable properties and struct accesors 353 | 354 | Vala ("vala"): 355 | 356 | keyword keyword 357 | number number 358 | string string 359 | comment comment 360 | class class definitions 361 | title in class definition 362 | constant ALL_UPPER_CASE 363 | 364 | C# ("cs"): 365 | 366 | keyword keyword 367 | number number 368 | string string 369 | comment commment 370 | xmlDocTag xmldoc tag ("///", "", "<..>") 371 | 372 | F# ("fsharp"): 373 | 374 | keywords keyword 375 | number number 376 | string string 377 | commment comment 378 | class any custom F# type 379 | title the name of a custom F# type 380 | annotation any attribute 381 | 382 | OCaml ("ocaml"): 383 | keywords keyword 384 | number number 385 | string string 386 | commment comment 387 | class any custom OCaml type 388 | title the name of a custom OCaml type 389 | annotation any attribute 390 | 391 | D ("d"): 392 | 393 | comment comment 394 | string string constant 395 | number number 396 | keyword language keywords (including @attributes) 397 | constant true false null 398 | built_in built-in plain types (int, string etc.) 399 | 400 | RenderMan RSL ("rsl"): 401 | 402 | keyword keyword 403 | number number 404 | string string (including @"..") 405 | comment comment 406 | preprocessor preprocessor directive 407 | shader sahder keywords 408 | shading shading keywords 409 | built_in built-in function 410 | 411 | RenderMan RIB ("rib"): 412 | 413 | keyword keyword 414 | number number 415 | string string 416 | comment comment 417 | commands command 418 | 419 | Maya Embedded Language ("mel"): 420 | 421 | keyword keyword 422 | number number 423 | string string 424 | comment comment 425 | variable variable 426 | 427 | SQL ("sql"): 428 | 429 | keyword keyword (mostly SQL'92 and SQL'99) 430 | number number 431 | string string (of any type: "..", '..', `..`) 432 | comment comment 433 | aggregate aggregate function 434 | 435 | Smalltalk ("smalltalk"): 436 | 437 | keyword keyword 438 | number number 439 | string string 440 | comment commment 441 | symbol symbol 442 | array array 443 | class name of a class 444 | char char 445 | localvars block of local variables 446 | 447 | Lisp ("lisp"): 448 | 449 | keyword keyword 450 | number number 451 | string string 452 | comment commment 453 | variable variable 454 | literal b, t and nil 455 | list non-quoted list 456 | title first symbol in a non-quoted list 457 | body remainder of the non-quoted list 458 | quoted quoted list, both "(quote .. )" and "'(..)" 459 | 460 | Clojure ("clojure"): 461 | 462 | comment comments and hints 463 | string string 464 | number number 465 | collection collections 466 | attribute :keyword 467 | title function name (built-in or user defined) 468 | built_in built-in function name 469 | 470 | Ini ("ini"): 471 | 472 | title title of a section 473 | value value of a setting of any type 474 | string string 475 | number number 476 | keyword boolean value keyword 477 | 478 | Apache ("apache"): 479 | 480 | keyword keyword 481 | number number 482 | comment commment 483 | literal On and Off 484 | sqbracket variables in rewrites "%{..}" 485 | cbracket options in rewrites "[..]" 486 | tag begin and end of a configuration section 487 | 488 | Nginx ("nginx"): 489 | 490 | title directive title 491 | string string 492 | number number 493 | comment comment 494 | built_in built-in constant 495 | variable $-variable 496 | regexp regexp 497 | 498 | Diff ("diff"): 499 | 500 | header file header 501 | chunk chunk header within a file 502 | addition added lines 503 | deletion deleted lines 504 | change changed lines 505 | 506 | DOS ("dos"): 507 | 508 | keyword keyword 509 | flow batch control keyword 510 | stream DOS special files ("con", "prn", ...) 511 | winutils some commands (see dos.js specifically) 512 | envvar environment variables 513 | 514 | Bash ("bash"): 515 | 516 | keyword keyword 517 | string string 518 | number number 519 | comment comment 520 | literal special literal: "true" и "false" 521 | variable variable 522 | shebang script interpreter header 523 | 524 | Makefile ("makefile"): 525 | 526 | keyword keyword ".PHONY" within the phony line 527 | string string 528 | comment comment 529 | variable $(..) variable 530 | title target title 531 | constant constant within the initial definition 532 | 533 | CMake ("cmake"): 534 | 535 | keyword keyword 536 | number number 537 | string string 538 | comment commment 539 | envvar $-variable 540 | operator operator (LESS, STREQUAL, MATCHES, etc) 541 | 542 | Axapta ("axapta"): 543 | 544 | keyword keyword 545 | number number 546 | string string 547 | comment commment 548 | class class header from "class" till "{" 549 | title class name inside a header 550 | params everything in parentheses inside a class header 551 | inheritance keywords "extends" and "implements" inside class header 552 | preprocessor preprocessor directive 553 | 554 | Oracle Rules Language ("ruleslanguage"): 555 | 556 | comment comment 557 | string string constant 558 | number number 559 | keyword language keywords 560 | built_in built-in functions 561 | array array stem 562 | 563 | 1C ("1c"): 564 | 565 | keyword keyword 566 | number number 567 | date date 568 | string string 569 | comment commment 570 | function header of function or procudure 571 | title function name inside a header 572 | params everything in parentheses inside a function header 573 | preprocessor preprocessor directive 574 | 575 | AVR assembler ("avrasm"): 576 | 577 | keyword keyword 578 | built_in pre-defined register 579 | number number 580 | string string 581 | comment commment 582 | label label 583 | preprocessor preprocessor directive 584 | localvars substitution in .macro 585 | 586 | VHDL ("vhdl"): 587 | 588 | keyword keyword 589 | number number 590 | string string 591 | comment commment 592 | literal signal logical value 593 | typename typename 594 | attribute signal attribute 595 | 596 | Parser3 ("parser3"): 597 | 598 | keyword keyword 599 | number number 600 | comment commment 601 | variable variable starting with "$" 602 | preprocessor preprocessor directive 603 | title user-defined name starting with "@" 604 | 605 | LiveCode Server ("livecodeserver"): 606 | 607 | variable variable starting with "g", "t", "p", "s", "$_" 608 | string string 609 | comment comment 610 | number number 611 | title name of a command or a function 612 | keyword keyword 613 | constant constant 614 | operator operator 615 | built_in built_in functions and commands 616 | function header of a function 617 | command header of a command 618 | preprocessor preprocessor marks: "", "" 619 | 620 | TeX ("tex"): 621 | 622 | comment comment 623 | number number 624 | command command 625 | parameter parameter 626 | formula formula 627 | special special symbol 628 | 629 | Haskell ("haskell"): 630 | 631 | comment comment 632 | pragma GHC pragma 633 | preprocessor CPP preprocessor directive 634 | keyword keyword 635 | number number 636 | string string 637 | title function or variable name 638 | type value, type or type class constructor name (i.e. capitalized) 639 | container (..., ...) or {...; ...} list in declaration or record 640 | module module declaration 641 | import import declaration 642 | class type class or instance declaration 643 | typedef type declaration (type, newtype, data) 644 | default default declaration 645 | infix infix declaration 646 | foreign FFI declaration 647 | shebang shebang line 648 | 649 | Erlang ("erlang"): 650 | 651 | comment comment 652 | string string 653 | number number 654 | keyword keyword 655 | record_name record access (#record_name) 656 | title name of declaration function 657 | variable variable (starts with capital letter or with _) 658 | pp.keywords module's attribute (-attribute) 659 | function_name atom or atom:atom in case of function call 660 | 661 | Rust ("rust"): 662 | 663 | comment comment 664 | string string 665 | number number 666 | keyword keyword 667 | title name of declaration 668 | preprocessor preprocessor directive 669 | 670 | Matlab ("matlab"): 671 | 672 | comment comment 673 | string string 674 | number number 675 | keyword keyword 676 | title function name 677 | function function 678 | param params of function 679 | matrix matrix in [ .. ] 680 | cell cell in { .. } 681 | 682 | Scilab ("scilab"): 683 | 684 | comment comment 685 | string string 686 | number number 687 | keyword keyword 688 | title function name 689 | function function 690 | param params of function 691 | matrix matrix in [ .. ] 692 | 693 | R ("r"): 694 | 695 | comment comment 696 | string string constant 697 | number number 698 | keyword language keywords (function, if) plus "structural" 699 | functions (attach, require, setClass) 700 | literal special literal: TRUE, FALSE, NULL, NA, etc. 701 | 702 | OpenGL Shading Language ("glsl"): 703 | 704 | comment comment 705 | number number 706 | preprocessor preprocessor directive 707 | keyword keyword 708 | built_in GLSL built-in functions and variables 709 | literal true false 710 | 711 | AppleScript ("applescript"): 712 | 713 | keyword keyword 714 | command core AppleScript command 715 | constant AppleScript built in constant 716 | type AppleScript variable type (integer, etc.) 717 | property Applescript built in property (length, etc.) 718 | number number 719 | string string 720 | comment comment 721 | title name of a handler 722 | 723 | Brainfuck ("brainfuck"): 724 | 725 | title Brainfuck while loop command 726 | literal Brainfuck inc and dec commands 727 | comment comment 728 | string Brainfuck input and output commands 729 | 730 | Mizar ("mizar"): 731 | 732 | keyword keyword 733 | comment comment 734 | -------------------------------------------------------------------------------- /doc/_highlight/highlight.pack.js: -------------------------------------------------------------------------------- 1 | var hljs=new function(){function l(o){return o.replace(/&/gm,"&").replace(//gm,">")}function b(p){for(var o=p.firstChild;o;o=o.nextSibling){if(o.nodeName.toUpperCase()=="CODE"){return o}if(!(o.nodeType==3&&o.nodeValue.match(/\s+/))){break}}}function h(p,o){return Array.prototype.map.call(p.childNodes,function(q){if(q.nodeType==3){return o?q.nodeValue.replace(/\n/g,""):q.nodeValue}if(q.nodeName.toUpperCase()=="BR"){return"\n"}return h(q,o)}).join("")}function a(q){var p=(q.className+" "+(q.parentNode?q.parentNode.className:"")).split(/\s+/);p=p.map(function(r){return r.replace(/^language-/,"")});for(var o=0;o
"}function x(z){y+=""+z.nodeName.toLowerCase()+">"}function o(z){(z.event=="start"?t:x)(z.node)}while(p.length||r.length){var w=u();y+=l(v.substr(q,w[0].offset-q));q=w[0].offset;if(w==p){s.reverse().forEach(x);do{o(w.splice(0,1)[0]);w=u()}while(w==p&&w.length&&w[0].offset==q);s.reverse().forEach(t)}else{if(w[0].event=="start"){s.push(w[0].node)}else{s.pop()}o(w.splice(0,1)[0])}}return y+l(v.substr(q))}function f(r){function o(s){return(s&&s.source)||s}function p(t,s){return RegExp(o(t),"m"+(r.cI?"i":"")+(s?"g":""))}function q(z,x){if(z.compiled){return}z.compiled=true;var u=[];if(z.k){var s={};function A(B,t){if(r.cI){t=t.toLowerCase()}t.split(" ").forEach(function(C){var D=C.split("|");s[D[0]]=[B,D[1]?Number(D[1]):1];u.push(D[0])})}z.lR=p(z.l||"\\b"+hljs.IR+"\\b(?!\\.)",true);if(typeof z.k=="string"){A("keyword",z.k)}else{for(var y in z.k){if(!z.k.hasOwnProperty(y)){continue}A(y,z.k[y])}}z.k=s}if(x){if(z.bWK){z.b="\\b("+u.join("|")+")\\b(?!\\.)\\s*"}z.bR=p(z.b?z.b:"\\B|\\b");if(!z.e&&!z.eW){z.e="\\B|\\b"}if(z.e){z.eR=p(z.e)}z.tE=o(z.e)||"";if(z.eW&&x.tE){z.tE+=(z.e?"|":"")+x.tE}}if(z.i){z.iR=p(z.i)}if(z.r===undefined){z.r=1}if(!z.c){z.c=[]}for(var w=0;w '+O[0]+"