CodeMirror

@@ -41,6 +42,16 @@
Underscores_are_allowed_between_words.
+## Strikethrough text
+
+GFM adds syntax to strikethrough text, which is missing from standard Markdown.
+
+~~Mistaken text.~~
+~~**works with other fomatting**~~
+
+~~spans across
+lines~~
+
## Fenced code blocks (and syntax highlighting)
```javascript
diff --git a/mode/gfm/test.js b/mode/gfm/test.js
index b9af5e894c..c2bc38fd57 100644
--- a/mode/gfm/test.js
+++ b/mode/gfm/test.js
@@ -22,6 +22,12 @@
"[variable-2&formatting&formatting-list&formatting-list-ul - ][meta&formatting&formatting-task [ ]]][variable-2 foo]",
"[variable-2&formatting&formatting-list&formatting-list-ul - ][property&formatting&formatting-task [x]]][variable-2 foo]");
+ FT("formatting_strikethrough",
+ "[strikethrough&formatting&formatting-strikethrough ~~][strikethrough foo][strikethrough&formatting&formatting-strikethrough ~~]");
+
+ FT("formatting_strikethrough",
+ "foo [strikethrough&formatting&formatting-strikethrough ~~][strikethrough bar][strikethrough&formatting&formatting-strikethrough ~~]");
+
MT("emInWordAsterisk",
"foo[em *bar*]hello");
@@ -161,4 +167,47 @@
"Commit: [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2]",
"Issue: [link #1]",
"Link: [link http://www.example.com/]");
+
+ MT("strikethrough",
+ "[strikethrough ~~foo~~]");
+
+ MT("strikethroughWithStartingSpace",
+ "~~ foo~~");
+
+ MT("strikethroughUnclosedStrayTildes",
+ "[strikethrough ~~foo~~~]");
+
+ MT("strikethroughUnclosedStrayTildes",
+ "[strikethrough ~~foo ~~]");
+
+ MT("strikethroughUnclosedStrayTildes",
+ "[strikethrough ~~foo ~~ bar]");
+
+ MT("strikethroughUnclosedStrayTildes",
+ "[strikethrough ~~foo ~~ bar~~]hello");
+
+ MT("strikethroughOneLetter",
+ "[strikethrough ~~a~~]");
+
+ MT("strikethroughWrapped",
+ "[strikethrough ~~foo]",
+ "[strikethrough foo~~]");
+
+ MT("strikethroughParagraph",
+ "[strikethrough ~~foo]",
+ "",
+ "foo[strikethrough ~~bar]");
+
+ MT("strikethroughEm",
+ "[strikethrough ~~foo][em&strikethrough *bar*][strikethrough ~~]");
+
+ MT("strikethroughEm",
+ "[em *][em&strikethrough ~~foo~~][em *]");
+
+ MT("strikethroughStrong",
+ "[strikethrough ~~][strong&strikethrough **foo**][strikethrough ~~]");
+
+ MT("strikethroughStrong",
+ "[strong **][strong&strikethrough ~~foo~~][strong **]");
+
})();
diff --git a/mode/htmlmixed/htmlmixed.js b/mode/htmlmixed/htmlmixed.js
index 250ef8cd24..1cc438f013 100644
--- a/mode/htmlmixed/htmlmixed.js
+++ b/mode/htmlmixed/htmlmixed.js
@@ -69,7 +69,7 @@ CodeMirror.defineMode("htmlmixed", function(config, parserConfig) {
if (stream.match(/^<\/\s*script\s*>/i, false)) {
state.token = html;
state.localState = state.localMode = null;
- return html(stream, state);
+ return null;
}
return maybeBackup(stream, /<\/\s*script\s*>/,
state.localMode.token(stream, state.localState));
@@ -78,7 +78,7 @@ CodeMirror.defineMode("htmlmixed", function(config, parserConfig) {
if (stream.match(/^<\/\s*style\s*>/i, false)) {
state.token = html;
state.localState = state.localMode = null;
- return html(stream, state);
+ return null;
}
return maybeBackup(stream, /<\/\s*style\s*>/,
cssMode.token(stream, state.localState));
diff --git a/mode/idl/idl.js b/mode/idl/idl.js
new file mode 100644
index 0000000000..15c852e36c
--- /dev/null
+++ b/mode/idl/idl.js
@@ -0,0 +1,290 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ function wordRegexp(words) {
+ return new RegExp('^((' + words.join(')|(') + '))\\b', 'i');
+ };
+
+ var builtinArray = [
+ 'a_correlate', 'abs', 'acos', 'adapt_hist_equal', 'alog',
+ 'alog2', 'alog10', 'amoeba', 'annotate', 'app_user_dir',
+ 'app_user_dir_query', 'arg_present', 'array_equal', 'array_indices',
+ 'arrow', 'ascii_template', 'asin', 'assoc', 'atan',
+ 'axis', 'axis', 'bandpass_filter', 'bandreject_filter', 'barplot',
+ 'bar_plot', 'beseli', 'beselj', 'beselk', 'besely',
+ 'beta', 'biginteger', 'bilinear', 'bin_date', 'binary_template',
+ 'bindgen', 'binomial', 'bit_ffs', 'bit_population', 'blas_axpy',
+ 'blk_con', 'boolarr', 'boolean', 'boxplot', 'box_cursor',
+ 'breakpoint', 'broyden', 'bubbleplot', 'butterworth', 'bytarr',
+ 'byte', 'byteorder', 'bytscl', 'c_correlate', 'calendar',
+ 'caldat', 'call_external', 'call_function', 'call_method',
+ 'call_procedure', 'canny', 'catch', 'cd', 'cdf', 'ceil',
+ 'chebyshev', 'check_math', 'chisqr_cvf', 'chisqr_pdf', 'choldc',
+ 'cholsol', 'cindgen', 'cir_3pnt', 'clipboard', 'close',
+ 'clust_wts', 'cluster', 'cluster_tree', 'cmyk_convert', 'code_coverage',
+ 'color_convert', 'color_exchange', 'color_quan', 'color_range_map',
+ 'colorbar', 'colorize_sample', 'colormap_applicable',
+ 'colormap_gradient', 'colormap_rotation', 'colortable',
+ 'comfit', 'command_line_args', 'common', 'compile_opt', 'complex',
+ 'complexarr', 'complexround', 'compute_mesh_normals', 'cond', 'congrid',
+ 'conj', 'constrained_min', 'contour', 'contour', 'convert_coord',
+ 'convol', 'convol_fft', 'coord2to3', 'copy_lun', 'correlate',
+ 'cos', 'cosh', 'cpu', 'cramer', 'createboxplotdata',
+ 'create_cursor', 'create_struct', 'create_view', 'crossp', 'crvlength',
+ 'ct_luminance', 'cti_test', 'cursor', 'curvefit', 'cv_coord',
+ 'cvttobm', 'cw_animate', 'cw_animate_getp', 'cw_animate_load',
+ 'cw_animate_run', 'cw_arcball', 'cw_bgroup', 'cw_clr_index',
+ 'cw_colorsel', 'cw_defroi', 'cw_field', 'cw_filesel', 'cw_form',
+ 'cw_fslider', 'cw_light_editor', 'cw_light_editor_get',
+ 'cw_light_editor_set', 'cw_orient', 'cw_palette_editor',
+ 'cw_palette_editor_get', 'cw_palette_editor_set', 'cw_pdmenu',
+ 'cw_rgbslider', 'cw_tmpl', 'cw_zoom', 'db_exists',
+ 'dblarr', 'dcindgen', 'dcomplex', 'dcomplexarr', 'define_key',
+ 'define_msgblk', 'define_msgblk_from_file', 'defroi', 'defsysv',
+ 'delvar', 'dendro_plot', 'dendrogram', 'deriv', 'derivsig',
+ 'determ', 'device', 'dfpmin', 'diag_matrix', 'dialog_dbconnect',
+ 'dialog_message', 'dialog_pickfile', 'dialog_printersetup',
+ 'dialog_printjob', 'dialog_read_image',
+ 'dialog_write_image', 'dictionary', 'digital_filter', 'dilate', 'dindgen',
+ 'dissolve', 'dist', 'distance_measure', 'dlm_load', 'dlm_register',
+ 'doc_library', 'double', 'draw_roi', 'edge_dog', 'efont',
+ 'eigenql', 'eigenvec', 'ellipse', 'elmhes', 'emboss',
+ 'empty', 'enable_sysrtn', 'eof', 'eos', 'erase',
+ 'erf', 'erfc', 'erfcx', 'erode', 'errorplot',
+ 'errplot', 'estimator_filter', 'execute', 'exit', 'exp',
+ 'expand', 'expand_path', 'expint', 'extrac', 'extract_slice',
+ 'f_cvf', 'f_pdf', 'factorial', 'fft', 'file_basename',
+ 'file_chmod', 'file_copy', 'file_delete', 'file_dirname',
+ 'file_expand_path', 'file_gunzip', 'file_gzip', 'file_info',
+ 'file_lines', 'file_link', 'file_mkdir', 'file_move',
+ 'file_poll_input', 'file_readlink', 'file_same',
+ 'file_search', 'file_tar', 'file_test', 'file_untar', 'file_unzip',
+ 'file_which', 'file_zip', 'filepath', 'findgen', 'finite',
+ 'fix', 'flick', 'float', 'floor', 'flow3',
+ 'fltarr', 'flush', 'format_axis_values', 'forward_function', 'free_lun',
+ 'fstat', 'fulstr', 'funct', 'function', 'fv_test',
+ 'fx_root', 'fz_roots', 'gamma', 'gamma_ct', 'gauss_cvf',
+ 'gauss_pdf', 'gauss_smooth', 'gauss2dfit', 'gaussfit',
+ 'gaussian_function', 'gaussint', 'get_drive_list', 'get_dxf_objects',
+ 'get_kbrd', 'get_login_info',
+ 'get_lun', 'get_screen_size', 'getenv', 'getwindows', 'greg2jul',
+ 'grib', 'grid_input', 'grid_tps', 'grid3', 'griddata',
+ 'gs_iter', 'h_eq_ct', 'h_eq_int', 'hanning', 'hash',
+ 'hdf', 'hdf5', 'heap_free', 'heap_gc', 'heap_nosave',
+ 'heap_refcount', 'heap_save', 'help', 'hilbert', 'hist_2d',
+ 'hist_equal', 'histogram', 'hls', 'hough', 'hqr',
+ 'hsv', 'i18n_multibytetoutf8',
+ 'i18n_multibytetowidechar', 'i18n_utf8tomultibyte',
+ 'i18n_widechartomultibyte',
+ 'ibeta', 'icontour', 'iconvertcoord', 'idelete', 'identity',
+ 'idl_base64', 'idl_container', 'idl_validname',
+ 'idlexbr_assistant', 'idlitsys_createtool',
+ 'idlunit', 'iellipse', 'igamma', 'igetcurrent', 'igetdata',
+ 'igetid', 'igetproperty', 'iimage', 'image', 'image_cont',
+ 'image_statistics', 'image_threshold', 'imaginary', 'imap', 'indgen',
+ 'int_2d', 'int_3d', 'int_tabulated', 'intarr', 'interpol',
+ 'interpolate', 'interval_volume', 'invert', 'ioctl', 'iopen',
+ 'ir_filter', 'iplot', 'ipolygon', 'ipolyline', 'iputdata',
+ 'iregister', 'ireset', 'iresolve', 'irotate', 'isa',
+ 'isave', 'iscale', 'isetcurrent', 'isetproperty', 'ishft',
+ 'isocontour', 'isosurface', 'isurface', 'itext', 'itranslate',
+ 'ivector', 'ivolume', 'izoom', 'journal', 'json_parse',
+ 'json_serialize', 'jul2greg', 'julday', 'keyword_set', 'krig2d',
+ 'kurtosis', 'kw_test', 'l64indgen', 'la_choldc', 'la_cholmprove',
+ 'la_cholsol', 'la_determ', 'la_eigenproblem', 'la_eigenql', 'la_eigenvec',
+ 'la_elmhes', 'la_gm_linear_model', 'la_hqr', 'la_invert',
+ 'la_least_square_equality', 'la_least_squares', 'la_linear_equation',
+ 'la_ludc', 'la_lumprove', 'la_lusol',
+ 'la_svd', 'la_tridc', 'la_trimprove', 'la_triql', 'la_trired',
+ 'la_trisol', 'label_date', 'label_region', 'ladfit', 'laguerre',
+ 'lambda', 'lambdap', 'lambertw', 'laplacian', 'least_squares_filter',
+ 'leefilt', 'legend', 'legendre', 'linbcg', 'lindgen',
+ 'linfit', 'linkimage', 'list', 'll_arc_distance', 'lmfit',
+ 'lmgr', 'lngamma', 'lnp_test', 'loadct', 'locale_get',
+ 'logical_and', 'logical_or', 'logical_true', 'lon64arr', 'lonarr',
+ 'long', 'long64', 'lsode', 'lu_complex', 'ludc',
+ 'lumprove', 'lusol', 'm_correlate', 'machar', 'make_array',
+ 'make_dll', 'make_rt', 'map', 'mapcontinents', 'mapgrid',
+ 'map_2points', 'map_continents', 'map_grid', 'map_image', 'map_patch',
+ 'map_proj_forward', 'map_proj_image', 'map_proj_info',
+ 'map_proj_init', 'map_proj_inverse',
+ 'map_set', 'matrix_multiply', 'matrix_power', 'max', 'md_test',
+ 'mean', 'meanabsdev', 'mean_filter', 'median', 'memory',
+ 'mesh_clip', 'mesh_decimate', 'mesh_issolid',
+ 'mesh_merge', 'mesh_numtriangles',
+ 'mesh_obj', 'mesh_smooth', 'mesh_surfacearea',
+ 'mesh_validate', 'mesh_volume',
+ 'message', 'min', 'min_curve_surf', 'mk_html_help', 'modifyct',
+ 'moment', 'morph_close', 'morph_distance',
+ 'morph_gradient', 'morph_hitormiss',
+ 'morph_open', 'morph_thin', 'morph_tophat', 'multi', 'n_elements',
+ 'n_params', 'n_tags', 'ncdf', 'newton', 'noise_hurl',
+ 'noise_pick', 'noise_scatter', 'noise_slur', 'norm', 'obj_class',
+ 'obj_destroy', 'obj_hasmethod', 'obj_isa', 'obj_new', 'obj_valid',
+ 'objarr', 'on_error', 'on_ioerror', 'online_help', 'openr',
+ 'openu', 'openw', 'oplot', 'oploterr', 'orderedhash',
+ 'p_correlate', 'parse_url', 'particle_trace', 'path_cache', 'path_sep',
+ 'pcomp', 'plot', 'plot3d', 'plot', 'plot_3dbox',
+ 'plot_field', 'ploterr', 'plots', 'polar_contour', 'polar_surface',
+ 'polyfill', 'polyshade', 'pnt_line', 'point_lun', 'polarplot',
+ 'poly', 'poly_2d', 'poly_area', 'poly_fit', 'polyfillv',
+ 'polygon', 'polyline', 'polywarp', 'popd', 'powell',
+ 'pref_commit', 'pref_get', 'pref_set', 'prewitt', 'primes',
+ 'print', 'printf', 'printd', 'pro', 'product',
+ 'profile', 'profiler', 'profiles', 'project_vol', 'ps_show_fonts',
+ 'psafm', 'pseudo', 'ptr_free', 'ptr_new', 'ptr_valid',
+ 'ptrarr', 'pushd', 'qgrid3', 'qhull', 'qromb',
+ 'qromo', 'qsimp', 'query_*', 'query_ascii', 'query_bmp',
+ 'query_csv', 'query_dicom', 'query_gif', 'query_image', 'query_jpeg',
+ 'query_jpeg2000', 'query_mrsid', 'query_pict', 'query_png', 'query_ppm',
+ 'query_srf', 'query_tiff', 'query_video', 'query_wav', 'r_correlate',
+ 'r_test', 'radon', 'randomn', 'randomu', 'ranks',
+ 'rdpix', 'read', 'readf', 'read_ascii', 'read_binary',
+ 'read_bmp', 'read_csv', 'read_dicom', 'read_gif', 'read_image',
+ 'read_interfile', 'read_jpeg', 'read_jpeg2000', 'read_mrsid', 'read_pict',
+ 'read_png', 'read_ppm', 'read_spr', 'read_srf', 'read_sylk',
+ 'read_tiff', 'read_video', 'read_wav', 'read_wave', 'read_x11_bitmap',
+ 'read_xwd', 'reads', 'readu', 'real_part', 'rebin',
+ 'recall_commands', 'recon3', 'reduce_colors', 'reform', 'region_grow',
+ 'register_cursor', 'regress', 'replicate',
+ 'replicate_inplace', 'resolve_all',
+ 'resolve_routine', 'restore', 'retall', 'return', 'reverse',
+ 'rk4', 'roberts', 'rot', 'rotate', 'round',
+ 'routine_filepath', 'routine_info', 'rs_test', 's_test', 'save',
+ 'savgol', 'scale3', 'scale3d', 'scatterplot', 'scatterplot3d',
+ 'scope_level', 'scope_traceback', 'scope_varfetch',
+ 'scope_varname', 'search2d',
+ 'search3d', 'sem_create', 'sem_delete', 'sem_lock', 'sem_release',
+ 'set_plot', 'set_shading', 'setenv', 'sfit', 'shade_surf',
+ 'shade_surf_irr', 'shade_volume', 'shift', 'shift_diff', 'shmdebug',
+ 'shmmap', 'shmunmap', 'shmvar', 'show3', 'showfont',
+ 'signum', 'simplex', 'sin', 'sindgen', 'sinh',
+ 'size', 'skewness', 'skip_lun', 'slicer3', 'slide_image',
+ 'smooth', 'sobel', 'socket', 'sort', 'spawn',
+ 'sph_4pnt', 'sph_scat', 'spher_harm', 'spl_init', 'spl_interp',
+ 'spline', 'spline_p', 'sprsab', 'sprsax', 'sprsin',
+ 'sprstp', 'sqrt', 'standardize', 'stddev', 'stop',
+ 'strarr', 'strcmp', 'strcompress', 'streamline', 'streamline',
+ 'stregex', 'stretch', 'string', 'strjoin', 'strlen',
+ 'strlowcase', 'strmatch', 'strmessage', 'strmid', 'strpos',
+ 'strput', 'strsplit', 'strtrim', 'struct_assign', 'struct_hide',
+ 'strupcase', 'surface', 'surface', 'surfr', 'svdc',
+ 'svdfit', 'svsol', 'swap_endian', 'swap_endian_inplace', 'symbol',
+ 'systime', 't_cvf', 't_pdf', 't3d', 'tag_names',
+ 'tan', 'tanh', 'tek_color', 'temporary', 'terminal_size',
+ 'tetra_clip', 'tetra_surface', 'tetra_volume', 'text', 'thin',
+ 'thread', 'threed', 'tic', 'time_test2', 'timegen',
+ 'timer', 'timestamp', 'timestamptovalues', 'tm_test', 'toc',
+ 'total', 'trace', 'transpose', 'tri_surf', 'triangulate',
+ 'trigrid', 'triql', 'trired', 'trisol', 'truncate_lun',
+ 'ts_coef', 'ts_diff', 'ts_fcast', 'ts_smooth', 'tv',
+ 'tvcrs', 'tvlct', 'tvrd', 'tvscl', 'typename',
+ 'uindgen', 'uint', 'uintarr', 'ul64indgen', 'ulindgen',
+ 'ulon64arr', 'ulonarr', 'ulong', 'ulong64', 'uniq',
+ 'unsharp_mask', 'usersym', 'value_locate', 'variance', 'vector',
+ 'vector_field', 'vel', 'velovect', 'vert_t3d', 'voigt',
+ 'volume', 'voronoi', 'voxel_proj', 'wait', 'warp_tri',
+ 'watershed', 'wdelete', 'wf_draw', 'where', 'widget_base',
+ 'widget_button', 'widget_combobox', 'widget_control',
+ 'widget_displaycontextmenu', 'widget_draw',
+ 'widget_droplist', 'widget_event', 'widget_info',
+ 'widget_label', 'widget_list',
+ 'widget_propertysheet', 'widget_slider', 'widget_tab',
+ 'widget_table', 'widget_text',
+ 'widget_tree', 'widget_tree_move', 'widget_window',
+ 'wiener_filter', 'window',
+ 'window', 'write_bmp', 'write_csv', 'write_gif', 'write_image',
+ 'write_jpeg', 'write_jpeg2000', 'write_nrif', 'write_pict', 'write_png',
+ 'write_ppm', 'write_spr', 'write_srf', 'write_sylk', 'write_tiff',
+ 'write_video', 'write_wav', 'write_wave', 'writeu', 'wset',
+ 'wshow', 'wtn', 'wv_applet', 'wv_cwt', 'wv_cw_wavelet',
+ 'wv_denoise', 'wv_dwt', 'wv_fn_coiflet',
+ 'wv_fn_daubechies', 'wv_fn_gaussian',
+ 'wv_fn_haar', 'wv_fn_morlet', 'wv_fn_paul',
+ 'wv_fn_symlet', 'wv_import_data',
+ 'wv_import_wavelet', 'wv_plot3d_wps', 'wv_plot_multires',
+ 'wv_pwt', 'wv_tool_denoise',
+ 'xbm_edit', 'xdisplayfile', 'xdxf', 'xfont', 'xinteranimate',
+ 'xloadct', 'xmanager', 'xmng_tmpl', 'xmtool', 'xobjview',
+ 'xobjview_rotate', 'xobjview_write_image',
+ 'xpalette', 'xpcolor', 'xplot3d',
+ 'xregistered', 'xroi', 'xsq_test', 'xsurface', 'xvaredit',
+ 'xvolume', 'xvolume_rotate', 'xvolume_write_image',
+ 'xyouts', 'zlib_compress', 'zlib_uncompress', 'zoom', 'zoom_24'
+ ];
+ var builtins = wordRegexp(builtinArray);
+
+ var keywordArray = [
+ 'begin', 'end', 'endcase', 'endfor',
+ 'endwhile', 'endif', 'endrep', 'endforeach',
+ 'break', 'case', 'continue', 'for',
+ 'foreach', 'goto', 'if', 'then', 'else',
+ 'repeat', 'until', 'switch', 'while',
+ 'do', 'pro', 'function'
+ ];
+ var keywords = wordRegexp(keywordArray);
+
+ CodeMirror.registerHelper("hintWords", "idl", builtinArray.concat(keywordArray));
+
+ var identifiers = new RegExp('^[_a-z\xa1-\uffff][_a-z0-9\xa1-\uffff]*', 'i');
+
+ var singleOperators = /[+\-*&=<>\/@#~$]/;
+ var boolOperators = new RegExp('(and|or|eq|lt|le|gt|ge|ne|not)', 'i');
+
+ function tokenBase(stream) {
+ // whitespaces
+ if (stream.eatSpace()) return null;
+
+ // Handle one line Comments
+ if (stream.match(';')) {
+ stream.skipToEnd();
+ return 'comment';
+ }
+
+ // Handle Number Literals
+ if (stream.match(/^[0-9\.+-]/, false)) {
+ if (stream.match(/^[+-]?0x[0-9a-fA-F]+/))
+ return 'number';
+ if (stream.match(/^[+-]?\d*\.\d+([EeDd][+-]?\d+)?/))
+ return 'number';
+ if (stream.match(/^[+-]?\d+([EeDd][+-]?\d+)?/))
+ return 'number';
+ }
+
+ // Handle Strings
+ if (stream.match(/^"([^"]|(""))*"/)) { return 'string'; }
+ if (stream.match(/^'([^']|(''))*'/)) { return 'string'; }
+
+ // Handle words
+ if (stream.match(keywords)) { return 'keyword'; }
+ if (stream.match(builtins)) { return 'builtin'; }
+ if (stream.match(identifiers)) { return 'variable'; }
+
+ if (stream.match(singleOperators) || stream.match(boolOperators)) {
+ return 'operator'; }
+
+ // Handle non-detected items
+ stream.next();
+ return 'error';
+ };
+
+ CodeMirror.defineMode('idl', function() {
+ return {
+ token: function(stream) {
+ return tokenBase(stream);
+ }
+ };
+ });
+
+ CodeMirror.defineMIME('text/x-idl', 'idl');
+});
diff --git a/mode/idl/index.html b/mode/idl/index.html
new file mode 100644
index 0000000000..4c169e2d69
--- /dev/null
+++ b/mode/idl/index.html
@@ -0,0 +1,64 @@
+
+
+
CodeMirror: IDL mode
+
+
+
+
+
+
+
+
+
+
+IDL mode
+
+
+
+
+ MIME types defined: text/x-idl.
+
diff --git a/mode/index.html b/mode/index.html
index bb656d2a79..82bf03ae51 100644
--- a/mode/index.html
+++ b/mode/index.html
@@ -42,6 +42,7 @@
Cython
D
Django (templating language)
+
Dockerfile
diff
DTD
Dylan
@@ -60,6 +61,7 @@
HTML embedded scripts
HTML mixed-mode
HTTP
+
IDL
Java
Jade
JavaScript
@@ -74,6 +76,7 @@
Modelica
Nginx
NTriples
+
Objective C
OCaml
Octave (MATLAB)
Pascal
diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js
index 3eb7747e60..7c87984e2b 100644
--- a/mode/markdown/markdown.js
+++ b/mode/markdown/markdown.js
@@ -3,9 +3,9 @@
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
- mod(require("../../lib/codemirror", require("../xml/xml")));
+ mod(require("../../lib/codemirror", require("../xml/xml"), require("../meta")));
else if (typeof define == "function" && define.amd) // AMD
- define(["../../lib/codemirror", "../xml/xml"], mod);
+ define(["../../lib/codemirror", "../xml/xml", "../meta"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
@@ -15,45 +15,15 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
var htmlFound = CodeMirror.modes.hasOwnProperty("xml");
var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? {name: "xml", htmlMode: true} : "text/plain");
- var aliases = {
- html: "htmlmixed",
- js: "javascript",
- json: "application/json",
- c: "text/x-csrc",
- "c++": "text/x-c++src",
- java: "text/x-java",
- csharp: "text/x-csharp",
- "c#": "text/x-csharp",
- scala: "text/x-scala"
- };
-
- var getMode = (function () {
- var i, modes = {}, mimes = {}, mime;
- var list = [];
- for (var m in CodeMirror.modes)
- if (CodeMirror.modes.propertyIsEnumerable(m)) list.push(m);
- for (i = 0; i < list.length; i++) {
- modes[list[i]] = list[i];
+ function getMode(name) {
+ if (CodeMirror.findModeByName) {
+ var found = CodeMirror.findModeByName(name);
+ if (found) name = found.mime || found.mimes[0];
}
- var mimesList = [];
- for (var m in CodeMirror.mimeModes)
- if (CodeMirror.mimeModes.propertyIsEnumerable(m))
- mimesList.push({mime: m, mode: CodeMirror.mimeModes[m]});
- for (i = 0; i < mimesList.length; i++) {
- mime = mimesList[i].mime;
- mimes[mime] = mimesList[i].mime;
- }
-
- for (var a in aliases) {
- if (aliases[a] in modes || aliases[a] in mimes)
- modes[a] = aliases[a];
- }
-
- return function (lang) {
- return modes[lang] ? CodeMirror.getMode(cmCfg, modes[lang]) : null;
- };
- }());
+ var mode = CodeMirror.getMode(cmCfg, name);
+ return mode.name == "null" ? null : mode;
+ }
// Should characters that affect highlighting be highlighted separate?
// Does not include characters that will be output (such as `1.` and `-` for lists)
@@ -75,6 +45,10 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
// Turn on task lists? ("- [ ] " and "- [x] ")
if (modeCfg.taskLists === undefined) modeCfg.taskLists = false;
+ // Turn on strikethrough syntax
+ if (modeCfg.strikethrough === undefined)
+ modeCfg.strikethrough = false;
+
var codeDepth = 0;
var header = 'header'
@@ -91,7 +65,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
, linktext = 'link'
, linkhref = 'string'
, em = 'em'
- , strong = 'strong';
+ , strong = 'strong'
+ , strikethrough = 'strikethrough';
var hrRE = /^([*\-=_])(?:\s*\1){2,}\s*$/
, ulRE = /^[*\-+]\s+/
@@ -99,7 +74,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
, taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE
, atxHeaderRE = /^#+/
, setextHeaderRE = /^(?:\={1,}|-{1,})$/
- , textRE = /^[^#!\[\]*_\\<>` "'(]+/;
+ , textRE = /^[^#!\[\]*_\\<>` "'(~]+/;
function switchInline(stream, state, f) {
state.f = state.inline = f;
@@ -121,6 +96,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
state.em = false;
// Reset STRONG state
state.strong = false;
+ // Reset strikethrough state
+ state.strikethrough = false;
// Reset state.quote
state.quote = 0;
if (!htmlFound && state.f == htmlBlock) {
@@ -197,11 +174,11 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
state.f = state.inline;
if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType];
return getType(state);
- } else if (modeCfg.fencedCodeBlocks && stream.match(/^```([\w+#]*)/, true)) {
+ } else if (modeCfg.fencedCodeBlocks && stream.match(/^```[ \t]*([\w+#]*)/, true)) {
// try switching mode
state.localMode = getMode(RegExp.$1);
if (state.localMode) state.localState = state.localMode.startState();
- switchBlock(stream, state, local);
+ state.f = state.block = local;
if (modeCfg.highlightFormatting) state.formatting = "code-block";
state.code = true;
return getType(state);
@@ -222,15 +199,10 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
}
function local(stream, state) {
- if (stream.sol() && stream.match(/^```/, true)) {
+ if (stream.sol() && stream.match("```", false)) {
state.localMode = state.localState = null;
- state.f = inlineNormal;
- state.block = blockNormal;
- if (modeCfg.highlightFormatting) state.formatting = "code-block";
- state.code = true;
- var returnType = getType(state);
- state.code = false;
- return returnType;
+ state.f = state.block = leavingLocal;
+ return null;
} else if (state.localMode) {
return state.localMode.token(stream, state.localState);
} else {
@@ -239,6 +211,17 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
}
}
+ function leavingLocal(stream, state) {
+ stream.match("```");
+ state.block = blockNormal;
+ state.f = inlineNormal;
+ if (modeCfg.highlightFormatting) state.formatting = "code-block";
+ state.code = true;
+ var returnType = getType(state);
+ state.code = false;
+ return returnType;
+ }
+
// Inline
function getType(state) {
var styles = [];
@@ -283,6 +266,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
if (state.strong) { styles.push(strong); }
if (state.em) { styles.push(em); }
+ if (state.strikethrough) { styles.push(strikethrough); }
if (state.linkText) { styles.push(linktext); }
@@ -511,6 +495,29 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
}
}
+ if (modeCfg.strikethrough) {
+ if (ch === '~' && stream.eatWhile(ch)) {
+ if (state.strikethrough) {// Remove strikethrough
+ if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
+ var t = getType(state);
+ state.strikethrough = false;
+ return t;
+ } else if (stream.match(/^[^\s]/, false)) {// Add strikethrough
+ state.strikethrough = true;
+ if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
+ return getType(state);
+ }
+ } else if (ch === ' ') {
+ if (stream.match(/^~~/, true)) { // Probably surrounded by space
+ if (stream.peek() === ' ') { // Surrounded by spaces, ignore
+ return getType(state);
+ } else { // Not surrounded by spaces, back up pointer
+ stream.backUp(2);
+ }
+ }
+ }
+ }
+
if (ch === ' ') {
if (stream.match(/ +$/, false)) {
state.trailingSpace++;
@@ -659,7 +666,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
listDepth: 0,
quote: 0,
trailingSpace: 0,
- trailingSpaceNewLine: false
+ trailingSpaceNewLine: false,
+ strikethrough: false
};
},
@@ -683,6 +691,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
linkTitle: s.linkTitle,
em: s.em,
strong: s.strong,
+ strikethrough: s.strikethrough,
header: s.header,
taskList: s.taskList,
list: s.list,
@@ -733,9 +742,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
state.indentation = adjustedIndentation;
if (indentation > 0) return null;
}
- var result = state.f(stream, state);
- if (stream.start == stream.pos) return this.token(stream, state);
- else return result;
+ return state.f(stream, state);
},
innerMode: function(state) {
diff --git a/mode/meta.js b/mode/meta.js
index cee33e5422..945b9b565b 100644
--- a/mode/meta.js
+++ b/mode/meta.js
@@ -15,18 +15,20 @@
{name: "APL", mime: "text/apl", mode: "apl", ext: ["dyalog", "apl"]},
{name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk"},
{name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h"]},
- {name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "hpp", "h++"]},
+ {name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "hpp", "h++"], alias: ["cpp"]},
{name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]},
- {name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"]},
+ {name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp"]},
{name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj"]},
- {name: "CoffeeScript", mime: "text/x-coffeescript", mode: "coffeescript", ext: ["coffee"]},
- {name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"]},
+ {name: "CoffeeScript", mime: "text/x-coffeescript", mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]},
+ {name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]},
{name: "Cypher", mime: "application/x-cypher-query", mode: "cypher"},
{name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]},
{name: "CSS", mime: "text/css", mode: "css", ext: ["css"]},
{name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"]},
{name: "D", mime: "text/x-d", mode: "d", ext: ["d"]},
{name: "diff", mime: "text/x-diff", mode: "diff", ext: ["diff", "patch"]},
+ {name: "Django", mime: "text/x-django", mode: "django"},
+ {name: "Dockerfile", mime: "text/x-dockerfile", mode: "dockerfile"},
{name: "DTD", mime: "application/xml-dtd", mode: "dtd", ext: ["dtd"]},
{name: "Dylan", mime: "text/x-dylan", mode: "dylan", ext: ["dylan", "dyl", "intr"]},
{name: "ECL", mime: "text/x-ecl", mode: "ecl", ext: ["ecl"]},
@@ -34,7 +36,7 @@
{name: "Embedded Javascript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]},
{name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]},
{name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90"]},
- {name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"]},
+ {name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]},
{name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]},
{name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
{name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm"},
@@ -44,21 +46,22 @@
{name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]},
{name: "Haxe", mime: "text/x-haxe", mode: "haxe", ext: ["hx"]},
{name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"]},
- {name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"]},
- {name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm"]},
+ {name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"], alias: ["asp", "aspx"]},
+ {name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm"], alias: ["xhtml"]},
{name: "HTTP", mime: "message/http", mode: "http"},
+ {name: "IDL", mime: "text/x-idl", mode: "idl", ext: ["pro"]},
{name: "Jade", mime: "text/x-jade", mode: "jade", ext: ["jade"]},
{name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]},
- {name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"]},
+ {name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]},
{name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"],
- mode: "javascript", ext: ["js"]},
- {name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"]},
- {name: "JSON-LD", mime: "application/ld+json", mode: "javascript"},
+ mode: "javascript", ext: ["js"], alias: ["ecmascript", "js", "node"]},
+ {name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"]},
+ {name: "JSON-LD", mime: "application/ld+json", mode: "javascript", alias: ["jsonld"]},
{name: "Jinja2", mime: "null", mode: "jinja2"},
{name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]},
{name: "Kotlin", mime: "text/x-kotlin", mode: "kotlin", ext: ["kt"]},
{name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"]},
- {name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"]},
+ {name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"], alias: ["ls"]},
{name: "Lua", mime: "text/x-lua", mode: "lua", ext: ["lua"]},
{name: "Markdown (GitHub-flavour)", mime: "text/x-markdown", mode: "markdown", ext: ["markdown", "md", "mkd"]},
{name: "mIRC", mime: "text/mirc", mode: "mirc"},
@@ -68,6 +71,7 @@
{name: "MySQL", mime: "text/x-mysql", mode: "sql"},
{name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx"},
{name: "NTriples", mime: "text/n-triples", mode: "ntriples", ext: ["nt"]},
+ {name: "Objective C", mime: "text/x-objectivec", mode: "clike", ext: ["m", "mm"]},
{name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"]},
{name: "Octave", mime: "text/x-octave", mode: "octave", ext: ["m"]},
{name: "Pascal", mime: "text/x-pascal", mode: "pascal", ext: ["p", "pas"]},
@@ -77,30 +81,32 @@
{name: "Pig", mime: "text/x-pig", mode: "pig"},
{name: "Plain Text", mime: "text/plain", mode: "null", ext: ["txt", "text", "conf", "def", "list", "log"]},
{name: "PLSQL", mime: "text/x-plsql", mode: "sql"},
- {name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"]},
+ {name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"], alias: ["ini", "properties"]},
{name: "Python", mime: "text/x-python", mode: "python", ext: ["py", "pyw"]},
{name: "Puppet", mime: "text/x-puppet", mode: "puppet", ext: ["pp"]},
{name: "Q", mime: "text/x-q", mode: "q", ext: ["q"]},
- {name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r"]},
- {name: "reStructuredText", mime: "text/x-rst", mode: "rst", ext: ["rst"]},
- {name: "Ruby", mime: "text/x-ruby", mode: "ruby", ext: ["rb"]},
+ {name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r"], alias: ["rscript"]},
+ {name: "reStructuredText", mime: "text/x-rst", mode: "rst", ext: ["rst"], alias: ["rst"]},
+ {name: "RPM Changes", mime: "text/x-rpm-changes", mode: "rpm"},
+ {name: "RPM Spec", mime: "text/x-rpm-spec", mode: "rpm", ext: ["spec"]},
+ {name: "Ruby", mime: "text/x-ruby", mode: "ruby", ext: ["rb"], alias: ["jruby", "macruby", "rake", "rb", "rbx"]},
{name: "Rust", mime: "text/x-rustsrc", mode: "rust", ext: ["rs"]},
{name: "Sass", mime: "text/x-sass", mode: "sass", ext: ["sass"]},
{name: "Scala", mime: "text/x-scala", mode: "clike", ext: ["scala"]},
{name: "Scheme", mime: "text/x-scheme", mode: "scheme", ext: ["scm", "ss"]},
{name: "SCSS", mime: "text/x-scss", mode: "css", ext: ["scss"]},
- {name: "Shell", mime: "text/x-sh", mode: "shell", ext: ["sh", "ksh", "bash"]},
+ {name: "Shell", mime: "text/x-sh", mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"]},
{name: "Sieve", mime: "application/sieve", mode: "sieve"},
{name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim"},
{name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk", ext: ["st"]},
{name: "Smarty", mime: "text/x-smarty", mode: "smarty", ext: ["tpl"]},
{name: "SmartyMixed", mime: "text/x-smarty", mode: "smartymixed"},
{name: "Solr", mime: "text/x-solr", mode: "solr"},
- {name: "SPARQL", mime: "application/x-sparql-query", mode: "sparql", ext: ["sparql"]},
+ {name: "SPARQL", mime: "application/sparql-query", mode: "sparql", ext: ["rq", "sparql"], alias: ["sparul"]},
{name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]},
{name: "MariaDB", mime: "text/x-mariadb", mode: "sql"},
{name: "sTeX", mime: "text/x-stex", mode: "stex"},
- {name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx"]},
+ {name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx"], alias: ["tex"]},
{name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v"]},
{name: "Tcl", mime: "text/x-tcl", mode: "tcl", ext: ["tcl"]},
{name: "Textile", mime: "text/x-textile", mode: "textile"},
@@ -109,14 +115,14 @@
{name: "TOML", mime: "text/x-toml", mode: "toml"},
{name: "Tornado", mime: "text/x-tornado", mode: "tornado"},
{name: "Turtle", mime: "text/turtle", mode: "turtle", ext: ["ttl"]},
- {name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"]},
+ {name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"], alias: ["ts"]},
{name: "VB.NET", mime: "text/x-vb", mode: "vb", ext: ["vb"]},
{name: "VBScript", mime: "text/vbscript", mode: "vbscript"},
{name: "Velocity", mime: "text/velocity", mode: "velocity", ext: ["vtl"]},
{name: "Verilog", mime: "text/x-verilog", mode: "verilog", ext: ["v"]},
- {name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd"]},
+ {name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd"], alias: ["rss", "wsdl", "xsd"]},
{name: "XQuery", mime: "application/xquery", mode: "xquery", ext: ["xy", "xquery"]},
- {name: "YAML", mime: "text/x-yaml", mode: "yaml", ext: ["yaml"]},
+ {name: "YAML", mime: "text/x-yaml", mode: "yaml", ext: ["yaml"], alias: ["yml"]},
{name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]}
];
// Ensure all modes have a mime property for backwards compatibility
@@ -141,4 +147,14 @@
if (info.ext[j] == ext) return info;
}
};
+
+ CodeMirror.findModeByName = function(name) {
+ name = name.toLowerCase();
+ for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
+ var info = CodeMirror.modeInfo[i];
+ if (info.name.toLowerCase() == name) return info;
+ if (info.alias) for (var j = 0; j < info.alias.length; j++)
+ if (info.alias[j].toLowerCase() == name) return info;
+ }
+ };
});
diff --git a/mode/ruby/index.html b/mode/ruby/index.html
index 1197ab023f..97544babc3 100644
--- a/mode/ruby/index.html
+++ b/mode/ruby/index.html
@@ -178,7 +178,6 @@
MIME types defined: text/x-ruby.
Development of the CodeMirror Ruby mode was kindly sponsored
- by Ubalo, who hold
- the license.
+ by
Ubalo.
diff --git a/mode/sparql/index.html b/mode/sparql/index.html
index 6f24206b1e..84ef4d3639 100644
--- a/mode/sparql/index.html
+++ b/mode/sparql/index.html
@@ -29,25 +29,33 @@
PREFIX a: <http://www.w3.org/2000/10/annotation-ns#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
+PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
# Comment!
SELECT ?given ?family
WHERE {
- ?annot a:annotates <http://www.w3.org/TR/rdf-sparql-query/> .
- ?annot dc:creator ?c .
- OPTIONAL {?c foaf:given ?given ;
- foaf:family ?family } .
+ {
+ ?annot a:annotates <http://www.w3.org/TR/rdf-sparql-query/> .
+ ?annot dc:creator ?c .
+ OPTIONAL {?c foaf:givenName ?given ;
+ foaf:familyName ?family }
+ } UNION {
+ ?c !foaf:knows/foaf:knows? ?thing.
+ ?thing rdfs
+ } MINUS {
+ ?thing rdfs:label "剛柔流"@jp
+ }
FILTER isBlank(?c)
}
-
MIME types defined: application/x-sparql-query.
+
MIME types defined: application/sparql-query.
diff --git a/mode/sparql/sparql.js b/mode/sparql/sparql.js
index 64dbb612c2..bbf8a76a0d 100644
--- a/mode/sparql/sparql.js
+++ b/mode/sparql/sparql.js
@@ -19,18 +19,28 @@ CodeMirror.defineMode("sparql", function(config) {
return new RegExp("^(?:" + words.join("|") + ")$", "i");
}
var ops = wordRegexp(["str", "lang", "langmatches", "datatype", "bound", "sameterm", "isiri", "isuri",
+ "iri", "uri", "bnode", "count", "sum", "min", "max", "avg", "sample",
+ "group_concat", "rand", "abs", "ceil", "floor", "round", "concat", "substr", "strlen",
+ "replace", "ucase", "lcase", "encode_for_uri", "contains", "strstarts", "strends",
+ "strbefore", "strafter", "year", "month", "day", "hours", "minutes", "seconds",
+ "timezone", "tz", "now", "uuid", "struuid", "md5", "sha1", "sha256", "sha384",
+ "sha512", "coalesce", "if", "strlang", "strdt", "isnumeric", "regex", "exists",
"isblank", "isliteral", "a"]);
var keywords = wordRegexp(["base", "prefix", "select", "distinct", "reduced", "construct", "describe",
"ask", "from", "named", "where", "order", "limit", "offset", "filter", "optional",
"graph", "by", "asc", "desc", "as", "having", "undef", "values", "group",
"minus", "in", "not", "service", "silent", "using", "insert", "delete", "union",
+ "true", "false", "with",
"data", "copy", "to", "move", "add", "create", "drop", "clear", "load"]);
- var operatorChars = /[*+\-<>=&|]/;
+ var operatorChars = /[*+\-<>=&|\^\/!\?]/;
function tokenBase(stream, state) {
var ch = stream.next();
curPunc = null;
if (ch == "$" || ch == "?") {
+ if(ch == "?" && stream.match(/\s/, false)){
+ return "operator";
+ }
stream.match(/^[\w\d]*/);
return "variable-2";
}
@@ -44,7 +54,7 @@ CodeMirror.defineMode("sparql", function(config) {
}
else if (/[{}\(\),\.;\[\]]/.test(ch)) {
curPunc = ch;
- return null;
+ return "bracket";
}
else if (ch == "#") {
stream.skipToEnd();
@@ -52,12 +62,16 @@ CodeMirror.defineMode("sparql", function(config) {
}
else if (operatorChars.test(ch)) {
stream.eatWhile(operatorChars);
- return null;
+ return "operator";
}
else if (ch == ":") {
stream.eatWhile(/[\w\d\._\-]/);
return "atom";
}
+ else if (ch == "@") {
+ stream.eatWhile(/[a-z\d\-]/i);
+ return "meta";
+ }
else {
stream.eatWhile(/[_\w\d]/);
if (stream.eat(":")) {
@@ -66,7 +80,7 @@ CodeMirror.defineMode("sparql", function(config) {
}
var word = stream.current();
if (ops.test(word))
- return null;
+ return "builtin";
else if (keywords.test(word))
return "keyword";
else
@@ -155,6 +169,6 @@ CodeMirror.defineMode("sparql", function(config) {
};
});
-CodeMirror.defineMIME("application/x-sparql-query", "sparql");
+CodeMirror.defineMIME("application/sparql-query", "sparql");
});
diff --git a/mode/sql/sql.js b/mode/sql/sql.js
index 799492f51b..f2c2384a72 100644
--- a/mode/sql/sql.js
+++ b/mode/sql/sql.js
@@ -367,8 +367,6 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
keywords:
A list of keywords you want to be highlighted.
- functions:
- A list of function names you want to be highlighted.
builtin:
A list of builtin types you want to be highlighted (if you want types to be of class "builtin" instead of "keyword").
operatorChars:
diff --git a/mode/stex/stex.js b/mode/stex/stex.js
index 14f6fcc3cb..4be533c54e 100644
--- a/mode/stex/stex.js
+++ b/mode/stex/stex.js
@@ -14,60 +14,60 @@
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
-"use strict";
+ "use strict";
-CodeMirror.defineMode("stex", function() {
+ CodeMirror.defineMode("stex", function() {
"use strict";
function pushCommand(state, command) {
- state.cmdState.push(command);
+ state.cmdState.push(command);
}
function peekCommand(state) {
- if (state.cmdState.length > 0) {
- return state.cmdState[state.cmdState.length - 1];
- } else {
- return null;
- }
+ if (state.cmdState.length > 0) {
+ return state.cmdState[state.cmdState.length - 1];
+ } else {
+ return null;
+ }
}
function popCommand(state) {
- var plug = state.cmdState.pop();
- if (plug) {
- plug.closeBracket();
- }
+ var plug = state.cmdState.pop();
+ if (plug) {
+ plug.closeBracket();
+ }
}
// returns the non-default plugin closest to the end of the list
function getMostPowerful(state) {
- var context = state.cmdState;
- for (var i = context.length - 1; i >= 0; i--) {
- var plug = context[i];
- if (plug.name == "DEFAULT") {
- continue;
- }
- return plug;
- }
- return { styleIdentifier: function() { return null; } };
+ var context = state.cmdState;
+ for (var i = context.length - 1; i >= 0; i--) {
+ var plug = context[i];
+ if (plug.name == "DEFAULT") {
+ continue;
+ }
+ return plug;
+ }
+ return { styleIdentifier: function() { return null; } };
}
function addPluginPattern(pluginName, cmdStyle, styles) {
- return function () {
- this.name = pluginName;
- this.bracketNo = 0;
- this.style = cmdStyle;
- this.styles = styles;
- this.argument = null; // \begin and \end have arguments that follow. These are stored in the plugin
-
- this.styleIdentifier = function() {
- return this.styles[this.bracketNo - 1] || null;
- };
- this.openBracket = function() {
- this.bracketNo++;
- return "bracket";
- };
- this.closeBracket = function() {};
+ return function () {
+ this.name = pluginName;
+ this.bracketNo = 0;
+ this.style = cmdStyle;
+ this.styles = styles;
+ this.argument = null; // \begin and \end have arguments that follow. These are stored in the plugin
+
+ this.styleIdentifier = function() {
+ return this.styles[this.bracketNo - 1] || null;
};
+ this.openBracket = function() {
+ this.bracketNo++;
+ return "bracket";
+ };
+ this.closeBracket = function() {};
+ };
}
var plugins = {};
@@ -79,184 +79,175 @@ CodeMirror.defineMode("stex", function() {
plugins["end"] = addPluginPattern("end", "tag", ["atom"]);
plugins["DEFAULT"] = function () {
- this.name = "DEFAULT";
- this.style = "tag";
+ this.name = "DEFAULT";
+ this.style = "tag";
- this.styleIdentifier = this.openBracket = this.closeBracket = function() {};
+ this.styleIdentifier = this.openBracket = this.closeBracket = function() {};
};
function setState(state, f) {
- state.f = f;
+ state.f = f;
}
// called when in a normal (no environment) context
function normal(source, state) {
- var plug;
- // Do we look like '\command' ? If so, attempt to apply the plugin 'command'
- if (source.match(/^\\[a-zA-Z@]+/)) {
- var cmdName = source.current().slice(1);
- plug = plugins[cmdName] || plugins["DEFAULT"];
- plug = new plug();
- pushCommand(state, plug);
- setState(state, beginParams);
- return plug.style;
- }
-
- // escape characters
- if (source.match(/^\\[$&%#{}_]/)) {
- return "tag";
- }
-
- // white space control characters
- if (source.match(/^\\[,;!\/\\]/)) {
- return "tag";
- }
-
- // find if we're starting various math modes
- if (source.match("\\[")) {
- setState(state, function(source, state){ return inMathMode(source, state, "\\]"); });
- return "keyword";
- }
- if (source.match("$$")) {
- setState(state, function(source, state){ return inMathMode(source, state, "$$"); });
- return "keyword";
- }
- if (source.match("$")) {
- setState(state, function(source, state){ return inMathMode(source, state, "$"); });
- return "keyword";
- }
-
- var ch = source.next();
- if (ch == "%") {
- // special case: % at end of its own line; stay in same state
- if (!source.eol()) {
- setState(state, inCComment);
- }
- return "comment";
- }
- else if (ch == '}' || ch == ']') {
- plug = peekCommand(state);
- if (plug) {
- plug.closeBracket(ch);
- setState(state, beginParams);
- } else {
- return "error";
- }
- return "bracket";
- } else if (ch == '{' || ch == '[') {
- plug = plugins["DEFAULT"];
- plug = new plug();
- pushCommand(state, plug);
- return "bracket";
- }
- else if (/\d/.test(ch)) {
- source.eatWhile(/[\w.%]/);
- return "atom";
- }
- else {
- source.eatWhile(/[\w\-_]/);
- plug = getMostPowerful(state);
- if (plug.name == 'begin') {
- plug.argument = source.current();
- }
- return plug.styleIdentifier();
- }
- }
-
- function inCComment(source, state) {
+ var plug;
+ // Do we look like '\command' ? If so, attempt to apply the plugin 'command'
+ if (source.match(/^\\[a-zA-Z@]+/)) {
+ var cmdName = source.current().slice(1);
+ plug = plugins[cmdName] || plugins["DEFAULT"];
+ plug = new plug();
+ pushCommand(state, plug);
+ setState(state, beginParams);
+ return plug.style;
+ }
+
+ // escape characters
+ if (source.match(/^\\[$&%#{}_]/)) {
+ return "tag";
+ }
+
+ // white space control characters
+ if (source.match(/^\\[,;!\/\\]/)) {
+ return "tag";
+ }
+
+ // find if we're starting various math modes
+ if (source.match("\\[")) {
+ setState(state, function(source, state){ return inMathMode(source, state, "\\]"); });
+ return "keyword";
+ }
+ if (source.match("$$")) {
+ setState(state, function(source, state){ return inMathMode(source, state, "$$"); });
+ return "keyword";
+ }
+ if (source.match("$")) {
+ setState(state, function(source, state){ return inMathMode(source, state, "$"); });
+ return "keyword";
+ }
+
+ var ch = source.next();
+ if (ch == "%") {
source.skipToEnd();
- setState(state, normal);
return "comment";
+ }
+ else if (ch == '}' || ch == ']') {
+ plug = peekCommand(state);
+ if (plug) {
+ plug.closeBracket(ch);
+ setState(state, beginParams);
+ } else {
+ return "error";
+ }
+ return "bracket";
+ } else if (ch == '{' || ch == '[') {
+ plug = plugins["DEFAULT"];
+ plug = new plug();
+ pushCommand(state, plug);
+ return "bracket";
+ }
+ else if (/\d/.test(ch)) {
+ source.eatWhile(/[\w.%]/);
+ return "atom";
+ }
+ else {
+ source.eatWhile(/[\w\-_]/);
+ plug = getMostPowerful(state);
+ if (plug.name == 'begin') {
+ plug.argument = source.current();
+ }
+ return plug.styleIdentifier();
+ }
}
function inMathMode(source, state, endModeSeq) {
- if (source.eatSpace()) {
- return null;
- }
- if (source.match(endModeSeq)) {
- setState(state, normal);
- return "keyword";
- }
- if (source.match(/^\\[a-zA-Z@]+/)) {
- return "tag";
- }
- if (source.match(/^[a-zA-Z]+/)) {
- return "variable-2";
- }
- // escape characters
- if (source.match(/^\\[$&%#{}_]/)) {
- return "tag";
- }
- // white space control characters
- if (source.match(/^\\[,;!\/]/)) {
- return "tag";
- }
- // special math-mode characters
- if (source.match(/^[\^_&]/)) {
- return "tag";
- }
- // non-special characters
- if (source.match(/^[+\-<>|=,\/@!*:;'"`~#?]/)) {
- return null;
- }
- if (source.match(/^(\d+\.\d*|\d*\.\d+|\d+)/)) {
- return "number";
- }
- var ch = source.next();
- if (ch == "{" || ch == "}" || ch == "[" || ch == "]" || ch == "(" || ch == ")") {
- return "bracket";
- }
-
- // eat comments here, because inCComment returns us to normal state!
- if (ch == "%") {
- if (!source.eol()) {
- source.skipToEnd();
- }
- return "comment";
- }
- return "error";
+ if (source.eatSpace()) {
+ return null;
+ }
+ if (source.match(endModeSeq)) {
+ setState(state, normal);
+ return "keyword";
+ }
+ if (source.match(/^\\[a-zA-Z@]+/)) {
+ return "tag";
+ }
+ if (source.match(/^[a-zA-Z]+/)) {
+ return "variable-2";
+ }
+ // escape characters
+ if (source.match(/^\\[$&%#{}_]/)) {
+ return "tag";
+ }
+ // white space control characters
+ if (source.match(/^\\[,;!\/]/)) {
+ return "tag";
+ }
+ // special math-mode characters
+ if (source.match(/^[\^_&]/)) {
+ return "tag";
+ }
+ // non-special characters
+ if (source.match(/^[+\-<>|=,\/@!*:;'"`~#?]/)) {
+ return null;
+ }
+ if (source.match(/^(\d+\.\d*|\d*\.\d+|\d+)/)) {
+ return "number";
+ }
+ var ch = source.next();
+ if (ch == "{" || ch == "}" || ch == "[" || ch == "]" || ch == "(" || ch == ")") {
+ return "bracket";
+ }
+
+ if (ch == "%") {
+ source.skipToEnd();
+ return "comment";
+ }
+ return "error";
}
function beginParams(source, state) {
- var ch = source.peek(), lastPlug;
- if (ch == '{' || ch == '[') {
- lastPlug = peekCommand(state);
- lastPlug.openBracket(ch);
- source.eat(ch);
- setState(state, normal);
- return "bracket";
- }
- if (/[ \t\r]/.test(ch)) {
- source.eat(ch);
- return null;
- }
+ var ch = source.peek(), lastPlug;
+ if (ch == '{' || ch == '[') {
+ lastPlug = peekCommand(state);
+ lastPlug.openBracket(ch);
+ source.eat(ch);
setState(state, normal);
- popCommand(state);
-
- return normal(source, state);
+ return "bracket";
+ }
+ if (/[ \t\r]/.test(ch)) {
+ source.eat(ch);
+ return null;
+ }
+ setState(state, normal);
+ popCommand(state);
+
+ return normal(source, state);
}
return {
- startState: function() {
- return {
- cmdState: [],
- f: normal
- };
- },
- copyState: function(s) {
- return {
- cmdState: s.cmdState.slice(),
- f: s.f
- };
- },
- token: function(stream, state) {
- return state.f(stream, state);
- },
- lineComment: "%"
+ startState: function() {
+ return {
+ cmdState: [],
+ f: normal
+ };
+ },
+ copyState: function(s) {
+ return {
+ cmdState: s.cmdState.slice(),
+ f: s.f
+ };
+ },
+ token: function(stream, state) {
+ return state.f(stream, state);
+ },
+ blankLine: function(state) {
+ state.f = normal;
+ },
+ lineComment: "%"
};
-});
+ });
-CodeMirror.defineMIME("text/x-stex", "stex");
-CodeMirror.defineMIME("text/x-latex", "stex");
+ CodeMirror.defineMIME("text/x-stex", "stex");
+ CodeMirror.defineMIME("text/x-latex", "stex");
});
diff --git a/mode/yaml/yaml.js b/mode/yaml/yaml.js
index 332aef6a23..b7015e599c 100644
--- a/mode/yaml/yaml.js
+++ b/mode/yaml/yaml.js
@@ -23,8 +23,13 @@ CodeMirror.defineMode("yaml", function() {
state.escaped = false;
/* comments */
if (ch == "#" && (stream.pos == 0 || /\s/.test(stream.string.charAt(stream.pos - 1)))) {
- stream.skipToEnd(); return "comment";
+ stream.skipToEnd();
+ return "comment";
}
+
+ if (stream.match(/^('([^']|\\.)*'?|"([^"]|\\.)*"?)/))
+ return "string";
+
if (state.literal && stream.indentation() > state.keyCol) {
stream.skipToEnd(); return "string";
} else if (state.literal) { state.literal = false; }
diff --git a/package.json b/package.json
index e7d5bd962b..fe52bcfe8b 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "codemirror",
- "version":"4.7.0",
+ "version":"4.8.0",
"main": "lib/codemirror.js",
"description": "In-browser code editing made bearable",
"licenses": [{"type": "MIT",
diff --git a/test/lint/lint.js b/test/lint/lint.js
index c2c45262a6..b0248290cf 100644
--- a/test/lint/lint.js
+++ b/test/lint/lint.js
@@ -22,7 +22,7 @@ var topAllowedGlobals = Object.create(null);
"screen FileReader Worker postMessage importScripts " +
"setInterval clearInterval setTimeout clearTimeout " +
"CodeMirror " +
- "test exports require module define")
+ "test exports require module define requirejs")
.split(" ").forEach(function(n) { topAllowedGlobals[n] = true; });
var fs = require("fs"), acorn = require("./acorn.js"), walk = require("./walk.js");
diff --git a/test/test.js b/test/test.js
index 4e7de08818..3a19c8f5af 100644
--- a/test/test.js
+++ b/test/test.js
@@ -3,7 +3,7 @@ var Pos = CodeMirror.Pos;
CodeMirror.defaults.rtlMoveVisually = true;
function forEach(arr, f) {
- for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
+ for (var i = 0, e = arr.length; i < e; ++i) f(arr[i], i);
}
function addDoc(cm, width, height) {
@@ -1975,6 +1975,18 @@ testCM("alwaysMergeSelEventWithChangeOrigin", function(cm) {
eq(cm.getValue(), "Va");
}, {value: "a"});
+testCM("getTokenAt", function(cm) {
+ var tokPlus = cm.getTokenAt(Pos(0, 2));
+ eq(tokPlus.type, "operator");
+ eq(tokPlus.string, "+");
+ var toks = cm.getLineTokens(0);
+ eq(toks.length, 3);
+ forEach([["number", "1"], ["operator", "+"], ["number", "2"]], function(expect, i) {
+ eq(toks[i].type, expect[0]);
+ eq(toks[i].string, expect[1]);
+ });
+}, {value: "1+2", mode: "javascript"});
+
testCM("getTokenTypeAt", function(cm) {
eq(cm.getTokenTypeAt(Pos(0, 0)), "number");
eq(cm.getTokenTypeAt(Pos(0, 6)), "string");
@@ -2032,3 +2044,32 @@ testCM("eventOrder", function(cm) {
cm.replaceSelection("/");
eq(seen.join(","), "change,change,activity,change");
});
+
+test("core_rmClass", function() {
+ var node = document.createElement("div");
+ node.className = "foo-bar baz-quux yadda";
+ CodeMirror.rmClass(node, "quux");
+ eq(node.className, "foo-bar baz-quux yadda");
+ CodeMirror.rmClass(node, "baz-quux");
+ eq(node.className, "foo-bar yadda");
+ CodeMirror.rmClass(node, "yadda");
+ eq(node.className, "foo-bar");
+ CodeMirror.rmClass(node, "foo-bar");
+ eq(node.className, "");
+ node.className = " foo ";
+ CodeMirror.rmClass(node, "foo");
+ eq(node.className, "");
+});
+
+test("core_addClass", function() {
+ var node = document.createElement("div");
+ CodeMirror.addClass(node, "a");
+ eq(node.className, "a");
+ CodeMirror.addClass(node, "a");
+ eq(node.className, "a");
+ CodeMirror.addClass(node, "b");
+ eq(node.className, "a b");
+ CodeMirror.addClass(node, "a");
+ CodeMirror.addClass(node, "b");
+ eq(node.className, "a b");
+});
diff --git a/test/vim_test.js b/test/vim_test.js
index 401172b649..7eb8f6d8f7 100644
--- a/test/vim_test.js
+++ b/test/vim_test.js
@@ -143,9 +143,9 @@ function testVim(name, run, opts, expectedFail) {
for (var i = 0; i < arguments.length; i++) {
var key = arguments[i];
// Find key in keymap and handle.
- var handled = CodeMirror.lookupKey(key, ['vim-insert'], executeHandler);
+ var handled = CodeMirror.lookupKey(key, 'vim-insert', executeHandler);
// Record for insert mode.
- if (handled === true && cm.state.vim.insertMode && arguments[i] != 'Esc') {
+ if (handled == "handled" && cm.state.vim.insertMode && arguments[i] != 'Esc') {
var lastChange = CodeMirror.Vim.getVimGlobalState_().macroModeState.lastInsertModeChanges;
if (lastChange) {
lastChange.changes.push(new CodeMirror.Vim.InsertModeKey(key));
@@ -898,32 +898,36 @@ testVim('cc_multiply_repeat', function(cm, vim, helpers) {
is(register.linewise);
eq('vim-insert', cm.getOption('keyMap'));
});
-testVim('cc_append', function(cm, vim, helpers) {
+testVim('cc_should_not_append_to_document', function(cm, vim, helpers) {
var expectedLineCount = cm.lineCount();
cm.setCursor(cm.lastLine(), 0);
helpers.doKeys('c', 'c');
eq(expectedLineCount, cm.lineCount());
});
+function fillArray(val, times) {
+ var arr = [];
+ for (var i = 0; i < times; i++) {
+ arr.push(val);
+ }
+ return arr;
+}
testVim('c_visual_block', function(cm, vim, helpers) {
cm.setCursor(0, 1);
helpers.doKeys('
', '2', 'j', 'l', 'l', 'l', 'c');
- var replacement = new Array(cm.listSelections().length+1).join('hello ').split(' ');
- replacement.pop();
+ var replacement = fillArray('hello', 3);
cm.replaceSelections(replacement);
eq('1hello\n5hello\nahellofg', cm.getValue());
helpers.doKeys('');
cm.setCursor(2, 3);
helpers.doKeys('', '2', 'k', 'h', 'C');
- replacement = new Array(cm.listSelections().length+1).join('world ').split(' ');
- replacement.pop();
+ replacement = fillArray('world', 3);
cm.replaceSelections(replacement);
eq('1hworld\n5hworld\nahworld', cm.getValue());
}, {value: '1234\n5678\nabcdefg'});
testVim('c_visual_block_replay', function(cm, vim, helpers) {
cm.setCursor(0, 1);
helpers.doKeys('', '2', 'j', 'l', 'c');
- var replacement = new Array(cm.listSelections().length+1).join('fo ').split(' ');
- replacement.pop();
+ var replacement = fillArray('fo', 3);
cm.replaceSelections(replacement);
eq('1fo4\n5fo8\nafodefg', cm.getValue());
helpers.doKeys('');
@@ -932,6 +936,17 @@ testVim('c_visual_block_replay', function(cm, vim, helpers) {
eq('foo4\nfoo8\nfoodefg', cm.getValue());
}, {value: '1234\n5678\nabcdefg'});
+testVim('d_visual_block', function(cm, vim, helpers) {
+ cm.setCursor(0, 1);
+ helpers.doKeys('', '2', 'j', 'l', 'l', 'l', 'd');
+ eq('1\n5\nafg', cm.getValue());
+}, {value: '1234\n5678\nabcdefg'});
+testVim('D_visual_block', function(cm, vim, helpers) {
+ cm.setCursor(0, 1);
+ helpers.doKeys('', '2', 'j', 'l', 'D');
+ eq('1\n5\na', cm.getValue());
+}, {value: '1234\n5678\nabcdefg'});
+
// Swapcase commands edit in place and do not modify registers.
testVim('g~w_repeat', function(cm, vim, helpers) {
// Assert that dw does delete newline if it should go to the next line, and
@@ -955,8 +970,34 @@ testVim('g~g~', function(cm, vim, helpers) {
var register = helpers.getRegisterController().getRegister();
eq('', register.toString());
is(!register.linewise);
- eqPos({line: curStart.line, ch:0}, cm.getCursor());
+ eqPos(curStart, cm.getCursor());
}, { value: ' word1\nword2\nword3\nword4\nword5\nword6' });
+testVim('gu_and_gU', function(cm, vim, helpers) {
+ var curStart = makeCursor(0, 7);
+ var value = cm.getValue();
+ cm.setCursor(curStart);
+ helpers.doKeys('2', 'g', 'U', 'w');
+ eq(cm.getValue(), 'wa wb xX WC wd');
+ eqPos(curStart, cm.getCursor());
+ helpers.doKeys('2', 'g', 'u', 'w');
+ eq(cm.getValue(), value);
+
+ helpers.doKeys('2', 'g', 'U', 'B');
+ eq(cm.getValue(), 'wa WB Xx wc wd');
+ eqPos(makeCursor(0, 3), cm.getCursor());
+
+ cm.setCursor(makeCursor(0, 4));
+ helpers.doKeys('g', 'u', 'i', 'w');
+ eq(cm.getValue(), 'wa wb Xx wc wd');
+ eqPos(makeCursor(0, 3), cm.getCursor());
+
+ // TODO: support gUgU guu
+ // eqPos(makeCursor(0, 0), cm.getCursor());
+
+ var register = helpers.getRegisterController().getRegister();
+ eq('', register.toString());
+ is(!register.linewise);
+}, { value: 'wa wb xx wc wd' });
testVim('visual_block_~', function(cm, vim, helpers) {
cm.setCursor(1, 1);
helpers.doKeys('', 'l', 'l', 'j', '~');
@@ -1237,7 +1278,7 @@ testVim('a_eol', function(cm, vim, helpers) {
helpers.assertCursorAt(0, lines[0].length);
eq('vim-insert', cm.getOption('keyMap'));
});
-testVim('a_endOfSelectedArea', function(cm, vim, helpers) {
+testVim('A_endOfSelectedArea', function(cm, vim, helpers) {
cm.setCursor(0, 0);
helpers.doKeys('v', 'j', 'l');
helpers.doKeys('A');
@@ -1278,6 +1319,11 @@ testVim('A_visual_block', function(cm, vim, helpers) {
replacement.pop();
cm.replaceSelections(replacement);
eq('testhello\nmehello\npleahellose', cm.getValue());
+ helpers.doKeys('');
+ cm.setCursor(0, 0);
+ helpers.doKeys('.');
+ // TODO this doesn't work yet
+ // eq('teshellothello\nme hello hello\nplehelloahellose', cm.getValue());
}, {value: 'test\nme\nplease'});
testVim('I', function(cm, vim, helpers) {
cm.setCursor(0, 4);
@@ -1695,29 +1741,75 @@ testVim('visual', function(cm, vim, helpers) {
helpers.doKeys('d');
eq('15', cm.getValue());
}, { value: '12345' });
+testVim('visual_yank', function(cm, vim, helpers) {
+ helpers.doKeys('v', '3', 'l', 'y');
+ helpers.assertCursorAt(0, 0);
+ helpers.doKeys('p');
+ eq('aa te test for yank', cm.getValue());
+}, { value: 'a test for yank' })
+testVim('visual_w', function(cm, vim, helpers) {
+ helpers.doKeys('v', 'w');
+ eq(cm.getSelection(), 'motion t');
+}, { value: 'motion test'});
+testVim('visual_initial_selection', function(cm, vim, helpers) {
+ cm.setCursor(0, 1);
+ helpers.doKeys('v');
+ cm.getSelection('n');
+}, { value: 'init'});
+testVim('visual_crossover_left', function(cm, vim, helpers) {
+ cm.setCursor(0, 2);
+ helpers.doKeys('v', 'l', 'h', 'h');
+ cm.getSelection('ro');
+}, { value: 'cross'});
+testVim('visual_crossover_left', function(cm, vim, helpers) {
+ cm.setCursor(0, 2);
+ helpers.doKeys('v', 'h', 'l', 'l');
+ cm.getSelection('os');
+}, { value: 'cross'});
+testVim('visual_crossover_up', function(cm, vim, helpers) {
+ cm.setCursor(3, 2);
+ helpers.doKeys('v', 'j', 'k', 'k');
+ eqPos(Pos(2, 2), cm.getCursor('head'));
+ eqPos(Pos(3, 3), cm.getCursor('anchor'));
+ helpers.doKeys('k');
+ eqPos(Pos(1, 2), cm.getCursor('head'));
+ eqPos(Pos(3, 3), cm.getCursor('anchor'));
+}, { value: 'cross\ncross\ncross\ncross\ncross\n'});
+testVim('visual_crossover_down', function(cm, vim, helpers) {
+ cm.setCursor(1, 2);
+ helpers.doKeys('v', 'k', 'j', 'j');
+ eqPos(Pos(2, 3), cm.getCursor('head'));
+ eqPos(Pos(1, 2), cm.getCursor('anchor'));
+ helpers.doKeys('j');
+ eqPos(Pos(3, 3), cm.getCursor('head'));
+ eqPos(Pos(1, 2), cm.getCursor('anchor'));
+}, { value: 'cross\ncross\ncross\ncross\ncross\n'});
testVim('visual_exit', function(cm, vim, helpers) {
helpers.doKeys('', 'l', 'j', 'j', '');
- eq(cm.getCursor('anchor'), cm.getCursor('head'));
+ eqPos(cm.getCursor('anchor'), cm.getCursor('head'));
eq(vim.visualMode, false);
}, { value: 'hello\nworld\nfoo' });
testVim('visual_line', function(cm, vim, helpers) {
helpers.doKeys('l', 'V', 'l', 'j', 'j', 'd');
eq(' 4\n 5', cm.getValue());
}, { value: ' 1\n 2\n 3\n 4\n 5' });
-testVim('visual_block', function(cm, vim, helpers) {
+testVim('visual_block_different_line_lengths', function(cm, vim, helpers) {
// test the block selection with lines of different length
// i.e. extending the selection
// till the end of the longest line.
helpers.doKeys('', 'l', 'j', 'j', '6', 'l', 'd');
helpers.doKeys('d', 'd', 'd', 'd');
eq('', cm.getValue());
+}, {value: '1234\n5678\nabcdefg'});
+testVim('visual_block_truncate_on_short_line', function(cm, vim, helpers) {
// check for left side selection in case
// of moving up to a shorter line.
- cm.replaceRange('hello world\n{\nthis is\nsparta!', cm.getCursor());
+ cm.replaceRange('', cm.getCursor());
cm.setCursor(3, 4);
helpers.doKeys('', 'l', 'k', 'k', 'd');
eq('hello world\n{\ntis\nsa!', cm.getValue());
- cm.replaceRange('12345\n67891\nabcde', {line: 0, ch: 0}, {line: cm.lastLine(), ch: 6});
+}, {value: 'hello world\n{\nthis is\nsparta!'});
+testVim('visual_block_corners', function(cm, vim, helpers) {
cm.setCursor(1, 2);
helpers.doKeys('', '2', 'l', 'k');
// circle around the anchor
@@ -1733,10 +1825,12 @@ testVim('visual_block', function(cm, vim, helpers) {
helpers.doKeys('4', 'l');
selections = cm.getSelections();
eq('891cde', selections.join(''));
+}, {value: '12345\n67891\nabcde'});
+testVim('visual_block_mode_switch', function(cm, vim, helpers) {
// switch between visual modes
cm.setCursor(1, 1);
// blockwise to characterwise visual
- helpers.doKeys('', '', 'j', 'l', 'v');
+ helpers.doKeys('', 'j', 'l', 'v');
selections = cm.getSelections();
eq('7891\nabc', selections.join(''));
// characterwise to blockwise
@@ -1747,7 +1841,7 @@ testVim('visual_block', function(cm, vim, helpers) {
helpers.doKeys('V');
selections = cm.getSelections();
eq('67891\nabcde', selections.join(''));
-}, {value: '1234\n5678\nabcdefg'});
+}, {value: '12345\n67891\nabcde'});
testVim('visual_block_crossing_short_line', function(cm, vim, helpers) {
// visual block with long and short lines
cm.setCursor(0, 3);
@@ -1757,11 +1851,20 @@ testVim('visual_block_crossing_short_line', function(cm, vim, helpers) {
helpers.doKeys('3', 'k');
selections = cm.getSelections().join();
eq('4', selections);
-}, {value: '123456\n78\nabcdefg\nfoobar'});
+ helpers.doKeys('5', 'j', 'k');
+ selections = cm.getSelections().join("");
+ eq(10, selections.length);
+}, {value: '123456\n78\nabcdefg\nfoobar\n}\n'});
testVim('visual_block_curPos_on_exit', function(cm, vim, helpers) {
cm.setCursor(0, 0);
helpers.doKeys('', '3' , 'l', '');
eqPos(makeCursor(0, 3), cm.getCursor());
+ helpers.doKeys('h', '', '2' , 'j' ,'3' , 'l');
+ eq(cm.getSelections().join(), "3456,,cdef");
+ helpers.doKeys('4' , 'h');
+ eq(cm.getSelections().join(), "23,8,bc");
+ helpers.doKeys('2' , 'l');
+ eq(cm.getSelections().join(), "34,,cd");
}, {value: '123456\n78\nabcdefg\nfoobar'});
testVim('visual_marks', function(cm, vim, helpers) {
@@ -1776,6 +1879,7 @@ testVim('visual_marks', function(cm, vim, helpers) {
testVim('visual_join', function(cm, vim, helpers) {
helpers.doKeys('l', 'V', 'l', 'j', 'j', 'J');
eq(' 1 2 3\n 4\n 5', cm.getValue());
+ is(!vim.visualMode);
}, { value: ' 1\n 2\n 3\n 4\n 5' });
testVim('visual_blank', function(cm, vim, helpers) {
helpers.doKeys('v', 'k');
@@ -1817,12 +1921,15 @@ testVim('reselect_visual_block', function(cm, vim, helpers) {
helpers.doKeys('', 'k', 'h', '');
cm.setCursor(2, 1);
helpers.doKeys('v', 'l', 'g', 'v');
- helpers.assertCursorAt(0, 1);
+ eqPos(Pos(1, 2), vim.sel.anchor);
+ eqPos(Pos(0, 1), vim.sel.head);
// Ensure selection is done with visual block mode rather than one
// continuous range.
eq(cm.getSelections().join(''), '23oo')
helpers.doKeys('g', 'v');
- helpers.assertCursorAt(2, 3);
+ eqPos(Pos(2, 1), vim.sel.anchor);
+ eqPos(Pos(2, 2), vim.sel.head);
+ helpers.doKeys('');
// Ensure selection of deleted range
cm.setCursor(1, 1);
helpers.doKeys('v', '', 'j', 'd', 'g', 'v');
@@ -1856,11 +1963,14 @@ testVim('o_visual', function(cm, vim, helpers) {
testVim('o_visual_block', function(cm, vim, helpers) {
cm.setCursor(0, 1);
helpers.doKeys('','3','j','l','l', 'o');
- helpers.assertCursorAt(0, 1);
+ eqPos(Pos(3, 3), vim.sel.anchor);
+ eqPos(Pos(0, 1), vim.sel.head);
helpers.doKeys('O');
- helpers.assertCursorAt(0, 4);
+ eqPos(Pos(3, 1), vim.sel.anchor);
+ eqPos(Pos(0, 3), vim.sel.head);
helpers.doKeys('o');
- helpers.assertCursorAt(3, 1);
+ eqPos(Pos(0, 3), vim.sel.anchor);
+ eqPos(Pos(3, 1), vim.sel.head);
}, { value: 'abcd\nefgh\nijkl\nmnop'});
testVim('changeCase_visual', function(cm, vim, helpers) {
cm.setCursor(0, 0);
@@ -1895,7 +2005,9 @@ testVim('changeCase_visual_block', function(cm, vim, helpers) {
}, { value: 'abcdef\nghijkl\nmnopq\nfoo'});
testVim('visual_paste', function(cm, vim, helpers) {
cm.setCursor(0, 0);
- helpers.doKeys('v', 'l', 'l', 'y', 'j', 'v', 'l', 'p');
+ helpers.doKeys('v', 'l', 'l', 'y');
+ helpers.assertCursorAt(0, 0);
+ helpers.doKeys('3', 'l', 'j', 'v', 'l', 'p');
helpers.assertCursorAt(1, 5);
eq('this is a\nunithitest for visual paste', cm.getValue());
cm.setCursor(0, 0);
diff --git a/theme/3024-day.css b/theme/3024-day.css
index ebf46fb4a5..3c01c2bf58 100644
--- a/theme/3024-day.css
+++ b/theme/3024-day.css
@@ -35,4 +35,4 @@
.cm-s-3024-day span.cm-error {background: #db2d20; color: #5c5855;}
.cm-s-3024-day .CodeMirror-activeline-background {background: #e8f2ff !important;}
-.cm-s-3024-day .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
+.cm-s-3024-day .CodeMirror-matchingbracket { text-decoration: underline; color: #a16a94 !important;}
diff --git a/theme/solarized.css b/theme/solarized.css
index 36d5f79048..07ef406804 100644
--- a/theme/solarized.css
+++ b/theme/solarized.css
@@ -88,11 +88,6 @@ http://ethanschoonover.com/solarized/img/solarized-palette.png
text-decoration-style: dotted;
}
.cm-s-solarized .cm-strong { color: #eee; }
-.cm-s-solarized .cm-tab:before {
- content: "➤"; /*visualize tab character*/
- color: #586e75;
- position:absolute;
-}
.cm-s-solarized .cm-error,
.cm-s-solarized .cm-invalidchar {
color: #586e75;