rugments 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +52 -0
  3. data/README.md +195 -0
  4. data/bin/rugmentize +6 -0
  5. data/lib/rugments/cli.rb +357 -0
  6. data/lib/rugments/formatter.rb +29 -0
  7. data/lib/rugments/formatters/html.rb +142 -0
  8. data/lib/rugments/formatters/null.rb +17 -0
  9. data/lib/rugments/formatters/terminal256.rb +174 -0
  10. data/lib/rugments/lexer.rb +431 -0
  11. data/lib/rugments/lexers/apache/keywords.yml +453 -0
  12. data/lib/rugments/lexers/apache.rb +67 -0
  13. data/lib/rugments/lexers/apple_script.rb +366 -0
  14. data/lib/rugments/lexers/c.rb +210 -0
  15. data/lib/rugments/lexers/clojure.rb +109 -0
  16. data/lib/rugments/lexers/coffeescript.rb +172 -0
  17. data/lib/rugments/lexers/common_lisp.rb +343 -0
  18. data/lib/rugments/lexers/conf.rb +22 -0
  19. data/lib/rugments/lexers/cpp.rb +63 -0
  20. data/lib/rugments/lexers/csharp.rb +85 -0
  21. data/lib/rugments/lexers/css.rb +269 -0
  22. data/lib/rugments/lexers/dart.rb +102 -0
  23. data/lib/rugments/lexers/diff.rb +39 -0
  24. data/lib/rugments/lexers/elixir.rb +105 -0
  25. data/lib/rugments/lexers/erb.rb +54 -0
  26. data/lib/rugments/lexers/erlang.rb +116 -0
  27. data/lib/rugments/lexers/factor.rb +300 -0
  28. data/lib/rugments/lexers/gherkin/keywords.rb +13 -0
  29. data/lib/rugments/lexers/gherkin.rb +135 -0
  30. data/lib/rugments/lexers/go.rb +176 -0
  31. data/lib/rugments/lexers/groovy.rb +102 -0
  32. data/lib/rugments/lexers/haml.rb +226 -0
  33. data/lib/rugments/lexers/handlebars.rb +77 -0
  34. data/lib/rugments/lexers/haskell.rb +181 -0
  35. data/lib/rugments/lexers/html.rb +92 -0
  36. data/lib/rugments/lexers/http.rb +78 -0
  37. data/lib/rugments/lexers/ini.rb +55 -0
  38. data/lib/rugments/lexers/io.rb +66 -0
  39. data/lib/rugments/lexers/java.rb +74 -0
  40. data/lib/rugments/lexers/javascript.rb +258 -0
  41. data/lib/rugments/lexers/literate_coffeescript.rb +31 -0
  42. data/lib/rugments/lexers/literate_haskell.rb +34 -0
  43. data/lib/rugments/lexers/llvm.rb +82 -0
  44. data/lib/rugments/lexers/lua/builtins.rb +21 -0
  45. data/lib/rugments/lexers/lua.rb +120 -0
  46. data/lib/rugments/lexers/make.rb +114 -0
  47. data/lib/rugments/lexers/markdown.rb +151 -0
  48. data/lib/rugments/lexers/matlab/builtins.rb +10 -0
  49. data/lib/rugments/lexers/matlab.rb +70 -0
  50. data/lib/rugments/lexers/moonscript.rb +108 -0
  51. data/lib/rugments/lexers/nginx.rb +69 -0
  52. data/lib/rugments/lexers/nim.rb +149 -0
  53. data/lib/rugments/lexers/objective_c.rb +188 -0
  54. data/lib/rugments/lexers/ocaml.rb +109 -0
  55. data/lib/rugments/lexers/perl.rb +195 -0
  56. data/lib/rugments/lexers/php/builtins.rb +192 -0
  57. data/lib/rugments/lexers/php.rb +162 -0
  58. data/lib/rugments/lexers/plain_text.rb +23 -0
  59. data/lib/rugments/lexers/prolog.rb +62 -0
  60. data/lib/rugments/lexers/properties.rb +53 -0
  61. data/lib/rugments/lexers/puppet.rb +126 -0
  62. data/lib/rugments/lexers/python.rb +225 -0
  63. data/lib/rugments/lexers/qml.rb +70 -0
  64. data/lib/rugments/lexers/r.rb +55 -0
  65. data/lib/rugments/lexers/racket.rb +540 -0
  66. data/lib/rugments/lexers/ruby.rb +413 -0
  67. data/lib/rugments/lexers/rust.rb +188 -0
  68. data/lib/rugments/lexers/sass/common.rb +172 -0
  69. data/lib/rugments/lexers/sass.rb +72 -0
  70. data/lib/rugments/lexers/scala.rb +140 -0
  71. data/lib/rugments/lexers/scheme.rb +109 -0
  72. data/lib/rugments/lexers/scss.rb +32 -0
  73. data/lib/rugments/lexers/sed.rb +167 -0
  74. data/lib/rugments/lexers/shell.rb +150 -0
  75. data/lib/rugments/lexers/slim.rb +222 -0
  76. data/lib/rugments/lexers/smalltalk.rb +114 -0
  77. data/lib/rugments/lexers/sml.rb +345 -0
  78. data/lib/rugments/lexers/sql.rb +138 -0
  79. data/lib/rugments/lexers/swift.rb +153 -0
  80. data/lib/rugments/lexers/tcl.rb +189 -0
  81. data/lib/rugments/lexers/tex.rb +70 -0
  82. data/lib/rugments/lexers/toml.rb +68 -0
  83. data/lib/rugments/lexers/vb.rb +162 -0
  84. data/lib/rugments/lexers/viml/keywords.rb +11 -0
  85. data/lib/rugments/lexers/viml.rb +99 -0
  86. data/lib/rugments/lexers/xml.rb +57 -0
  87. data/lib/rugments/lexers/yaml.rb +362 -0
  88. data/lib/rugments/plugins/redcarpet.rb +28 -0
  89. data/lib/rugments/regex_lexer.rb +432 -0
  90. data/lib/rugments/template_lexer.rb +23 -0
  91. data/lib/rugments/text_analyzer.rb +46 -0
  92. data/lib/rugments/theme.rb +202 -0
  93. data/lib/rugments/themes/base16.rb +128 -0
  94. data/lib/rugments/themes/colorful.rb +65 -0
  95. data/lib/rugments/themes/github.rb +69 -0
  96. data/lib/rugments/themes/monokai.rb +88 -0
  97. data/lib/rugments/themes/monokai_sublime.rb +89 -0
  98. data/lib/rugments/themes/thankful_eyes.rb +69 -0
  99. data/lib/rugments/token.rb +180 -0
  100. data/lib/rugments/util.rb +99 -0
  101. data/lib/rugments/version.rb +3 -0
  102. data/lib/rugments.rb +33 -0
  103. metadata +149 -0
