codemirror-rails 4.4 → 4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror.js +77 -47
- data/vendor/assets/javascripts/codemirror/addons/comment/comment.js +2 -2
- data/vendor/assets/javascripts/codemirror/addons/dialog/dialog.js +26 -14
- data/vendor/assets/javascripts/codemirror/addons/edit/closetag.js +4 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/xml-fold.js +2 -1
- data/vendor/assets/javascripts/codemirror/addons/hint/sql-hint.js +53 -57
- data/vendor/assets/javascripts/codemirror/addons/merge/merge.js +39 -16
- data/vendor/assets/javascripts/codemirror/addons/search/search.js +3 -3
- data/vendor/assets/javascripts/codemirror/keymaps/sublime.js +6 -3
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +333 -90
- data/vendor/assets/javascripts/codemirror/modes/clike.js +11 -0
- data/vendor/assets/javascripts/codemirror/modes/clojure.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +5 -4
- data/vendor/assets/javascripts/codemirror/modes/perl.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/php.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/ruby.js +15 -9
- data/vendor/assets/javascripts/codemirror/modes/sass.js +91 -110
- data/vendor/assets/javascripts/codemirror/modes/slim.js +575 -0
- data/vendor/assets/javascripts/codemirror/modes/verilog.js +5 -0
- data/vendor/assets/stylesheets/codemirror/addons/merge/merge.css +6 -0
- metadata +3 -2
@@ -437,4 +437,15 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|
437
437
|
modeProps: {fold: ["brace", "include"]}
|
438
438
|
});
|
439
439
|
|
440
|
+
def("text/x-nesc", {
|
441
|
+
name: "clike",
|
442
|
+
keywords: words(cKeywords + "as atomic async call command component components configuration event generic " +
|
443
|
+
"implementation includes interface module new norace nx_struct nx_union post provides " +
|
444
|
+
"signal task uses abstract extends"),
|
445
|
+
blockKeywords: words("case do else for if switch while struct"),
|
446
|
+
atoms: words("null"),
|
447
|
+
hooks: {"#": cppHook},
|
448
|
+
modeProps: {fold: ["brace", "include"]}
|
449
|
+
});
|
450
|
+
|
440
451
|
});
|
@@ -114,7 +114,7 @@ CodeMirror.defineMode("clojure", function (options) {
|
|
114
114
|
var first = stream.next();
|
115
115
|
// Read special literals: backspace, newline, space, return.
|
116
116
|
// Just read all lowercase letters.
|
117
|
-
if (first.match(/[a-z]/) && stream.match(/[a-z]+/, true)) {
|
117
|
+
if (first && first.match(/[a-z]/) && stream.match(/[a-z]+/, true)) {
|
118
118
|
return;
|
119
119
|
}
|
120
120
|
// Read unicode character: \u1000 \uA0a1
|
@@ -19,6 +19,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|
19
19
|
var jsonldMode = parserConfig.jsonld;
|
20
20
|
var jsonMode = parserConfig.json || jsonldMode;
|
21
21
|
var isTS = parserConfig.typescript;
|
22
|
+
var wordRE = parserConfig.wordCharacters || /[\w$]/;
|
22
23
|
|
23
24
|
// Tokenizer
|
24
25
|
|
@@ -132,8 +133,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|
132
133
|
} else if (isOperatorChar.test(ch)) {
|
133
134
|
stream.eatWhile(isOperatorChar);
|
134
135
|
return ret("operator", "operator", stream.current());
|
135
|
-
} else {
|
136
|
-
stream.eatWhile(
|
136
|
+
} else if (wordRE.test(ch)) {
|
137
|
+
stream.eatWhile(wordRE);
|
137
138
|
var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
|
138
139
|
return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
|
139
140
|
ret("variable", "variable", word);
|
@@ -202,7 +203,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|
202
203
|
if (--depth == 0) break;
|
203
204
|
} else if (bracket >= 3 && bracket < 6) {
|
204
205
|
++depth;
|
205
|
-
} else if (
|
206
|
+
} else if (wordRE.test(ch)) {
|
206
207
|
sawSomething = true;
|
207
208
|
} else if (sawSomething && !depth) {
|
208
209
|
++pos;
|
@@ -669,7 +670,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|
669
670
|
};
|
670
671
|
});
|
671
672
|
|
672
|
-
CodeMirror.registerHelper("wordChars", "javascript", /[
|
673
|
+
CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
|
673
674
|
|
674
675
|
CodeMirror.defineMIME("text/javascript", "javascript");
|
675
676
|
CodeMirror.defineMIME("text/ecmascript", "javascript");
|
@@ -791,7 +791,7 @@ CodeMirror.defineMode("perl",function(){
|
|
791
791
|
return (state.tokenize||tokenPerl)(stream,state);},
|
792
792
|
electricChars:"{}"};});
|
793
793
|
|
794
|
-
CodeMirror.registerHelper("wordChars", "perl", /[
|
794
|
+
CodeMirror.registerHelper("wordChars", "perl", /[\w$]/);
|
795
795
|
|
796
796
|
CodeMirror.defineMIME("text/x-perl", "perl");
|
797
797
|
|
@@ -95,9 +95,9 @@
|
|
95
95
|
"die echo empty exit eval include include_once isset list require require_once return " +
|
96
96
|
"print unset __halt_compiler self static parent yield insteadof finally";
|
97
97
|
var phpAtoms = "true false null TRUE FALSE NULL __CLASS__ __DIR__ __FILE__ __LINE__ __METHOD__ __FUNCTION__ __NAMESPACE__ __TRAIT__";
|
98
|
-
var phpBuiltin = "func_num_args func_get_arg func_get_args strlen strcmp strncmp strcasecmp strncasecmp each error_reporting define defined trigger_error user_error set_error_handler restore_error_handler get_declared_classes get_loaded_extensions extension_loaded get_extension_funcs debug_backtrace constant bin2hex hex2bin sleep usleep time mktime gmmktime strftime gmstrftime strtotime date gmdate getdate localtime checkdate flush wordwrap htmlspecialchars htmlentities html_entity_decode md5 md5_file crc32 getimagesize image_type_to_mime_type phpinfo phpversion phpcredits strnatcmp strnatcasecmp substr_count strspn strcspn strtok strtoupper strtolower strpos strrpos strrev hebrev hebrevc nl2br basename dirname pathinfo stripslashes stripcslashes strstr stristr strrchr str_shuffle str_word_count strcoll substr substr_replace quotemeta ucfirst ucwords strtr addslashes addcslashes rtrim str_replace str_repeat count_chars chunk_split trim ltrim strip_tags similar_text explode implode setlocale localeconv parse_str str_pad chop strchr sprintf printf vprintf vsprintf sscanf fscanf parse_url urlencode urldecode rawurlencode rawurldecode readlink linkinfo link unlink exec system escapeshellcmd escapeshellarg passthru shell_exec proc_open proc_close rand srand getrandmax mt_rand mt_srand mt_getrandmax base64_decode base64_encode abs ceil floor round is_finite is_nan is_infinite bindec hexdec octdec decbin decoct dechex base_convert number_format fmod ip2long long2ip getenv putenv getopt microtime gettimeofday getrusage uniqid quoted_printable_decode set_time_limit get_cfg_var magic_quotes_runtime set_magic_quotes_runtime get_magic_quotes_gpc get_magic_quotes_runtime import_request_variables error_log serialize unserialize memory_get_usage var_dump var_export debug_zval_dump print_r highlight_file show_source highlight_string ini_get ini_get_all ini_set ini_alter ini_restore get_include_path set_include_path restore_include_path setcookie header headers_sent connection_aborted connection_status ignore_user_abort parse_ini_file is_uploaded_file move_uploaded_file intval floatval doubleval strval gettype settype is_null is_resource is_bool is_long is_float is_int is_integer is_double is_real is_numeric is_string is_array is_object is_scalar ereg ereg_replace eregi eregi_replace split spliti join sql_regcase dl pclose popen readfile rewind rmdir umask fclose feof fgetc fgets fgetss fread fopen fpassthru ftruncate fstat fseek ftell fflush fwrite fputs mkdir rename copy tempnam tmpfile file file_get_contents stream_select stream_context_create stream_context_set_params stream_context_set_option stream_context_get_options stream_filter_prepend stream_filter_append fgetcsv flock get_meta_tags stream_set_write_buffer set_file_buffer set_socket_blocking stream_set_blocking socket_set_blocking stream_get_meta_data stream_register_wrapper stream_wrapper_register stream_set_timeout socket_set_timeout socket_get_status realpath fnmatch fsockopen pfsockopen pack unpack get_browser crypt opendir closedir chdir getcwd rewinddir readdir dir glob fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype file_exists is_writable is_writeable is_readable is_executable is_file is_dir is_link stat lstat chown touch clearstatcache mail ob_start ob_flush ob_clean ob_end_flush ob_end_clean ob_get_flush ob_get_clean ob_get_length ob_get_level ob_get_status ob_get_contents ob_implicit_flush ob_list_handlers ksort krsort natsort natcasesort asort arsort sort rsort usort uasort uksort shuffle array_walk count end prev next reset current key min max in_array array_search extract compact array_fill range array_multisort array_push array_pop array_shift array_unshift array_splice array_slice array_merge array_merge_recursive array_keys array_values array_count_values array_reverse array_reduce array_pad array_flip array_change_key_case array_rand array_unique array_intersect array_intersect_assoc array_diff array_diff_assoc array_sum array_filter array_map array_chunk array_key_exists pos sizeof key_exists assert assert_options version_compare ftok str_rot13 aggregate session_name session_module_name session_save_path session_id session_regenerate_id session_decode session_register session_unregister session_is_registered session_encode session_start session_destroy session_unset session_set_save_handler session_cache_limiter session_cache_expire session_set_cookie_params session_get_cookie_params session_write_close preg_match preg_match_all preg_replace preg_replace_callback preg_split preg_quote preg_grep overload ctype_alnum ctype_alpha ctype_cntrl ctype_digit ctype_lower ctype_graph ctype_print ctype_punct ctype_space ctype_upper ctype_xdigit virtual apache_request_headers apache_note apache_lookup_uri apache_child_terminate apache_setenv apache_response_headers apache_get_version getallheaders mysql_connect mysql_pconnect mysql_close mysql_select_db mysql_create_db mysql_drop_db mysql_query mysql_unbuffered_query mysql_db_query mysql_list_dbs mysql_list_tables mysql_list_fields mysql_list_processes mysql_error mysql_errno mysql_affected_rows mysql_insert_id mysql_result mysql_num_rows mysql_num_fields mysql_fetch_row mysql_fetch_array mysql_fetch_assoc mysql_fetch_object mysql_data_seek mysql_fetch_lengths mysql_fetch_field mysql_field_seek mysql_free_result mysql_field_name mysql_field_table mysql_field_len mysql_field_type mysql_field_flags mysql_escape_string mysql_real_escape_string mysql_stat mysql_thread_id mysql_client_encoding mysql_get_client_info mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_info mysql mysql_fieldname mysql_fieldtable mysql_fieldlen mysql_fieldtype mysql_fieldflags mysql_selectdb mysql_createdb mysql_dropdb mysql_freeresult mysql_numfields mysql_numrows mysql_listdbs mysql_listtables mysql_listfields mysql_db_name mysql_dbname mysql_tablename mysql_table_name pg_connect pg_pconnect pg_close pg_connection_status pg_connection_busy pg_connection_reset pg_host pg_dbname pg_port pg_tty pg_options pg_ping pg_query pg_send_query pg_cancel_query pg_fetch_result pg_fetch_row pg_fetch_assoc pg_fetch_array pg_fetch_object pg_fetch_all pg_affected_rows pg_get_result pg_result_seek pg_result_status pg_free_result pg_last_oid pg_num_rows pg_num_fields pg_field_name pg_field_num pg_field_size pg_field_type pg_field_prtlen pg_field_is_null pg_get_notify pg_get_pid pg_result_error pg_last_error pg_last_notice pg_put_line pg_end_copy pg_copy_to pg_copy_from pg_trace pg_untrace pg_lo_create pg_lo_unlink pg_lo_open pg_lo_close pg_lo_read pg_lo_write pg_lo_read_all pg_lo_import pg_lo_export pg_lo_seek pg_lo_tell pg_escape_string pg_escape_bytea pg_unescape_bytea pg_client_encoding pg_set_client_encoding pg_meta_data pg_convert pg_insert pg_update pg_delete pg_select pg_exec pg_getlastoid pg_cmdtuples pg_errormessage pg_numrows pg_numfields pg_fieldname pg_fieldsize pg_fieldtype pg_fieldnum pg_fieldprtlen pg_fieldisnull pg_freeresult pg_result pg_loreadall pg_locreate pg_lounlink pg_loopen pg_loclose pg_loread pg_lowrite pg_loimport pg_loexport http_response_code get_declared_traits getimagesizefromstring socket_import_stream stream_set_chunk_size trait_exists header_register_callback class_uses session_status session_register_shutdown echo print global static exit array empty eval isset unset die include require include_once require_once";
|
98
|
+
var phpBuiltin = "func_num_args func_get_arg func_get_args strlen strcmp strncmp strcasecmp strncasecmp each error_reporting define defined trigger_error user_error set_error_handler restore_error_handler get_declared_classes get_loaded_extensions extension_loaded get_extension_funcs debug_backtrace constant bin2hex hex2bin sleep usleep time mktime gmmktime strftime gmstrftime strtotime date gmdate getdate localtime checkdate flush wordwrap htmlspecialchars htmlentities html_entity_decode md5 md5_file crc32 getimagesize image_type_to_mime_type phpinfo phpversion phpcredits strnatcmp strnatcasecmp substr_count strspn strcspn strtok strtoupper strtolower strpos strrpos strrev hebrev hebrevc nl2br basename dirname pathinfo stripslashes stripcslashes strstr stristr strrchr str_shuffle str_word_count strcoll substr substr_replace quotemeta ucfirst ucwords strtr addslashes addcslashes rtrim str_replace str_repeat count_chars chunk_split trim ltrim strip_tags similar_text explode implode setlocale localeconv parse_str str_pad chop strchr sprintf printf vprintf vsprintf sscanf fscanf parse_url urlencode urldecode rawurlencode rawurldecode readlink linkinfo link unlink exec system escapeshellcmd escapeshellarg passthru shell_exec proc_open proc_close rand srand getrandmax mt_rand mt_srand mt_getrandmax base64_decode base64_encode abs ceil floor round is_finite is_nan is_infinite bindec hexdec octdec decbin decoct dechex base_convert number_format fmod ip2long long2ip getenv putenv getopt microtime gettimeofday getrusage uniqid quoted_printable_decode set_time_limit get_cfg_var magic_quotes_runtime set_magic_quotes_runtime get_magic_quotes_gpc get_magic_quotes_runtime import_request_variables error_log serialize unserialize memory_get_usage var_dump var_export debug_zval_dump print_r highlight_file show_source highlight_string ini_get ini_get_all ini_set ini_alter ini_restore get_include_path set_include_path restore_include_path setcookie header headers_sent connection_aborted connection_status ignore_user_abort parse_ini_file is_uploaded_file move_uploaded_file intval floatval doubleval strval gettype settype is_null is_resource is_bool is_long is_float is_int is_integer is_double is_real is_numeric is_string is_array is_object is_scalar ereg ereg_replace eregi eregi_replace split spliti join sql_regcase dl pclose popen readfile rewind rmdir umask fclose feof fgetc fgets fgetss fread fopen fpassthru ftruncate fstat fseek ftell fflush fwrite fputs mkdir rename copy tempnam tmpfile file file_get_contents stream_select stream_context_create stream_context_set_params stream_context_set_option stream_context_get_options stream_filter_prepend stream_filter_append fgetcsv flock get_meta_tags stream_set_write_buffer set_file_buffer set_socket_blocking stream_set_blocking socket_set_blocking stream_get_meta_data stream_register_wrapper stream_wrapper_register stream_set_timeout socket_set_timeout socket_get_status realpath fnmatch fsockopen pfsockopen pack unpack get_browser crypt opendir closedir chdir getcwd rewinddir readdir dir glob fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype file_exists is_writable is_writeable is_readable is_executable is_file is_dir is_link stat lstat chown touch clearstatcache mail ob_start ob_flush ob_clean ob_end_flush ob_end_clean ob_get_flush ob_get_clean ob_get_length ob_get_level ob_get_status ob_get_contents ob_implicit_flush ob_list_handlers ksort krsort natsort natcasesort asort arsort sort rsort usort uasort uksort shuffle array_walk count end prev next reset current key min max in_array array_search extract compact array_fill range array_multisort array_push array_pop array_shift array_unshift array_splice array_slice array_merge array_merge_recursive array_keys array_values array_count_values array_reverse array_reduce array_pad array_flip array_change_key_case array_rand array_unique array_intersect array_intersect_assoc array_diff array_diff_assoc array_sum array_filter array_map array_chunk array_key_exists pos sizeof key_exists assert assert_options version_compare ftok str_rot13 aggregate session_name session_module_name session_save_path session_id session_regenerate_id session_decode session_register session_unregister session_is_registered session_encode session_start session_destroy session_unset session_set_save_handler session_cache_limiter session_cache_expire session_set_cookie_params session_get_cookie_params session_write_close preg_match preg_match_all preg_replace preg_replace_callback preg_split preg_quote preg_grep overload ctype_alnum ctype_alpha ctype_cntrl ctype_digit ctype_lower ctype_graph ctype_print ctype_punct ctype_space ctype_upper ctype_xdigit virtual apache_request_headers apache_note apache_lookup_uri apache_child_terminate apache_setenv apache_response_headers apache_get_version getallheaders mysql_connect mysql_pconnect mysql_close mysql_select_db mysql_create_db mysql_drop_db mysql_query mysql_unbuffered_query mysql_db_query mysql_list_dbs mysql_list_tables mysql_list_fields mysql_list_processes mysql_error mysql_errno mysql_affected_rows mysql_insert_id mysql_result mysql_num_rows mysql_num_fields mysql_fetch_row mysql_fetch_array mysql_fetch_assoc mysql_fetch_object mysql_data_seek mysql_fetch_lengths mysql_fetch_field mysql_field_seek mysql_free_result mysql_field_name mysql_field_table mysql_field_len mysql_field_type mysql_field_flags mysql_escape_string mysql_real_escape_string mysql_stat mysql_thread_id mysql_client_encoding mysql_get_client_info mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_info mysql mysql_fieldname mysql_fieldtable mysql_fieldlen mysql_fieldtype mysql_fieldflags mysql_selectdb mysql_createdb mysql_dropdb mysql_freeresult mysql_numfields mysql_numrows mysql_listdbs mysql_listtables mysql_listfields mysql_db_name mysql_dbname mysql_tablename mysql_table_name pg_connect pg_pconnect pg_close pg_connection_status pg_connection_busy pg_connection_reset pg_host pg_dbname pg_port pg_tty pg_options pg_ping pg_query pg_send_query pg_cancel_query pg_fetch_result pg_fetch_row pg_fetch_assoc pg_fetch_array pg_fetch_object pg_fetch_all pg_affected_rows pg_get_result pg_result_seek pg_result_status pg_free_result pg_last_oid pg_num_rows pg_num_fields pg_field_name pg_field_num pg_field_size pg_field_type pg_field_prtlen pg_field_is_null pg_get_notify pg_get_pid pg_result_error pg_last_error pg_last_notice pg_put_line pg_end_copy pg_copy_to pg_copy_from pg_trace pg_untrace pg_lo_create pg_lo_unlink pg_lo_open pg_lo_close pg_lo_read pg_lo_write pg_lo_read_all pg_lo_import pg_lo_export pg_lo_seek pg_lo_tell pg_escape_string pg_escape_bytea pg_unescape_bytea pg_client_encoding pg_set_client_encoding pg_meta_data pg_convert pg_insert pg_update pg_delete pg_select pg_exec pg_getlastoid pg_cmdtuples pg_errormessage pg_numrows pg_numfields pg_fieldname pg_fieldsize pg_fieldtype pg_fieldnum pg_fieldprtlen pg_fieldisnull pg_freeresult pg_result pg_loreadall pg_locreate pg_lounlink pg_loopen pg_loclose pg_loread pg_lowrite pg_loimport pg_loexport http_response_code get_declared_traits getimagesizefromstring socket_import_stream stream_set_chunk_size trait_exists header_register_callback class_uses session_status session_register_shutdown echo print global static exit array empty eval isset unset die include require include_once require_once json_decode json_encode json_last_error json_last_error_msg curl_close curl_copy_handle curl_errno curl_error curl_escape curl_exec curl_file_create curl_getinfo curl_init curl_multi_add_handle curl_multi_close curl_multi_exec curl_multi_getcontent curl_multi_info_read curl_multi_init curl_multi_remove_handle curl_multi_select curl_multi_setopt curl_multi_strerror curl_pause curl_reset curl_setopt_array curl_setopt curl_share_close curl_share_init curl_share_setopt curl_strerror curl_unescape curl_version mysqli_affected_rows mysqli_autocommit mysqli_change_user mysqli_character_set_name mysqli_close mysqli_commit mysqli_connect_errno mysqli_connect_error mysqli_connect mysqli_data_seek mysqli_debug mysqli_dump_debug_info mysqli_errno mysqli_error_list mysqli_error mysqli_fetch_all mysqli_fetch_array mysqli_fetch_assoc mysqli_fetch_field_direct mysqli_fetch_field mysqli_fetch_fields mysqli_fetch_lengths mysqli_fetch_object mysqli_fetch_row mysqli_field_count mysqli_field_seek mysqli_field_tell mysqli_free_result mysqli_get_charset mysqli_get_client_info mysqli_get_client_stats mysqli_get_client_version mysqli_get_connection_stats mysqli_get_host_info mysqli_get_proto_info mysqli_get_server_info mysqli_get_server_version mysqli_info mysqli_init mysqli_insert_id mysqli_kill mysqli_more_results mysqli_multi_query mysqli_next_result mysqli_num_fields mysqli_num_rows mysqli_options mysqli_ping mysqli_prepare mysqli_query mysqli_real_connect mysqli_real_escape_string mysqli_real_query mysqli_reap_async_query mysqli_refresh mysqli_rollback mysqli_select_db mysqli_set_charset mysqli_set_local_infile_default mysqli_set_local_infile_handler mysqli_sqlstate mysqli_ssl_set mysqli_stat mysqli_stmt_init mysqli_store_result mysqli_thread_id mysqli_thread_safe mysqli_use_result mysqli_warning_count";
|
99
99
|
CodeMirror.registerHelper("hintWords", "php", [phpKeywords, phpAtoms, phpBuiltin].join(" ").split(" "));
|
100
|
-
CodeMirror.registerHelper("wordChars", "php", /[
|
100
|
+
CodeMirror.registerHelper("wordChars", "php", /[\w$]/);
|
101
101
|
|
102
102
|
var phpConfig = {
|
103
103
|
name: "clike",
|
@@ -141,7 +141,8 @@ CodeMirror.defineMode("ruby", function(config) {
|
|
141
141
|
} else if (ch == "-" && stream.eat(">")) {
|
142
142
|
return "arrow";
|
143
143
|
} else if (/[=+\-\/*:\.^%<>~|]/.test(ch)) {
|
144
|
-
stream.eatWhile(/[=+\-\/*:\.^%<>~|]/);
|
144
|
+
var more = stream.eatWhile(/[=+\-\/*:\.^%<>~|]/);
|
145
|
+
if (ch == "." && !more) curPunc = ".";
|
145
146
|
return "operator";
|
146
147
|
} else {
|
147
148
|
return null;
|
@@ -232,20 +233,25 @@ CodeMirror.defineMode("ruby", function(config) {
|
|
232
233
|
token: function(stream, state) {
|
233
234
|
if (stream.sol()) state.indented = stream.indentation();
|
234
235
|
var style = state.tokenize[state.tokenize.length-1](stream, state), kwtype;
|
236
|
+
var thisTok = curPunc;
|
235
237
|
if (style == "ident") {
|
236
238
|
var word = stream.current();
|
237
|
-
style =
|
239
|
+
style = state.lastTok == "." ? "property"
|
240
|
+
: keywords.propertyIsEnumerable(stream.current()) ? "keyword"
|
238
241
|
: /^[A-Z]/.test(word) ? "tag"
|
239
242
|
: (state.lastTok == "def" || state.lastTok == "class" || state.varList) ? "def"
|
240
243
|
: "variable";
|
241
|
-
if (
|
242
|
-
|
243
|
-
|
244
|
-
kwtype = "
|
245
|
-
|
246
|
-
|
244
|
+
if (style == "keyword") {
|
245
|
+
thisTok = word;
|
246
|
+
if (indentWords.propertyIsEnumerable(word)) kwtype = "indent";
|
247
|
+
else if (dedentWords.propertyIsEnumerable(word)) kwtype = "dedent";
|
248
|
+
else if ((word == "if" || word == "unless") && stream.column() == stream.indentation())
|
249
|
+
kwtype = "indent";
|
250
|
+
else if (word == "do" && state.context.indented < state.indented)
|
251
|
+
kwtype = "indent";
|
252
|
+
}
|
247
253
|
}
|
248
|
-
if (curPunc || (style && style != "comment")) state.lastTok =
|
254
|
+
if (curPunc || (style && style != "comment")) state.lastTok = thisTok;
|
249
255
|
if (curPunc == "|") state.varList = !state.varList;
|
250
256
|
|
251
257
|
if (kwtype == "indent" || /[\(\[\{]/.test(curPunc))
|
@@ -12,9 +12,9 @@
|
|
12
12
|
"use strict";
|
13
13
|
|
14
14
|
CodeMirror.defineMode("sass", function(config) {
|
15
|
-
|
15
|
+
function tokenRegexp(words) {
|
16
16
|
return new RegExp("^" + words.join("|"));
|
17
|
-
}
|
17
|
+
}
|
18
18
|
|
19
19
|
var keywords = ["true", "false", "null", "auto"];
|
20
20
|
var keywordsRegexp = new RegExp("^" + keywords.join("|"));
|
@@ -24,246 +24,233 @@ CodeMirror.defineMode("sass", function(config) {
|
|
24
24
|
|
25
25
|
var pseudoElementsRegexp = /^::?[\w\-]+/;
|
26
26
|
|
27
|
-
|
27
|
+
function urlTokens(stream, state) {
|
28
28
|
var ch = stream.peek();
|
29
29
|
|
30
|
-
if (ch === ")"){
|
30
|
+
if (ch === ")") {
|
31
31
|
stream.next();
|
32
32
|
state.tokenizer = tokenBase;
|
33
33
|
return "operator";
|
34
|
-
}else if (ch === "("){
|
34
|
+
} else if (ch === "(") {
|
35
35
|
stream.next();
|
36
36
|
stream.eatSpace();
|
37
37
|
|
38
38
|
return "operator";
|
39
|
-
}else if (ch === "'" || ch === '"'){
|
39
|
+
} else if (ch === "'" || ch === '"') {
|
40
40
|
state.tokenizer = buildStringTokenizer(stream.next());
|
41
41
|
return "string";
|
42
|
-
}else{
|
42
|
+
} else {
|
43
43
|
state.tokenizer = buildStringTokenizer(")", false);
|
44
44
|
return "string";
|
45
45
|
}
|
46
|
-
}
|
47
|
-
|
48
|
-
|
49
|
-
stream.
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
stream.next();
|
54
|
-
}
|
46
|
+
}
|
47
|
+
function comment(indentation, multiLine) {
|
48
|
+
return function(stream, state) {
|
49
|
+
if (stream.sol() && stream.indentation() <= indentation) {
|
50
|
+
state.tokenizer = tokenBase;
|
51
|
+
return tokenBase(stream, state);
|
52
|
+
}
|
55
53
|
|
56
|
-
|
57
|
-
|
54
|
+
if (multiLine && stream.skipTo("*/")) {
|
55
|
+
stream.next();
|
56
|
+
stream.next();
|
57
|
+
state.tokenizer = tokenBase;
|
58
|
+
} else {
|
59
|
+
stream.next();
|
60
|
+
}
|
58
61
|
|
59
|
-
|
60
|
-
|
62
|
+
return "comment";
|
63
|
+
};
|
64
|
+
}
|
65
|
+
|
66
|
+
function buildStringTokenizer(quote, greedy) {
|
67
|
+
if(greedy == null) { greedy = true; }
|
61
68
|
|
62
|
-
function stringTokenizer(stream, state){
|
69
|
+
function stringTokenizer(stream, state) {
|
63
70
|
var nextChar = stream.next();
|
64
71
|
var peekChar = stream.peek();
|
65
72
|
var previousChar = stream.string.charAt(stream.pos-2);
|
66
73
|
|
67
74
|
var endingString = ((nextChar !== "\\" && peekChar === quote) || (nextChar === quote && previousChar !== "\\"));
|
68
75
|
|
69
|
-
|
70
|
-
console.log("previousChar: " + previousChar);
|
71
|
-
console.log("nextChar: " + nextChar);
|
72
|
-
console.log("peekChar: " + peekChar);
|
73
|
-
console.log("ending: " + endingString);
|
74
|
-
*/
|
75
|
-
|
76
|
-
if (endingString){
|
76
|
+
if (endingString) {
|
77
77
|
if (nextChar !== quote && greedy) { stream.next(); }
|
78
78
|
state.tokenizer = tokenBase;
|
79
79
|
return "string";
|
80
|
-
}else if (nextChar === "#" && peekChar === "{"){
|
80
|
+
} else if (nextChar === "#" && peekChar === "{") {
|
81
81
|
state.tokenizer = buildInterpolationTokenizer(stringTokenizer);
|
82
82
|
stream.next();
|
83
83
|
return "operator";
|
84
|
-
}else {
|
84
|
+
} else {
|
85
85
|
return "string";
|
86
86
|
}
|
87
87
|
}
|
88
88
|
|
89
89
|
return stringTokenizer;
|
90
|
-
}
|
90
|
+
}
|
91
91
|
|
92
|
-
|
93
|
-
return function(stream, state){
|
94
|
-
if (stream.peek() === "}"){
|
92
|
+
function buildInterpolationTokenizer(currentTokenizer) {
|
93
|
+
return function(stream, state) {
|
94
|
+
if (stream.peek() === "}") {
|
95
95
|
stream.next();
|
96
96
|
state.tokenizer = currentTokenizer;
|
97
97
|
return "operator";
|
98
|
-
}else{
|
98
|
+
} else {
|
99
99
|
return tokenBase(stream, state);
|
100
100
|
}
|
101
101
|
};
|
102
|
-
}
|
102
|
+
}
|
103
103
|
|
104
|
-
|
105
|
-
if (state.indentCount == 0){
|
104
|
+
function indent(state) {
|
105
|
+
if (state.indentCount == 0) {
|
106
106
|
state.indentCount++;
|
107
107
|
var lastScopeOffset = state.scopes[0].offset;
|
108
108
|
var currentOffset = lastScopeOffset + config.indentUnit;
|
109
109
|
state.scopes.unshift({ offset:currentOffset });
|
110
110
|
}
|
111
|
-
}
|
111
|
+
}
|
112
112
|
|
113
|
-
|
114
|
-
if (state.scopes.length == 1)
|
113
|
+
function dedent(state) {
|
114
|
+
if (state.scopes.length == 1) return;
|
115
115
|
|
116
116
|
state.scopes.shift();
|
117
|
-
}
|
117
|
+
}
|
118
118
|
|
119
|
-
|
119
|
+
function tokenBase(stream, state) {
|
120
120
|
var ch = stream.peek();
|
121
121
|
|
122
|
-
//
|
123
|
-
if (stream.match(
|
124
|
-
stream.
|
125
|
-
return
|
122
|
+
// Comment
|
123
|
+
if (stream.match("/*")) {
|
124
|
+
state.tokenizer = comment(stream.indentation(), true);
|
125
|
+
return state.tokenizer(stream, state);
|
126
126
|
}
|
127
|
-
|
128
|
-
|
129
|
-
if (stream.match('/*')){
|
130
|
-
state.tokenizer = multilineComment;
|
127
|
+
if (stream.match("//")) {
|
128
|
+
state.tokenizer = comment(stream.indentation(), false);
|
131
129
|
return state.tokenizer(stream, state);
|
132
130
|
}
|
133
131
|
|
134
132
|
// Interpolation
|
135
|
-
if (stream.match(
|
136
|
-
|
133
|
+
if (stream.match("#{")) {
|
134
|
+
state.tokenizer = buildInterpolationTokenizer(tokenBase);
|
137
135
|
return "operator";
|
138
136
|
}
|
139
137
|
|
140
|
-
if (ch === "."){
|
138
|
+
if (ch === ".") {
|
141
139
|
stream.next();
|
142
140
|
|
143
141
|
// Match class selectors
|
144
|
-
if (stream.match(/^[\w-]+/)){
|
142
|
+
if (stream.match(/^[\w-]+/)) {
|
145
143
|
indent(state);
|
146
144
|
return "atom";
|
147
|
-
}else if (stream.peek() === "#"){
|
145
|
+
} else if (stream.peek() === "#") {
|
148
146
|
indent(state);
|
149
147
|
return "atom";
|
150
|
-
}else{
|
148
|
+
} else {
|
151
149
|
return "operator";
|
152
150
|
}
|
153
151
|
}
|
154
152
|
|
155
|
-
if (ch === "#"){
|
153
|
+
if (ch === "#") {
|
156
154
|
stream.next();
|
157
155
|
|
158
156
|
// Hex numbers
|
159
|
-
if (stream.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/))
|
157
|
+
if (stream.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/))
|
160
158
|
return "number";
|
161
|
-
}
|
162
159
|
|
163
160
|
// ID selectors
|
164
|
-
if (stream.match(/^[\w-]+/)){
|
161
|
+
if (stream.match(/^[\w-]+/)) {
|
165
162
|
indent(state);
|
166
163
|
return "atom";
|
167
164
|
}
|
168
165
|
|
169
|
-
if (stream.peek() === "#"){
|
166
|
+
if (stream.peek() === "#") {
|
170
167
|
indent(state);
|
171
168
|
return "atom";
|
172
169
|
}
|
173
170
|
}
|
174
171
|
|
175
172
|
// Numbers
|
176
|
-
if (stream.match(/^-?[0-9\.]+/))
|
173
|
+
if (stream.match(/^-?[0-9\.]+/))
|
177
174
|
return "number";
|
178
|
-
}
|
179
175
|
|
180
176
|
// Units
|
181
|
-
if (stream.match(/^(px|em|in)\b/))
|
177
|
+
if (stream.match(/^(px|em|in)\b/))
|
182
178
|
return "unit";
|
183
|
-
}
|
184
179
|
|
185
|
-
if (stream.match(keywordsRegexp))
|
180
|
+
if (stream.match(keywordsRegexp))
|
186
181
|
return "keyword";
|
187
|
-
}
|
188
182
|
|
189
|
-
if (stream.match(/^url/) && stream.peek() === "("){
|
183
|
+
if (stream.match(/^url/) && stream.peek() === "(") {
|
190
184
|
state.tokenizer = urlTokens;
|
191
185
|
return "atom";
|
192
186
|
}
|
193
187
|
|
194
188
|
// Variables
|
195
|
-
if (ch === "$"){
|
189
|
+
if (ch === "$") {
|
196
190
|
stream.next();
|
197
191
|
stream.eatWhile(/[\w-]/);
|
198
192
|
|
199
|
-
if (stream.peek() === ":"){
|
193
|
+
if (stream.peek() === ":") {
|
200
194
|
stream.next();
|
201
195
|
return "variable-2";
|
202
|
-
}else{
|
196
|
+
} else {
|
203
197
|
return "variable-3";
|
204
198
|
}
|
205
199
|
}
|
206
200
|
|
207
|
-
if (ch === "!"){
|
201
|
+
if (ch === "!") {
|
208
202
|
stream.next();
|
209
|
-
|
210
|
-
if (stream.match(/^[\w]+/)){
|
211
|
-
return "keyword";
|
212
|
-
}
|
213
|
-
|
214
|
-
return "operator";
|
203
|
+
return stream.match(/^[\w]+/) ? "keyword": "operator";
|
215
204
|
}
|
216
205
|
|
217
|
-
if (ch === "="){
|
206
|
+
if (ch === "=") {
|
218
207
|
stream.next();
|
219
208
|
|
220
209
|
// Match shortcut mixin definition
|
221
|
-
if (stream.match(/^[\w-]+/)){
|
210
|
+
if (stream.match(/^[\w-]+/)) {
|
222
211
|
indent(state);
|
223
212
|
return "meta";
|
224
|
-
}else {
|
213
|
+
} else {
|
225
214
|
return "operator";
|
226
215
|
}
|
227
216
|
}
|
228
217
|
|
229
|
-
if (ch === "+"){
|
218
|
+
if (ch === "+") {
|
230
219
|
stream.next();
|
231
220
|
|
232
221
|
// Match shortcut mixin definition
|
233
|
-
if (stream.match(/^[\w-]+/))
|
222
|
+
if (stream.match(/^[\w-]+/))
|
234
223
|
return "variable-3";
|
235
|
-
|
224
|
+
else
|
236
225
|
return "operator";
|
237
|
-
}
|
238
226
|
}
|
239
227
|
|
240
228
|
// Indent Directives
|
241
|
-
if (stream.match(/^@(else if|if|media|else|for|each|while|mixin|function)/)){
|
229
|
+
if (stream.match(/^@(else if|if|media|else|for|each|while|mixin|function)/)) {
|
242
230
|
indent(state);
|
243
231
|
return "meta";
|
244
232
|
}
|
245
233
|
|
246
234
|
// Other Directives
|
247
|
-
if (ch === "@"){
|
235
|
+
if (ch === "@") {
|
248
236
|
stream.next();
|
249
237
|
stream.eatWhile(/[\w-]/);
|
250
238
|
return "meta";
|
251
239
|
}
|
252
240
|
|
253
241
|
// Strings
|
254
|
-
if (ch === '"' || ch === "'"){
|
242
|
+
if (ch === '"' || ch === "'") {
|
255
243
|
stream.next();
|
256
244
|
state.tokenizer = buildStringTokenizer(ch);
|
257
245
|
return "string";
|
258
246
|
}
|
259
247
|
|
260
248
|
// Pseudo element selectors
|
261
|
-
if (ch ==
|
249
|
+
if (ch == ":" && stream.match(pseudoElementsRegexp))
|
262
250
|
return "keyword";
|
263
|
-
}
|
264
251
|
|
265
252
|
// atoms
|
266
|
-
if (stream.eatWhile(/[\w-&]/)){
|
253
|
+
if (stream.eatWhile(/[\w-&]/)) {
|
267
254
|
// matches a property definition
|
268
255
|
if (stream.peek() === ":" && !stream.match(pseudoElementsRegexp, false))
|
269
256
|
return "property";
|
@@ -271,43 +258,37 @@ CodeMirror.defineMode("sass", function(config) {
|
|
271
258
|
return "atom";
|
272
259
|
}
|
273
260
|
|
274
|
-
if (stream.match(opRegexp))
|
261
|
+
if (stream.match(opRegexp))
|
275
262
|
return "operator";
|
276
|
-
}
|
277
263
|
|
278
264
|
// If we haven't returned by now, we move 1 character
|
279
265
|
// and return an error
|
280
266
|
stream.next();
|
281
267
|
return null;
|
282
|
-
}
|
268
|
+
}
|
283
269
|
|
284
|
-
|
285
|
-
if (stream.sol())
|
286
|
-
state.indentCount = 0;
|
287
|
-
}
|
270
|
+
function tokenLexer(stream, state) {
|
271
|
+
if (stream.sol()) state.indentCount = 0;
|
288
272
|
var style = state.tokenizer(stream, state);
|
289
273
|
var current = stream.current();
|
290
274
|
|
291
|
-
if (current === "@return")
|
275
|
+
if (current === "@return")
|
292
276
|
dedent(state);
|
293
|
-
}
|
294
277
|
|
295
|
-
if (style === "atom")
|
278
|
+
if (style === "atom")
|
296
279
|
indent(state);
|
297
|
-
}
|
298
280
|
|
299
|
-
if (style !== null){
|
281
|
+
if (style !== null) {
|
300
282
|
var startOfToken = stream.pos - current.length;
|
301
283
|
var withCurrentIndent = startOfToken + (config.indentUnit * state.indentCount);
|
302
284
|
|
303
285
|
var newScopes = [];
|
304
286
|
|
305
|
-
for (var i = 0; i < state.scopes.length; i++){
|
287
|
+
for (var i = 0; i < state.scopes.length; i++) {
|
306
288
|
var scope = state.scopes[i];
|
307
289
|
|
308
|
-
if (scope.offset <= withCurrentIndent)
|
290
|
+
if (scope.offset <= withCurrentIndent)
|
309
291
|
newScopes.push(scope);
|
310
|
-
}
|
311
292
|
}
|
312
293
|
|
313
294
|
state.scopes = newScopes;
|
@@ -315,13 +296,13 @@ CodeMirror.defineMode("sass", function(config) {
|
|
315
296
|
|
316
297
|
|
317
298
|
return style;
|
318
|
-
}
|
299
|
+
}
|
319
300
|
|
320
301
|
return {
|
321
302
|
startState: function() {
|
322
303
|
return {
|
323
304
|
tokenizer: tokenBase,
|
324
|
-
scopes: [{offset: 0, type:
|
305
|
+
scopes: [{offset: 0, type: "sass"}],
|
325
306
|
definedVars: [],
|
326
307
|
definedMixins: []
|
327
308
|
};
|