@@ -0,0 +1,151 @@
1
+ module Rugments
2
+ module Lexers
3
+ class Markdown < RegexLexer
4
+ title 'Markdown'
5
+ desc 'Markdown, a light-weight markup language for authors'
6
+
7
+ tag 'markdown'
8
+ aliases 'md', 'mkd'
9
+ filenames '*.markdown', '*.md', '*.mkd'
10
+ mimetypes 'text/x-markdown'
11
+
12
+ def html
13
+ @html ||= HTML.new(options)
14
+ end
15
+
16
+ start { html.reset! }
17
+
18
+ edot = /\\.|[^\\\n]/
19
+
20
+ state :root do
21
+ # YAML frontmatter
22
+ rule(/\A(---\s*\n.*?\n?)^(---\s*$\n?)/m) { delegate YAML }
23
+
24
+ rule /\\./, Str::Escape
25
+
26
+ rule /^[\S ]+\n(?:---*)\n/, Generic::Heading
27
+ rule /^[\S ]+\n(?:===*)\n/, Generic::Subheading
28
+
29
+ rule /^#(?=[^#]).*?$/, Generic::Heading
30
+ rule /^##*.*?$/, Generic::Subheading
31
+
32
+ # TODO: syntax highlight the code block, github style
33
+ rule /(\n[ \t]*)(```|~~~)(.*?)(\n.*?)(\2)/m do |m|
34
+ sublexer = Lexer.find_fancy(m[3].strip, m[4])
35
+ sublexer ||= PlainText.new(token: Str::Backtick)
36
+
37
+ token Text, m[1]
38
+ token Punctuation, m[2]
39
+ token Name::Label, m[3]
40
+ delegate sublexer, m[4]
41
+ token Punctuation, m[5]
42
+ end
43
+
44
+ rule /\n\n(( |\t).*?\n|\n)+/, Str::Backtick
45
+
46
+ rule /(`+)#{edot}*\1/, Str::Backtick
47
+
48
+ # various uses of * are in order of precedence
49
+
50
+ # line breaks
51
+ rule /^(\s*[*]){3,}\s*$/, Punctuation
52
+ rule /^(\s*[-]){3,}\s*$/, Punctuation
53
+
54
+ # bulleted lists
55
+ rule /^\s*[*+-](?=\s)/, Punctuation
56
+
57
+ # numbered lists
58
+ rule /^\s*\d+\./, Punctuation
59
+
60
+ # blockquotes
61
+ rule /^\s*>.*?$/, Generic::Traceback
62
+
63
+ # link references
64
+ # [foo]: bar "baz"
65
+ rule %r{^
66
+ (\s*) # leading whitespace
67
+ (\[) (#{edot}+?) (\]) # the reference
68
+ (\s*) (:) # colon
69
+ }x do
70
+ groups Text, Punctuation, Str::Symbol, Punctuation, Text, Punctuation
71
+
72
+ push :title
73
+ push :url
74
+ end
75
+
76
+ # links and images
77
+ rule /(!?\[)(#{edot}+?)(\])/ do
78
+ groups Punctuation, Name::Variable, Punctuation
79
+ push :link
80
+ end
81
+
82
+ rule /[*][*]#{edot}*?[*][*]/, Generic::Strong
83
+ rule /__#{edot}*?__/, Generic::Strong
84
+
85
+ rule /[*]#{edot}*?[*]/, Generic::Emph
86
+ rule /_#{edot}*?_/, Generic::Emph
87
+
88
+ # Automatic links
89
+ rule /<.*?@.+[.].+>/, Name::Variable
90
+ rule %r{<(https?|mailto|ftp)://#{edot}*?>}, Name::Variable
91
+
92
+ rule /[^\\`\[*\n&<]+/, Text
93
+
94
+ # inline html
95
+ rule(/&\S*;/) { delegate html }
96
+ rule(/<#{edot}*?>/) { delegate html }
97
+ rule /[&<]/, Text
98
+
99
+ rule /\n/, Text
100
+ end
101
+
102
+ state :link do
103
+ rule /(\[)(#{edot}*?)(\])/ do
104
+ groups Punctuation, Str::Symbol, Punctuation
105
+ pop!
106
+ end
107
+
108
+ rule /[(]/ do
109
+ token Punctuation
110
+ push :inline_title
111
+ push :inline_url
112
+ end
113
+
114
+ rule /[ \t]+/, Text
115
+
116
+ rule(//) { pop! }
117
+ end
118
+
119
+ state :url do
120
+ rule /[ \t]+/, Text
121
+
122
+ # the url
123
+ rule /(<)(#{edot}*?)(>)/ do
124
+ groups Name::Tag, Str::Other, Name::Tag
125
+ pop!
126
+ end
127
+
128
+ rule /\S+/, Str::Other, :pop!
129
+ end
130
+
131
+ state :title do
132
+ rule /"#{edot}*?"/, Name::Namespace
133
+ rule /'#{edot}*?'/, Name::Namespace
134
+ rule /[(]#{edot}*?[)]/, Name::Namespace
135
+ rule /\s*(?=["'()])/, Text
136
+ rule(//) { pop! }
137
+ end
138
+
139
+ state :inline_title do
140
+ rule /[)]/, Punctuation, :pop!
141
+ mixin :title
142
+ end
143
+
144
+ state :inline_url do
145
+ rule /[^<\s)]+/, Str::Other, :pop!
146
+ rule /\s+/m, Text
147
+ mixin :url
148
+ end
149
+ end
150
+ end
151
+ end
@@ -0,0 +1,10 @@
1
+ # automatically generated by `rake builtins:matlab`
2
+ module Rugments
3
+ module Lexers
4
+ class Matlab
5
+ def self.builtins
6
+ @builtins ||= Set.new %w(ans clc diary format home iskeyword more accumarray blkdiag diag eye false freqspace linspace logspace meshgrid ndgrid ones rand true zeros cat horzcat vertcat colon end ind2sub sub2ind length ndims numel size height width iscolumn isempty ismatrix isrow isscalar isvector blkdiag circshift ctranspose diag flip fliplr flipud ipermute permute repmat reshape rot90 shiftdim issorted sort sortrows squeeze transpose vectorize plus uplus minus uminus times rdivide ldivide power mtimes mrdivide mldivide mpower cumprod cumsum diff prod sum ceil fix floor idivide mod rem round relationaloperators eq ge gt le lt ne isequal isequaln logicaloperatorsshortcircuit and not or xor all any false find islogical logical true intersect ismember issorted setdiff setxor union unique join innerjoin outerjoin bitand bitcmp bitget bitor bitset bitshift bitxor swapbytes specialcharacters colon double single int8 int16 int32 int64 uint8 uint16 uint32 uint64 cast typecast isinteger isfloat isnumeric isreal isfinite isinf isnan eps flintmax inf intmax intmin nan realmax realmin blanks cellstr char iscellstr ischar sprintf strcat strjoin ischar isletter isspace isstrprop sscanf strfind strrep strsplit strtok validatestring symvar regexp regexpi regexprep regexptranslate strcmp strcmpi strncmp strncmpi blanks deblank strtrim lower upper strjust datetime years days hours minutes seconds duration calyears calquarters calmonths calweeks caldays calendarduration exceltime juliandate posixtime yyyymmdd year quarter month week day hour minute second ymd hms split time timeofday isdst isweekend tzoffset between caldiff dateshift isbetween isdatetime isduration iscalendarduration isnat datenum datevec datestr now clock date calendar eomday weekday addtodate etime categorical iscategorical categories iscategory isordinal isprotected addcats mergecats removecats renamecats reordercats setcats summary countcats isundefined table array2table cell2table struct2table table2array table2cell table2struct readtable writetable istable height width summary intersect ismember setdiff setxor unique union join innerjoin outerjoin sortrows stack unstack ismissing standardizemissing varfun rowfun struct fieldnames getfield isfield isstruct orderfields rmfield setfield arrayfun structfun table2struct struct2table cell2struct struct2cell cell cell2mat cell2struct cell2table celldisp cellfun cellplot cellstr iscell iscellstr mat2cell num2cell strjoin strsplit struct2cell table2cell function_handle feval func2str str2func localfunctions functions addevent delevent gettsafteratevent gettsafterevent gettsatevent gettsbeforeatevent gettsbeforeevent gettsbetweenevents gettscollection isemptytscollection lengthtscollection settscollection sizetscollection tscollection addsampletocollection addts delsamplefromcollection getabstimetscollection getsampleusingtimetscollection gettimeseriesnames horzcattscollection removets resampletscollection setabstimetscollection settimeseriesnames vertcattscollection isa iscalendarduration iscategorical iscell iscellstr ischar isdatetime isduration isfield isfloat ishghandle isinteger isjava islogical isnumeric isobject isreal isstr isstruct istable is class validateattributes whos char cellstr int2str mat2str num2str str2double str2num native2unicode unicode2native base2dec bin2dec dec2base dec2bin dec2hex hex2dec hex2num num2hex table2array table2cell table2struct array2table cell2table struct2table cell2mat cell2struct mat2cell num2cell struct2cell plus uplus minus uminus times rdivide ldivide power mtimes mrdivide mldivide mpower cumprod cumsum diff prod sum ceil fix floor idivide mod rem round sin sind asin asind sinh asinh cos cosd acos acosd cosh acosh tan tand atan atand atan2 atan2d tanh atanh csc cscd acsc acscd csch acsch sec secd asec asecd sech asech cot cotd acot acotd coth acoth hypot exp expm1 log log10 log1p log2 nextpow2 nthroot pow2 reallog realpow realsqrt sqrt abs angle complex conj cplxpair i imag isreal j real sign unwrap factor factorial gcd isprime lcm nchoosek perms primes rat rats poly polyder polyeig polyfit polyint polyval polyvalm residue roots airy besselh besseli besselj besselk bessely beta betainc betaincinv betaln ellipj ellipke erf erfc erfcinv erfcx erfinv expint gamma gammainc gammaincinv gammaln legendre psi cart2pol cart2sph pol2cart sph2cart eps flintmax i j inf pi nan isfinite isinf isnan compan gallery hadamard hankel hilb invhilb magic pascal rosser toeplitz vander wilkinson cross dot kron surfnorm tril triu transpose cond condest inv linsolve lscov lsqnonneg pinv rcond sylvester mldivide mrdivide chol ichol cholupdate ilu lu qr qrdelete qrinsert qrupdate planerot ldl cdf2rdf rsf2csf gsvd svd balance cdf2rdf condeig eig eigs gsvd hess ordeig ordqz ordschur poly polyeig qz rsf2csf schur sqrtm ss2tf svd svds bandwidth cond condeig det isbanded isdiag ishermitian issymmetric istril istriu norm normest null orth rank rcond rref subspace trace expm logm sqrtm bsxfun funm arrayfun accumarray mpower corrcoef cov max cummax mean median min cummin mode std var rand randn randi randperm rng interp1 pchip spline ppval mkpp unmkpp padecoef interpft interp2 interp3 interpn ndgrid meshgrid griddata griddatan fminbnd fminsearch fzero lsqnonneg optimget optimset ode45 ode15s ode23 ode113 ode23t ode23tb ode23s ode15i decic odextend odeget odeset deval bvp4c bvp5c bvpinit bvpxtend bvpget bvpset deval dde23 ddesd ddensd ddeget ddeset deval pdepe pdeval integral integral2 integral3 quadgk quad2d cumtrapz trapz polyint del2 diff gradient polyder abs angle cplxpair fft fft2 fftn fftshift fftw ifft ifft2 ifftn ifftshift nextpow2 unwrap conv conv2 convn deconv detrend filter filter2 spdiags speye sprand sprandn sprandsym sparse spconvert issparse nnz nonzeros nzmax spalloc spfun spones spparms spy find full amd colamd colperm dmperm randperm symamd symrcm condest eigs ichol ilu normest spaugment sprank svds bicg bicgstab bicgstabl cgs gmres lsqr minres pcg qmr symmlq tfqmr etree etreeplot gplot symbfact treelayout treeplot unmesh tetramesh trimesh triplot trisurf delaunay delaunayn tetramesh trimesh triplot trisurf dsearchn tsearchn delaunay delaunayn boundary alphashape convhull convhulln patch voronoi voronoin polyarea inpolygon rectint plot plotyy plot3 loglog semilogx semilogy errorbar fplot ezplot ezplot3 linespec colorspec bar bar3 barh bar3h histogram histcounts rose pareto area pie pie3 stem stairs stem3 scatter scatter3 spy plotmatrix polar rose compass ezpolar linespec colorspec contour contourf contourc contour3 contourslice ezcontour ezcontourf feather quiver compass quiver3 streamslice streamline surf surfc surface surfl surfnorm mesh meshc meshz waterfall ribbon contour3 peaks cylinder ellipsoid sphere pcolor surf2patch ezsurf ezsurfc ezmesh ezmeshc contourslice flow isocaps isocolors isonormals isosurface reducepatch reducevolume shrinkfaces slice smooth3 subvolume volumebounds coneplot curl divergence interpstreamspeed stream2 stream3 streamline streamparticles streamribbon streamslice streamtube fill fill3 patch surf2patch movie getframe frame2im im2frame animatedline comet comet3 drawnow refreshdata title xlabel ylabel zlabel clabel datetick texlabel legend colorbar xlim ylim zlim box grid daspect pbaspect axes axis subplot hold gca cla annotation text line rectangle legend title xlabel ylabel zlabel datacursormode ginput gtext colormap colormapeditor colorbar brighten contrast shading graymon caxis hsv2rgb rgb2hsv rgbplot spinmap colordef whitebg hidden pan reset rotate rotate3d zoom datacursormode figurepalette plotbrowser plotedit plottools propertyeditor showplottool brush datacursormode linkdata linkaxes linkprop refreshdata view makehgtform viewmtx cameratoolbar campan camzoom camdolly camlookat camorbit campos camproj camroll camtarget camup camva camlight light lightangle lighting diffuse material specular alim alpha alphamap imshow image imagesc imread imwrite imfinfo imformats frame2im im2frame im2java im2double ind2rgb rgb2gray rgb2ind imapprox dither cmpermute cmunique print printopt printdlg printpreview orient savefig openfig hgexport hgsave hgload saveas axes figure groot get set inspect propedit gca gcf gcbf gcbo gco groot ancestor allchild findall findobj findfigs gobjects ishghandle ishandle copyobj delete gobjects isgraphics isempty isequal isa clf cla close set get groot uicontextmenu uimenu function_handle dragrect rbbox refresh shg hggroup hgtransform makehgtform eye hold ishold newplot clf cla drawnow opengl if for parfor switch try while break continue end pause return edit input publish notebook grabcode snapnow function nargin nargout varargin varargout narginchk nargoutchk validateattributes validatestring inputname persistent isvarname namelengthmax assignin global try error warning lastwarn assert oncleanup dbclear dbcont dbdown dbquit dbstack dbstatus dbstep dbstop dbtype dbup checkcode keyboard mlintrpt edit echo eval evalc evalin feval run builtin mfilename pcode clear clearvars disp openvar who whos load save matfile importdata uiimport csvread csvwrite dlmread dlmwrite textscan readtable writetable type xlsfinfo xlsread xlswrite readtable writetable fclose feof ferror fgetl fgets fileread fopen fprintf fread frewind fscanf fseek ftell fwrite im2java imfinfo imread imwrite nccreate ncdisp ncinfo ncread ncreadatt ncwrite ncwriteatt ncwriteschema netcdf h5create h5disp h5info h5read h5readatt h5write h5writeatt hdfinfo hdfread hdftool imread imwrite hdfan hdfhx hdfh hdfhd hdfhe hdfml hdfpt hdfv hdfvf hdfvh hdfvs hdfdf24 hdfdfr8 fitsdisp fitsinfo fitsread fitswrite multibandread multibandwrite cdfepoch cdfinfo cdfread cdfwrite todatenum cdflib audioinfo audioread audiowrite mmfileinfo audiodevinfo audioplayer audiorecorder sound soundsc beep lin2mu mu2lin xmlread xmlwrite xslt tcpclient datastore mapreduce datastore mapreducer matfile memmapfile dir ls pwd fileattrib exist isdir type visdiff what which cd copyfile delete recycle mkdir movefile rmdir open winopen fileparts fullfile filemarker filesep tempdir tempname matlabroot toolboxdir zip unzip gzip gunzip tar untar addpath rmpath path savepath userpath genpath pathsep pathtool restoredefaultpath clipboard computer dos getenv perl setenv system unix winqueryreg web webread websave weboptions urlread urlwrite sendmail instrcallback instrfind instrfindall readasync record serial serialbreak stopasync guide inspect figure axes uicontrol uitable uipanel uibuttongroup actxcontrol uitab uitabgroup uimenu uicontextmenu uitoolbar uipushtool uitoggletool dialog errordlg helpdlg msgbox questdlg uigetpref uisetpref waitbar warndlg export2wsdlg inputdlg listdlg uisetcolor uisetfont printdlg printpreview uigetdir uigetfile uiopen uiputfile uisave menu align movegui getpixelposition setpixelposition listfonts textwrap uistack uiwait uiresume waitfor waitforbuttonpress getappdata setappdata isappdata rmappdata guidata guihandles closereq classdef class isa isequal isobject enumeration events methods properties edit clear classdef import properties isprop dynamicprops methods ismethod handle dynamicprops isa events empty superclasses enumeration save load saveobj loadobj cat horzcat vertcat empty disp display numel size end subsref subsasgn subsindex substruct disp display details metaclass mexext inmem loadlibrary unloadlibrary libisloaded calllib libfunctions libfunctionsview libstruct libpointer javaarray javaclasspath javaaddpath javarmpath javachk isjava usejava javamethod javamethodedt javaobject javaobjectedt cell class clear depfun exist fieldnames im2java import inmem inspect isa methods methodsview which net enablenetfromnetworkdrive cell begininvoke endinvoke combine remove removeall bitand bitor bitxor bitnot actxserver actxcontrol actxcontrollist actxcontrolselect iscom addproperty deleteproperty inspect fieldnames methods methodsview invoke isevent eventlisteners registerevent unregisterallevents unregisterevent isinterface interfaces release move pyversion pyargs createclassfromwsdl createsoapmessage callsoapservice parsesoapresponse builddocsearchdb try functiontests runtests checkin checkout cmopts customverctrl undocheckout verctrl bench cputime memory profile profsave tic timeit toc clear inmem memory pack whos commandhistory commandwindow filebrowser workspace getpref setpref addpref rmpref ispref mex execute getchararray putchararray getfullmatrix putfullmatrix getvariable getworkspacedata putworkspacedata maximizecommandwindow minimizecommandwindow actxgetrunningserver enableservice mex dbmex mexext inmem ver computer mexext dbmex inmem mex mexext matlabwindows matlabunix exit quit matlabrc startup finish prefdir preferences ismac ispc isstudent isunix javachk license usejava ver verlessthan version doc help docsearch lookfor demo echodemo supportpackageinstaller targetupdater)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,70 @@
1
+ module Rugments
2
+ module Lexers
3
+ class Matlab < RegexLexer
4
+ title 'MATLAB'
5
+ desc 'Matlab'
6
+ tag 'matlab'
7
+ aliases 'm'
8
+ filenames '*.m'
9
+ mimetypes 'text/x-matlab', 'application/x-matlab'
10
+
11
+ def self.analyze_text(text)
12
+ return 0.4 if text.match(/^\s*% /) # % comments are a dead giveaway
13
+ end
14
+
15
+ def self.keywords
16
+ @keywords = Set.new %w(
17
+ break case catch classdef continue else elseif end for function
18
+ global if otherwise parfor persistent return spmd switch try while
19
+ )
20
+ end
21
+
22
+ def self.builtins
23
+ load Pathname.new(__FILE__).dirname.join('matlab/builtins.rb')
24
+ builtins
25
+ end
26
+
27
+ state :root do
28
+ rule /\s+/m, Text # Whitespace
29
+ rule %r([{]%.*?%[}])m, Comment::Multiline
30
+ rule /%.*$/, Comment::Single
31
+ rule /([.][.][.])(.*?)$/ do
32
+ groups(Keyword, Comment)
33
+ end
34
+
35
+ rule /^(!)(.*?)(?=%|$)/ do |m|
36
+ token Keyword, m[1]
37
+ delegate Shell, m[2]
38
+ end
39
+
40
+ rule /[a-zA-Z][_a-zA-Z0-9]*/m do |m|
41
+ match = m[0]
42
+ if self.class.keywords.include? match
43
+ token Keyword
44
+ elsif self.class.builtins.include? match
45
+ token Name::Builtin
46
+ else
47
+ token Name
48
+ end
49
+ end
50
+
51
+ rule %r{[(){};:,\/\\\]\[]}, Punctuation
52
+
53
+ rule /~=|==|<<|>>|[-~+\/*%=<>&^|.]/, Operator
54
+
55
+ rule /(\d+\.\d*|\d*\.\d+)(e[+-]?[0-9]+)?/i, Num::Float
56
+ rule /\d+e[+-]?[0-9]+/i, Num::Float
57
+ rule /\d+L/, Num::Integer::Long
58
+ rule /\d+/, Num::Integer
59
+
60
+ rule /'/, Str::Single, :string
61
+ end
62
+
63
+ state :string do
64
+ rule /[^']+/, Str::Single
65
+ rule /''/, Str::Escape
66
+ rule /'/, Str::Single, :pop!
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,108 @@
1
+ module Rugments
2
+ module Lexers
3
+ load_const :Lua, 'lua.rb'
4
+
5
+ class Moonscript < RegexLexer
6
+ title 'MoonScript'
7
+ desc 'Moonscript (http://www.moonscript.org)'
8
+ tag 'moonscript'
9
+ aliases 'moon'
10
+ filenames '*.moon'
11
+ mimetypes 'text/x-moonscript', 'application/x-moonscript'
12
+
13
+ def initialize(opts = {})
14
+ @function_highlighting = opts.delete(:function_highlighting) { true }
15
+ @disabled_modules = opts.delete(:disabled_modules) { [] }
16
+ super(opts)
17
+ end
18
+
19
+ def self.analyze_text(text)
20
+ return 1 if text.shebang? 'moon'
21
+ end
22
+
23
+ def builtins
24
+ return [] unless @function_highlighting
25
+
26
+ @builtins ||= Set.new.tap do |builtins|
27
+ Rouge::Lexers::Lua.builtins.each do |mod, fns|
28
+ next if @disabled_modules.include? mod
29
+ builtins.merge(fns)
30
+ end
31
+ end
32
+ end
33
+
34
+ state :root do
35
+ rule %r{#!(.*?)$}, Comment::Preproc # shebang
36
+ rule //, Text, :main
37
+ end
38
+
39
+ state :base do
40
+ ident = '(?:[\w_][\w\d_]*)'
41
+
42
+ rule %r{(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?'}, Num::Float
43
+ rule %r{(?i)\d+e[+-]?\d+}, Num::Float
44
+ rule %r{(?i)0x[0-9a-f]*}, Num::Hex
45
+ rule %r{\d+}, Num::Integer
46
+ rule %r{@#{ident}*}, Name::Variable::Instance
47
+ rule %r{[A-Z][\w\d_]*}, Name::Class
48
+ rule %r{"?[^"]+":}, Literal::String::Symbol
49
+ rule %r{#{ident}:}, Literal::String::Symbol
50
+ rule %r{:#{ident}}, Literal::String::Symbol
51
+
52
+ rule %r{\s+}, Text::Whitespace
53
+ rule %r{(==|~=|!=|<=|>=|\.\.\.|\.\.|->|=>|[=+\-*/%^<>#!\\])}, Operator
54
+ rule %r([\[\]\{\}\(\)\.,:;]), Punctuation
55
+ rule %r{(and|or|not)\b}, Operator::Word
56
+
57
+ keywords = %w(
58
+ break class continue do else elseif end extends for if import in
59
+ repeat return switch super then unless until using when with while
60
+ )
61
+ rule %r{(#{keywords.join('|')})\b}, Keyword
62
+ rule %r{(local|export)\b}, Keyword::Declaration
63
+ rule %r{(true|false|nil)\b}, Keyword::Constant
64
+
65
+ rule %r{[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?} do |m|
66
+ name = m[0]
67
+ if self.builtins.include?(name)
68
+ token Name::Builtin
69
+ elsif name =~ /\./
70
+ a, b = name.split('.', 2)
71
+ token Name, a
72
+ token Punctuation, '.'
73
+ token Name, b
74
+ else
75
+ token Name
76
+ end
77
+ end
78
+ end
79
+
80
+ state :main do
81
+ rule %r{--.*$}, Comment::Single
82
+ rule %r{\[(=*)\[.*?\]\1\]}m, Str::Heredoc
83
+
84
+ mixin :base
85
+
86
+ rule %r{'}, Str::Single, :sqs
87
+ rule %r{"}, Str::Double, :dqs
88
+ end
89
+
90
+ state :sqs do
91
+ rule %r{'}, Str::Single, :pop!
92
+ rule %r{[^']+}, Str::Single
93
+ end
94
+
95
+ state :interpolation do
96
+ rule %r(\}), Str::Interpol, :pop!
97
+ mixin :base
98
+ end
99
+
100
+ state :dqs do
101
+ rule %r(#\{), Str::Interpol, :interpolation
102
+ rule %r{"}, Str::Double, :pop!
103
+ rule %r(#[^{]), Str::Double
104
+ rule %r{[^"#]+}, Str::Double
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,69 @@
1
+ module Rugments
2
+ module Lexers
3
+ class Nginx < RegexLexer
4
+ title 'nginx'
5
+ desc 'configuration files for the nginx web server (nginx.org)'
6
+ tag 'nginx'
7
+ mimetypes 'text/x-nginx-conf'
8
+ filenames 'nginx.conf'
9
+
10
+ id = /[^\s$;{}()#]+/
11
+
12
+ state :root do
13
+ rule /(include)(\s+)([^\s;]+)/ do
14
+ groups Keyword, Text, Name
15
+ end
16
+
17
+ rule id, Keyword, :statement
18
+
19
+ mixin :base
20
+ end
21
+
22
+ state :block do
23
+ rule /}/, Punctuation, :pop!
24
+ rule id, Keyword::Namespace, :statement
25
+ mixin :base
26
+ end
27
+
28
+ state :statement do
29
+ rule /{/ do
30
+ token Punctuation; pop!; push :block
31
+ end
32
+
33
+ rule /;/, Punctuation, :pop!
34
+
35
+ mixin :base
36
+ end
37
+
38
+ state :base do
39
+ rule /\s+/, Text
40
+
41
+ rule /#.*?\n/, Comment::Single
42
+ rule /(?:on|off)\b/, Name::Constant
43
+ rule /[$][\w-]+/, Name::Variable
44
+
45
+ # host/port
46
+ rule /([a-z0-9.-]+)(:)([0-9]+)/i do
47
+ groups Name::Function, Punctuation, Num::Integer
48
+ end
49
+
50
+ # mimetype
51
+ rule %r{[a-z-]+/[a-z-]+}i, Name::Class
52
+
53
+ rule /[0-9]+[kmg]?\b/i, Num::Integer
54
+ rule /(~)(\s*)([^\s{]+)/ do
55
+ groups Punctuation, Text, Str::Regex
56
+ end
57
+
58
+ rule /[:=~]/, Punctuation
59
+
60
+ # pathname
61
+ rule %r{/#{id}?}, Name
62
+
63
+ rule /[^#\s;{}$\\]+/, Str # catchall
64
+
65
+ rule /[$;]/, Text
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,149 @@
1
+ module Rugments
2
+ module Lexers
3
+ class Nim < RegexLexer
4
+ # This is pretty much a 1-1 port of the pygments NimrodLexer class
5
+ title 'Nim'
6
+ desc 'The Nim programming language (http://nim-lang.org/)'
7
+
8
+ tag 'nim'
9
+ aliases 'nimrod'
10
+ filenames '*.nim'
11
+
12
+ KEYWORDS = %w(
13
+ addr as asm atomic bind block break case cast const continue
14
+ converter defer discard distinct do elif else end enum except export
15
+ func finally for from generic if import include interface iterator let
16
+ macro method mixin nil object of out proc ptr raise ref return static
17
+ template try tuple type using var when while with without yield
18
+ )
19
+
20
+ OPWORDS = %w(
21
+ and or not xor shl shr div mod in notin is isnot
22
+ )
23
+
24
+ PSEUDOKEYWORDS = %w(
25
+ nil true false
26
+ )
27
+
28
+ TYPES = %w(
29
+ int int8 int16 int32 int64 float float32 float64 bool char range array
30
+ seq set string
31
+ )
32
+
33
+ NAMESPACE = %w(
34
+ from import include
35
+ )
36
+
37
+ def self.underscorize(words)
38
+ words.map do |w|
39
+ w.gsub(/./) { |x| "#{Regexp.escape(x)}_?" }
40
+ end.join('|')
41
+ end
42
+
43
+ state :chars do
44
+ rule(/\\([\\abcefnrtvl"\']|x[a-fA-F0-9]{2}|[0-9]{1,3})/, Str::Escape)
45
+ rule(/'/, Str::Char, :pop!)
46
+ rule(/./, Str::Char)
47
+ end
48
+
49
+ state :strings do
50
+ rule(/(?<!\$)\$(\d+|#|\w+)+/, Str::Interpol)
51
+ rule(/[^\\\'"\$\n]+/, Str)
52
+ rule(/[\'"\\]/, Str)
53
+ rule(/\$/, Str)
54
+ end
55
+
56
+ state :dqs do
57
+ rule(/\\([\\abcefnrtvl"\']|\n|x[a-fA-F0-9]{2}|[0-9]{1,3})/,
58
+ Str::Escape)
59
+ rule(/"/, Str, :pop!)
60
+ mixin :strings
61
+ end
62
+
63
+ state :rdqs do
64
+ rule(/"(?!")/, Str, :pop!)
65
+ rule(/"/, Str::Escape, :pop!)
66
+ mixin :strings
67
+ end
68
+
69
+ state :tdqs do
70
+ rule(/"""(?!")/, Str, :pop!)
71
+ mixin :strings
72
+ mixin :nl
73
+ end
74
+
75
+ state :funcname do
76
+ rule(/((?![\d_])\w)(((?!_)\w)|(_(?!_)\w))*/, Name::Function, :pop!)
77
+ rule(/`.+`/, Name::Function, :pop!)
78
+ end
79
+
80
+ state :nl do
81
+ rule(/\n/, Str)
82
+ end
83
+
84
+ state :floatnumber do
85
+ rule(/\.(?!\.)[0-9_]*/, Num::Float)
86
+ rule(/[eE][+-]?[0-9][0-9_]*/, Num::Float)
87
+ rule(//, Text, :pop!)
88
+ end
89
+
90
+ # Making apostrophes optional, as only hexadecimal with type suffix
91
+ # possibly ambiguous.
92
+ state :floatsuffix do
93
+ rule(/'?[fF](32|64)/, Num::Float)
94
+ rule(//, Text, :pop!)
95
+ end
96
+
97
+ state :intsuffix do
98
+ rule(/'?[iI](32|64)/, Num::Integer::Long)
99
+ rule(/'?[iI](8|16)/, Num::Integer)
100
+ rule(/'?[uU]/, Num::Integer)
101
+ rule(//, Text, :pop!)
102
+ end
103
+
104
+ state :root do
105
+ rule(/##.*$/, Str::Doc)
106
+ rule(/#.*$/, Comment)
107
+ rule(/\*|=|>|<|\+|-|\/|@|\$|~|&|%|\!|\?|\||\\|\[|\]/, Operator)
108
+ rule(/\.\.|\.|,|\[\.|\.\]|{\.|\.}|\(\.|\.\)|{|}|\(|\)|:|\^|`|;/,
109
+ Punctuation)
110
+
111
+ # Strings
112
+ rule(/(?:[\w]+)"/, Str, :rdqs)
113
+ rule(/"""/, Str, :tdqs)
114
+ rule(/"/, Str, :dqs)
115
+
116
+ # Char
117
+ rule(/'/, Str::Char, :chars)
118
+
119
+ # Keywords
120
+ rule(%r{(#{Nim.underscorize(OPWORDS)})\b}, Operator::Word)
121
+ rule(/(p_?r_?o_?c_?\s)(?![\(\[\]])/, Keyword, :funcname)
122
+ rule(%r{(#{Nim.underscorize(KEYWORDS)})\b}, Keyword)
123
+ rule(%r{(#{Nim.underscorize(NAMESPACE)})\b}, Keyword::Namespace)
124
+ rule(/(v_?a_?r)\b/, Keyword::Declaration)
125
+ rule(%r{(#{Nim.underscorize(TYPES)})\b}, Keyword::Type)
126
+ rule(%r{(#{Nim.underscorize(PSEUDOKEYWORDS)})\b}, Keyword::Pseudo)
127
+ # Identifiers
128
+ rule(/\b((?![_\d])\w)(((?!_)\w)|(_(?!_)\w))*/, Name)
129
+
130
+ # Numbers
131
+ # Note: Have to do this with a block to push multiple states first,
132
+ # since we can't pass array of states like w/ Pygments.
133
+ rule(/[0-9][0-9_]*(?=([eE.]|'?[fF](32|64)))/) do |_number|
134
+ push :floatsuffix
135
+ push :floatnumber
136
+ token Num::Float
137
+ end
138
+ rule(/0[xX][a-fA-F0-9][a-fA-F0-9_]*/, Num::Hex, :intsuffix)
139
+ rule(/0[bB][01][01_]*/, Num, :intsuffix)
140
+ rule(/0o[0-7][0-7_]*/, Num::Oct, :intsuffix)
141
+ rule(/[0-9][0-9_]*/, Num::Integer, :intsuffix)
142
+
143
+ # Whitespace
144
+ rule(/\s+/, Text)
145
+ rule(/.+$/, Error)
146
+ end
147
+ end
148
+ end
149
+ end