haml 3.2.0.alpha.10 → 3.2.0.alpha.13
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of haml might be problematic. Click here for more details.
- data/.yardopts +19 -7
- data/CHANGELOG.md +1224 -0
- data/FAQ.md +157 -0
- data/README.md +99 -62
- data/REFERENCE.md +1404 -0
- data/Rakefile +52 -341
- data/init.rb +1 -18
- data/lib/haml.rb +6 -30
- data/lib/haml/buffer.rb +37 -16
- data/lib/haml/compiler.rb +52 -13
- data/lib/haml/engine.rb +61 -44
- data/lib/haml/exec.rb +21 -4
- data/lib/haml/filters.rb +136 -166
- data/lib/haml/helpers.rb +37 -10
- data/lib/haml/helpers/action_view_extensions.rb +2 -1
- data/lib/haml/helpers/action_view_mods.rb +67 -181
- data/lib/haml/helpers/rails_323_textarea_fix.rb +39 -0
- data/lib/haml/helpers/xss_mods.rb +9 -11
- data/lib/haml/html.rb +22 -9
- data/lib/haml/html/erb.rb +1 -1
- data/lib/haml/parser.rb +22 -15
- data/lib/haml/railtie.rb +2 -13
- data/lib/haml/template.rb +18 -85
- data/lib/haml/template/options.rb +1 -1
- data/lib/haml/template/plugin.rb +15 -101
- data/lib/haml/util.rb +120 -603
- data/lib/haml/version.rb +1 -107
- data/test/{haml/engine_test.rb → engine_test.rb} +137 -143
- data/test/{haml/erb → erb}/_av_partial_1.erb +1 -1
- data/test/{haml/erb → erb}/_av_partial_2.erb +1 -1
- data/test/{haml/erb → erb}/action_view.erb +1 -1
- data/test/{haml/erb → erb}/standard.erb +0 -0
- data/test/filters_test.rb +141 -0
- data/test/gemfiles/Gemfile.rails-3.0.x +4 -6
- data/test/gemfiles/Gemfile.rails-3.1.x +5 -6
- data/test/gemfiles/Gemfile.rails-3.2.x +6 -0
- data/test/haml-spec/LICENSE +14 -0
- data/test/{haml/spec → haml-spec}/README.md +26 -17
- data/test/haml-spec/lua_haml_spec.lua +38 -0
- data/test/haml-spec/perl_haml_test.pl +81 -0
- data/test/haml-spec/ruby_haml_test.rb +23 -0
- data/test/{haml/spec → haml-spec}/tests.json +132 -54
- data/test/{haml/helper_test.rb → helper_test.rb} +50 -36
- data/test/{haml/html2haml → html2haml}/erb_tests.rb +0 -0
- data/test/{haml/html2haml_test.rb → html2haml_test.rb} +11 -5
- data/test/{haml/markaby → markaby}/standard.mab +0 -0
- data/test/{haml/mocks → mocks}/article.rb +0 -0
- data/test/{haml/results → results}/content_for_layout.xhtml +0 -0
- data/test/{haml/results → results}/eval_suppressed.xhtml +0 -0
- data/test/{haml/results → results}/helpers.xhtml +0 -0
- data/test/{haml/results → results}/helpful.xhtml +0 -0
- data/test/{haml/results → results}/just_stuff.xhtml +0 -0
- data/test/{haml/results → results}/list.xhtml +0 -0
- data/test/{haml/results → results}/nuke_inner_whitespace.xhtml +0 -0
- data/test/{haml/results → results}/nuke_outer_whitespace.xhtml +0 -0
- data/test/{haml/results → results}/original_engine.xhtml +0 -0
- data/test/{haml/results → results}/partial_layout.xhtml +0 -0
- data/test/{haml/results → results}/partials.xhtml +0 -0
- data/test/{haml/results → results}/render_layout.xhtml +0 -0
- data/test/{haml/results → results}/silent_script.xhtml +1 -1
- data/test/{haml/results → results}/standard.xhtml +0 -0
- data/test/{haml/results → results}/tag_parsing.xhtml +0 -0
- data/test/{haml/results → results}/very_basic.xhtml +0 -0
- data/test/{haml/results → results}/whitespace_handling.xhtml +46 -50
- data/test/{haml/template_test.rb → template_test.rb} +20 -81
- data/test/{haml/templates → templates}/_av_partial_1.haml +1 -1
- data/test/{haml/templates → templates}/_av_partial_1_ugly.haml +1 -1
- data/test/{haml/templates → templates}/_av_partial_2.haml +1 -1
- data/test/{haml/templates → templates}/_av_partial_2_ugly.haml +1 -1
- data/test/{haml/templates → templates}/_layout.erb +0 -0
- data/test/{haml/templates → templates}/_layout_for_partial.haml +0 -0
- data/test/{haml/templates → templates}/_partial.haml +0 -0
- data/test/{haml/templates → templates}/_text_area.haml +0 -0
- data/test/{haml/templates → templates}/action_view.haml +1 -1
- data/test/{haml/templates → templates}/action_view_ugly.haml +1 -1
- data/test/{haml/templates → templates}/breakage.haml +0 -0
- data/test/{haml/templates → templates}/content_for_layout.haml +0 -0
- data/test/{haml/templates → templates}/eval_suppressed.haml +0 -0
- data/test/{haml/templates → templates}/helpers.haml +0 -0
- data/test/{haml/templates → templates}/helpful.haml +0 -0
- data/test/{haml/templates → templates}/just_stuff.haml +0 -0
- data/test/{haml/templates → templates}/list.haml +0 -0
- data/test/{haml/templates → templates}/nuke_inner_whitespace.haml +0 -0
- data/test/{haml/templates → templates}/nuke_outer_whitespace.haml +0 -0
- data/test/{haml/templates → templates}/original_engine.haml +0 -0
- data/test/templates/partial_layout.haml +3 -0
- data/test/{haml/templates → templates}/partialize.haml +0 -0
- data/test/{haml/templates → templates}/partials.haml +0 -0
- data/test/{haml/templates → templates}/render_layout.haml +0 -0
- data/test/{haml/templates → templates}/silent_script.haml +2 -2
- data/test/{haml/templates → templates}/standard.haml +0 -0
- data/test/{haml/templates → templates}/standard_ugly.haml +0 -0
- data/test/{haml/templates → templates}/tag_parsing.haml +0 -0
- data/test/{haml/templates → templates}/very_basic.haml +0 -0
- data/test/{haml/templates → templates}/whitespace_handling.haml +0 -0
- data/test/test_helper.rb +42 -34
- data/test/util_test.rb +80 -0
- metadata +259 -427
- data/CONTRIBUTING +0 -3
- data/REVISION +0 -1
- data/VERSION +0 -1
- data/VERSION_NAME +0 -1
- data/extra/update_watch.rb +0 -13
- data/lib/haml/root.rb +0 -7
- data/lib/haml/shared.rb +0 -78
- data/lib/haml/template/patch.rb +0 -58
- data/lib/sass.rb +0 -8
- data/lib/sass/plugin.rb +0 -10
- data/lib/sass/rails2_shim.rb +0 -9
- data/lib/sass/rails3_shim.rb +0 -16
- data/test/benchmark.rb +0 -91
- data/test/gemfiles/Gemfile.rails-2.0.x +0 -8
- data/test/gemfiles/Gemfile.rails-2.0.x.lock +0 -38
- data/test/gemfiles/Gemfile.rails-2.1.x +0 -8
- data/test/gemfiles/Gemfile.rails-2.1.x.lock +0 -38
- data/test/gemfiles/Gemfile.rails-2.2.x +0 -8
- data/test/gemfiles/Gemfile.rails-2.2.x.lock +0 -38
- data/test/gemfiles/Gemfile.rails-2.3.x +0 -8
- data/test/gemfiles/Gemfile.rails-2.3.x.lock +0 -40
- data/test/gemfiles/Gemfile.rails-3.0.x.lock +0 -85
- data/test/gemfiles/Gemfile.rails-3.1.x.lock +0 -98
- data/test/gemfiles/Gemfile.rails-xss-2.3.x +0 -9
- data/test/gemfiles/Gemfile.rails-xss-2.3.x.lock +0 -42
- data/test/haml/results/filters.xhtml +0 -62
- data/test/haml/spec/lua_haml_spec.lua +0 -30
- data/test/haml/spec/ruby_haml_test.rb +0 -19
- data/test/haml/spec_test.rb +0 -44
- data/test/haml/templates/filters.haml +0 -66
- data/test/haml/templates/partial_layout.haml +0 -10
- data/test/haml/util_test.rb +0 -300
- data/test/linked_rails.rb +0 -42
- data/vendor/sass/CONTRIBUTING +0 -3
- data/vendor/sass/MIT-LICENSE +0 -20
- data/vendor/sass/README.md +0 -201
- data/vendor/sass/Rakefile +0 -339
- data/vendor/sass/TODO +0 -39
- data/vendor/sass/VERSION +0 -1
- data/vendor/sass/VERSION_NAME +0 -1
- data/vendor/sass/bin/sass +0 -8
- data/vendor/sass/bin/sass-convert +0 -7
- data/vendor/sass/bin/scss +0 -8
- data/vendor/sass/doc-src/FAQ.md +0 -35
- data/vendor/sass/doc-src/INDENTED_SYNTAX.md +0 -210
- data/vendor/sass/doc-src/SASS_CHANGELOG.md +0 -2327
- data/vendor/sass/doc-src/SASS_REFERENCE.md +0 -1965
- data/vendor/sass/doc-src/SCSS_FOR_SASS_USERS.md +0 -155
- data/vendor/sass/ext/extconf.rb +0 -10
- data/vendor/sass/extra/update_watch.rb +0 -13
- data/vendor/sass/init.rb +0 -18
- data/vendor/sass/lib/sass.rb +0 -73
- data/vendor/sass/lib/sass/cache_stores.rb +0 -15
- data/vendor/sass/lib/sass/cache_stores/base.rb +0 -86
- data/vendor/sass/lib/sass/cache_stores/chain.rb +0 -33
- data/vendor/sass/lib/sass/cache_stores/filesystem.rb +0 -60
- data/vendor/sass/lib/sass/cache_stores/memory.rb +0 -47
- data/vendor/sass/lib/sass/cache_stores/null.rb +0 -25
- data/vendor/sass/lib/sass/callbacks.rb +0 -66
- data/vendor/sass/lib/sass/css.rb +0 -295
- data/vendor/sass/lib/sass/engine.rb +0 -878
- data/vendor/sass/lib/sass/environment.rb +0 -166
- data/vendor/sass/lib/sass/error.rb +0 -201
- data/vendor/sass/lib/sass/exec.rb +0 -672
- data/vendor/sass/lib/sass/importers.rb +0 -22
- data/vendor/sass/lib/sass/importers/base.rb +0 -139
- data/vendor/sass/lib/sass/importers/filesystem.rb +0 -149
- data/vendor/sass/lib/sass/less.rb +0 -382
- data/vendor/sass/lib/sass/logger.rb +0 -15
- data/vendor/sass/lib/sass/logger/base.rb +0 -32
- data/vendor/sass/lib/sass/logger/log_level.rb +0 -49
- data/vendor/sass/lib/sass/plugin.rb +0 -132
- data/vendor/sass/lib/sass/plugin/compiler.rb +0 -383
- data/vendor/sass/lib/sass/plugin/configuration.rb +0 -123
- data/vendor/sass/lib/sass/plugin/generic.rb +0 -15
- data/vendor/sass/lib/sass/plugin/merb.rb +0 -48
- data/vendor/sass/lib/sass/plugin/rack.rb +0 -60
- data/vendor/sass/lib/sass/plugin/rails.rb +0 -47
- data/vendor/sass/lib/sass/plugin/staleness_checker.rb +0 -173
- data/vendor/sass/lib/sass/railtie.rb +0 -9
- data/vendor/sass/lib/sass/repl.rb +0 -58
- data/vendor/sass/lib/sass/root.rb +0 -7
- data/vendor/sass/lib/sass/script.rb +0 -40
- data/vendor/sass/lib/sass/script/bool.rb +0 -18
- data/vendor/sass/lib/sass/script/color.rb +0 -480
- data/vendor/sass/lib/sass/script/css_lexer.rb +0 -29
- data/vendor/sass/lib/sass/script/css_parser.rb +0 -31
- data/vendor/sass/lib/sass/script/funcall.rb +0 -175
- data/vendor/sass/lib/sass/script/functions.rb +0 -1386
- data/vendor/sass/lib/sass/script/interpolation.rb +0 -79
- data/vendor/sass/lib/sass/script/lexer.rb +0 -339
- data/vendor/sass/lib/sass/script/list.rb +0 -83
- data/vendor/sass/lib/sass/script/literal.rb +0 -250
- data/vendor/sass/lib/sass/script/node.rb +0 -99
- data/vendor/sass/lib/sass/script/number.rb +0 -452
- data/vendor/sass/lib/sass/script/operation.rb +0 -99
- data/vendor/sass/lib/sass/script/parser.rb +0 -474
- data/vendor/sass/lib/sass/script/string.rb +0 -51
- data/vendor/sass/lib/sass/script/string_interpolation.rb +0 -103
- data/vendor/sass/lib/sass/script/unary_operation.rb +0 -64
- data/vendor/sass/lib/sass/script/variable.rb +0 -59
- data/vendor/sass/lib/sass/scss.rb +0 -17
- data/vendor/sass/lib/sass/scss/css_parser.rb +0 -46
- data/vendor/sass/lib/sass/scss/parser.rb +0 -960
- data/vendor/sass/lib/sass/scss/rx.rb +0 -128
- data/vendor/sass/lib/sass/scss/sass_parser.rb +0 -11
- data/vendor/sass/lib/sass/scss/script_lexer.rb +0 -15
- data/vendor/sass/lib/sass/scss/script_parser.rb +0 -25
- data/vendor/sass/lib/sass/scss/static_parser.rb +0 -40
- data/vendor/sass/lib/sass/selector.rb +0 -361
- data/vendor/sass/lib/sass/selector/abstract_sequence.rb +0 -62
- data/vendor/sass/lib/sass/selector/comma_sequence.rb +0 -81
- data/vendor/sass/lib/sass/selector/sequence.rb +0 -233
- data/vendor/sass/lib/sass/selector/simple.rb +0 -113
- data/vendor/sass/lib/sass/selector/simple_sequence.rb +0 -134
- data/vendor/sass/lib/sass/shared.rb +0 -78
- data/vendor/sass/lib/sass/tree/charset_node.rb +0 -22
- data/vendor/sass/lib/sass/tree/comment_node.rb +0 -90
- data/vendor/sass/lib/sass/tree/debug_node.rb +0 -18
- data/vendor/sass/lib/sass/tree/directive_node.rb +0 -23
- data/vendor/sass/lib/sass/tree/each_node.rb +0 -24
- data/vendor/sass/lib/sass/tree/extend_node.rb +0 -29
- data/vendor/sass/lib/sass/tree/for_node.rb +0 -36
- data/vendor/sass/lib/sass/tree/function_node.rb +0 -27
- data/vendor/sass/lib/sass/tree/if_node.rb +0 -52
- data/vendor/sass/lib/sass/tree/import_node.rb +0 -68
- data/vendor/sass/lib/sass/tree/media_node.rb +0 -32
- data/vendor/sass/lib/sass/tree/mixin_def_node.rb +0 -27
- data/vendor/sass/lib/sass/tree/mixin_node.rb +0 -32
- data/vendor/sass/lib/sass/tree/node.rb +0 -201
- data/vendor/sass/lib/sass/tree/prop_node.rb +0 -148
- data/vendor/sass/lib/sass/tree/return_node.rb +0 -18
- data/vendor/sass/lib/sass/tree/root_node.rb +0 -28
- data/vendor/sass/lib/sass/tree/rule_node.rb +0 -136
- data/vendor/sass/lib/sass/tree/variable_node.rb +0 -30
- data/vendor/sass/lib/sass/tree/visitors/base.rb +0 -75
- data/vendor/sass/lib/sass/tree/visitors/check_nesting.rb +0 -133
- data/vendor/sass/lib/sass/tree/visitors/convert.rb +0 -260
- data/vendor/sass/lib/sass/tree/visitors/cssize.rb +0 -175
- data/vendor/sass/lib/sass/tree/visitors/deep_copy.rb +0 -87
- data/vendor/sass/lib/sass/tree/visitors/perform.rb +0 -332
- data/vendor/sass/lib/sass/tree/visitors/set_options.rb +0 -97
- data/vendor/sass/lib/sass/tree/visitors/to_css.rb +0 -210
- data/vendor/sass/lib/sass/tree/warn_node.rb +0 -18
- data/vendor/sass/lib/sass/tree/while_node.rb +0 -18
- data/vendor/sass/lib/sass/util.rb +0 -721
- data/vendor/sass/lib/sass/util/subset_map.rb +0 -101
- data/vendor/sass/lib/sass/version.rb +0 -112
- data/vendor/sass/rails/init.rb +0 -1
- data/vendor/sass/sass.gemspec +0 -33
- data/vendor/sass/test/Gemfile +0 -4
- data/vendor/sass/test/Gemfile.lock +0 -19
- data/vendor/sass/test/sass/cache_test.rb +0 -89
- data/vendor/sass/test/sass/callbacks_test.rb +0 -61
- data/vendor/sass/test/sass/conversion_test.rb +0 -1199
- data/vendor/sass/test/sass/css2sass_test.rb +0 -373
- data/vendor/sass/test/sass/data/hsl-rgb.txt +0 -319
- data/vendor/sass/test/sass/engine_test.rb +0 -2567
- data/vendor/sass/test/sass/extend_test.rb +0 -1348
- data/vendor/sass/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
- data/vendor/sass/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
- data/vendor/sass/test/sass/functions_test.rb +0 -1038
- data/vendor/sass/test/sass/importer_test.rb +0 -192
- data/vendor/sass/test/sass/less_conversion_test.rb +0 -653
- data/vendor/sass/test/sass/logger_test.rb +0 -58
- data/vendor/sass/test/sass/mock_importer.rb +0 -49
- data/vendor/sass/test/sass/more_results/more1.css +0 -9
- data/vendor/sass/test/sass/more_results/more1_with_line_comments.css +0 -26
- data/vendor/sass/test/sass/more_results/more_import.css +0 -29
- data/vendor/sass/test/sass/more_templates/_more_partial.sass +0 -2
- data/vendor/sass/test/sass/more_templates/more1.sass +0 -23
- data/vendor/sass/test/sass/more_templates/more_import.sass +0 -11
- data/vendor/sass/test/sass/plugin_test.rb +0 -472
- data/vendor/sass/test/sass/results/alt.css +0 -4
- data/vendor/sass/test/sass/results/basic.css +0 -9
- data/vendor/sass/test/sass/results/compact.css +0 -5
- data/vendor/sass/test/sass/results/complex.css +0 -86
- data/vendor/sass/test/sass/results/compressed.css +0 -1
- data/vendor/sass/test/sass/results/expanded.css +0 -19
- data/vendor/sass/test/sass/results/if.css +0 -3
- data/vendor/sass/test/sass/results/import.css +0 -31
- data/vendor/sass/test/sass/results/import_charset.css +0 -4
- data/vendor/sass/test/sass/results/import_charset_1_8.css +0 -4
- data/vendor/sass/test/sass/results/import_charset_ibm866.css +0 -4
- data/vendor/sass/test/sass/results/line_numbers.css +0 -49
- data/vendor/sass/test/sass/results/mixins.css +0 -95
- data/vendor/sass/test/sass/results/multiline.css +0 -24
- data/vendor/sass/test/sass/results/nested.css +0 -22
- data/vendor/sass/test/sass/results/options.css +0 -1
- data/vendor/sass/test/sass/results/parent_ref.css +0 -13
- data/vendor/sass/test/sass/results/script.css +0 -16
- data/vendor/sass/test/sass/results/scss_import.css +0 -31
- data/vendor/sass/test/sass/results/scss_importee.css +0 -2
- data/vendor/sass/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
- data/vendor/sass/test/sass/results/subdir/subdir.css +0 -3
- data/vendor/sass/test/sass/results/units.css +0 -11
- data/vendor/sass/test/sass/results/warn.css +0 -0
- data/vendor/sass/test/sass/results/warn_imported.css +0 -0
- data/vendor/sass/test/sass/script_conversion_test.rb +0 -285
- data/vendor/sass/test/sass/script_test.rb +0 -514
- data/vendor/sass/test/sass/scss/css_test.rb +0 -922
- data/vendor/sass/test/sass/scss/rx_test.rb +0 -156
- data/vendor/sass/test/sass/scss/scss_test.rb +0 -1273
- data/vendor/sass/test/sass/scss/test_helper.rb +0 -37
- data/vendor/sass/test/sass/templates/_imported_charset_ibm866.sass +0 -4
- data/vendor/sass/test/sass/templates/_imported_charset_utf8.sass +0 -4
- data/vendor/sass/test/sass/templates/_partial.sass +0 -2
- data/vendor/sass/test/sass/templates/alt.sass +0 -16
- data/vendor/sass/test/sass/templates/basic.sass +0 -23
- data/vendor/sass/test/sass/templates/bork1.sass +0 -2
- data/vendor/sass/test/sass/templates/bork2.sass +0 -2
- data/vendor/sass/test/sass/templates/bork3.sass +0 -2
- data/vendor/sass/test/sass/templates/bork4.sass +0 -2
- data/vendor/sass/test/sass/templates/bork5.sass +0 -3
- data/vendor/sass/test/sass/templates/compact.sass +0 -17
- data/vendor/sass/test/sass/templates/complex.sass +0 -305
- data/vendor/sass/test/sass/templates/compressed.sass +0 -15
- data/vendor/sass/test/sass/templates/expanded.sass +0 -17
- data/vendor/sass/test/sass/templates/if.sass +0 -11
- data/vendor/sass/test/sass/templates/import.sass +0 -12
- data/vendor/sass/test/sass/templates/import_charset.sass +0 -7
- data/vendor/sass/test/sass/templates/import_charset_1_8.sass +0 -4
- data/vendor/sass/test/sass/templates/import_charset_ibm866.sass +0 -9
- data/vendor/sass/test/sass/templates/importee.less +0 -2
- data/vendor/sass/test/sass/templates/importee.sass +0 -19
- data/vendor/sass/test/sass/templates/line_numbers.sass +0 -13
- data/vendor/sass/test/sass/templates/mixin_bork.sass +0 -5
- data/vendor/sass/test/sass/templates/mixins.sass +0 -76
- data/vendor/sass/test/sass/templates/multiline.sass +0 -20
- data/vendor/sass/test/sass/templates/nested.sass +0 -25
- data/vendor/sass/test/sass/templates/nested_bork1.sass +0 -2
- data/vendor/sass/test/sass/templates/nested_bork2.sass +0 -2
- data/vendor/sass/test/sass/templates/nested_bork3.sass +0 -2
- data/vendor/sass/test/sass/templates/nested_bork4.sass +0 -2
- data/vendor/sass/test/sass/templates/nested_bork5.sass +0 -2
- data/vendor/sass/test/sass/templates/nested_import.sass +0 -2
- data/vendor/sass/test/sass/templates/nested_mixin_bork.sass +0 -6
- data/vendor/sass/test/sass/templates/options.sass +0 -2
- data/vendor/sass/test/sass/templates/parent_ref.sass +0 -25
- data/vendor/sass/test/sass/templates/script.sass +0 -101
- data/vendor/sass/test/sass/templates/scss_import.scss +0 -11
- data/vendor/sass/test/sass/templates/scss_importee.scss +0 -1
- data/vendor/sass/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
- data/vendor/sass/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
- data/vendor/sass/test/sass/templates/subdir/subdir.sass +0 -6
- data/vendor/sass/test/sass/templates/units.sass +0 -11
- data/vendor/sass/test/sass/templates/warn.sass +0 -3
- data/vendor/sass/test/sass/templates/warn_imported.sass +0 -4
- data/vendor/sass/test/sass/test_helper.rb +0 -8
- data/vendor/sass/test/sass/util/subset_map_test.rb +0 -91
- data/vendor/sass/test/sass/util_test.rb +0 -266
- data/vendor/sass/test/test_helper.rb +0 -69
- data/vendor/sass/vendor/fssm/Gemfile +0 -3
- data/vendor/sass/vendor/fssm/LICENSE +0 -20
- data/vendor/sass/vendor/fssm/README.markdown +0 -83
- data/vendor/sass/vendor/fssm/Rakefile +0 -11
- data/vendor/sass/vendor/fssm/example.rb +0 -12
- data/vendor/sass/vendor/fssm/fssm.gemspec +0 -24
- data/vendor/sass/vendor/fssm/lib/fssm.rb +0 -37
- data/vendor/sass/vendor/fssm/lib/fssm/backends/fsevents.rb +0 -36
- data/vendor/sass/vendor/fssm/lib/fssm/backends/inotify.rb +0 -26
- data/vendor/sass/vendor/fssm/lib/fssm/backends/polling.rb +0 -25
- data/vendor/sass/vendor/fssm/lib/fssm/backends/rbfsevent.rb +0 -42
- data/vendor/sass/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +0 -131
- data/vendor/sass/vendor/fssm/lib/fssm/monitor.rb +0 -36
- data/vendor/sass/vendor/fssm/lib/fssm/path.rb +0 -94
- data/vendor/sass/vendor/fssm/lib/fssm/pathname.rb +0 -36
- data/vendor/sass/vendor/fssm/lib/fssm/state/directory.rb +0 -75
- data/vendor/sass/vendor/fssm/lib/fssm/state/file.rb +0 -24
- data/vendor/sass/vendor/fssm/lib/fssm/support.rb +0 -92
- data/vendor/sass/vendor/fssm/lib/fssm/tree.rb +0 -176
- data/vendor/sass/vendor/fssm/lib/fssm/version.rb +0 -3
- data/vendor/sass/vendor/fssm/profile/prof-cache.rb +0 -40
- data/vendor/sass/vendor/fssm/profile/prof-fssm-pathname.html +0 -1231
- data/vendor/sass/vendor/fssm/profile/prof-pathname-rubinius.rb +0 -35
- data/vendor/sass/vendor/fssm/profile/prof-pathname.rb +0 -68
- data/vendor/sass/vendor/fssm/profile/prof-plain-pathname.html +0 -988
- data/vendor/sass/vendor/fssm/profile/prof.html +0 -2379
- data/vendor/sass/vendor/fssm/spec/count_down_latch.rb +0 -151
- data/vendor/sass/vendor/fssm/spec/monitor_spec.rb +0 -202
- data/vendor/sass/vendor/fssm/spec/path_spec.rb +0 -96
- data/vendor/sass/vendor/fssm/spec/root/duck/quack.txt +0 -0
- data/vendor/sass/vendor/fssm/spec/root/file.css +0 -0
- data/vendor/sass/vendor/fssm/spec/root/file.rb +0 -0
- data/vendor/sass/vendor/fssm/spec/root/file.yml +0 -0
- data/vendor/sass/vendor/fssm/spec/root/moo/cow.txt +0 -0
- data/vendor/sass/vendor/fssm/spec/spec_helper.rb +0 -14
- data/vendor/sass/yard/callbacks.rb +0 -29
- data/vendor/sass/yard/default/fulldoc/html/css/common.sass +0 -26
- data/vendor/sass/yard/default/layout/html/footer.erb +0 -12
- data/vendor/sass/yard/inherited_hash.rb +0 -41
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'sass/script/literal'
|
2
|
-
|
3
|
-
module Sass::Script
|
4
|
-
# A SassScript object representing a CSS string *or* a CSS identifier.
|
5
|
-
class String < Literal
|
6
|
-
# The Ruby value of the string.
|
7
|
-
#
|
8
|
-
# @return [String]
|
9
|
-
attr_reader :value
|
10
|
-
|
11
|
-
# Whether this is a CSS string or a CSS identifier.
|
12
|
-
# The difference is that strings are written with double-quotes,
|
13
|
-
# while identifiers aren't.
|
14
|
-
#
|
15
|
-
# @return [Symbol] `:string` or `:identifier`
|
16
|
-
attr_reader :type
|
17
|
-
|
18
|
-
# Creates a new string.
|
19
|
-
#
|
20
|
-
# @param value [String] See \{#value}
|
21
|
-
# @param type [Symbol] See \{#type}
|
22
|
-
def initialize(value, type = :identifier)
|
23
|
-
super(value)
|
24
|
-
@type = type
|
25
|
-
end
|
26
|
-
|
27
|
-
# @see Literal#plus
|
28
|
-
def plus(other)
|
29
|
-
other_str = other.is_a?(Sass::Script::String) ? other.value : other.to_s
|
30
|
-
Sass::Script::String.new(self.value + other_str, self.type)
|
31
|
-
end
|
32
|
-
|
33
|
-
# @see Node#to_s
|
34
|
-
def to_s(opts = {})
|
35
|
-
if @type == :identifier
|
36
|
-
return @value.tr("\n", " ")
|
37
|
-
end
|
38
|
-
|
39
|
-
return "\"#{value.gsub('"', "\\\"")}\"" if opts[:quote] == %q{"}
|
40
|
-
return "'#{value.gsub("'", "\\'")}'" if opts[:quote] == %q{'}
|
41
|
-
return "\"#{value}\"" unless value.include?('"')
|
42
|
-
return "'#{value}'" unless value.include?("'")
|
43
|
-
"\"#{value.gsub('"', "\\\"")}\"" #'
|
44
|
-
end
|
45
|
-
|
46
|
-
# @see Node#to_sass
|
47
|
-
def to_sass(opts = {})
|
48
|
-
to_s
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
module Sass::Script
|
2
|
-
# A SassScript object representing `#{}` interpolation within a string.
|
3
|
-
#
|
4
|
-
# @see Interpolation
|
5
|
-
class StringInterpolation < Node
|
6
|
-
# Interpolation in a string is of the form `"before #{mid} after"`,
|
7
|
-
# where `before` and `after` may include more interpolation.
|
8
|
-
#
|
9
|
-
# @param before [Node] The string before the interpolation
|
10
|
-
# @param mid [Node] The SassScript within the interpolation
|
11
|
-
# @param after [Node] The string after the interpolation
|
12
|
-
def initialize(before, mid, after)
|
13
|
-
@before = before
|
14
|
-
@mid = mid
|
15
|
-
@after = after
|
16
|
-
end
|
17
|
-
|
18
|
-
# @return [String] A human-readable s-expression representation of the interpolation
|
19
|
-
def inspect
|
20
|
-
"(string_interpolation #{@before.inspect} #{@mid.inspect} #{@after.inspect})"
|
21
|
-
end
|
22
|
-
|
23
|
-
# @see Node#to_sass
|
24
|
-
def to_sass(opts = {})
|
25
|
-
# We can get rid of all of this when we remove the deprecated :equals context
|
26
|
-
# XXX CE: It's gone now but I'm not sure what can be removed now.
|
27
|
-
before_unquote, before_quote_char, before_str = parse_str(@before.to_sass(opts))
|
28
|
-
after_unquote, after_quote_char, after_str = parse_str(@after.to_sass(opts))
|
29
|
-
unquote = before_unquote || after_unquote ||
|
30
|
-
(before_quote_char && !after_quote_char && !after_str.empty?) ||
|
31
|
-
(!before_quote_char && after_quote_char && !before_str.empty?)
|
32
|
-
quote_char =
|
33
|
-
if before_quote_char && after_quote_char && before_quote_char != after_quote_char
|
34
|
-
before_str.gsub!("\\'", "'")
|
35
|
-
before_str.gsub!('"', "\\\"")
|
36
|
-
after_str.gsub!("\\'", "'")
|
37
|
-
after_str.gsub!('"', "\\\"")
|
38
|
-
'"'
|
39
|
-
else
|
40
|
-
before_quote_char || after_quote_char
|
41
|
-
end
|
42
|
-
|
43
|
-
res = ""
|
44
|
-
res << 'unquote(' if unquote
|
45
|
-
res << quote_char if quote_char
|
46
|
-
res << before_str
|
47
|
-
res << '#{' << @mid.to_sass(opts) << '}'
|
48
|
-
res << after_str
|
49
|
-
res << quote_char if quote_char
|
50
|
-
res << ')' if unquote
|
51
|
-
res
|
52
|
-
end
|
53
|
-
|
54
|
-
# Returns the three components of the interpolation, `before`, `mid`, and `after`.
|
55
|
-
#
|
56
|
-
# @return [Array<Node>]
|
57
|
-
# @see #initialize
|
58
|
-
# @see Node#children
|
59
|
-
def children
|
60
|
-
[@before, @mid, @after].compact
|
61
|
-
end
|
62
|
-
|
63
|
-
# @see Node#deep_copy
|
64
|
-
def deep_copy
|
65
|
-
node = dup
|
66
|
-
node.instance_variable_set('@before', @before.deep_copy) if @before
|
67
|
-
node.instance_variable_set('@mid', @mid.deep_copy)
|
68
|
-
node.instance_variable_set('@after', @after.deep_copy) if @after
|
69
|
-
node
|
70
|
-
end
|
71
|
-
|
72
|
-
protected
|
73
|
-
|
74
|
-
# Evaluates the interpolation.
|
75
|
-
#
|
76
|
-
# @param environment [Sass::Environment] The environment in which to evaluate the SassScript
|
77
|
-
# @return [Sass::Script::String] The SassScript string that is the value of the interpolation
|
78
|
-
def _perform(environment)
|
79
|
-
res = ""
|
80
|
-
before = @before.perform(environment)
|
81
|
-
res << before.value
|
82
|
-
mid = @mid.perform(environment)
|
83
|
-
res << (mid.is_a?(Sass::Script::String) ? mid.value : mid.to_s)
|
84
|
-
res << @after.perform(environment).value
|
85
|
-
opts(Sass::Script::String.new(res, before.type))
|
86
|
-
end
|
87
|
-
|
88
|
-
private
|
89
|
-
|
90
|
-
def parse_str(str)
|
91
|
-
case str
|
92
|
-
when /^unquote\((["'])(.*)\1\)$/
|
93
|
-
return true, $1, $2
|
94
|
-
when '""'
|
95
|
-
return false, nil, ""
|
96
|
-
when /^(["'])(.*)\1$/
|
97
|
-
return false, $1, $2
|
98
|
-
else
|
99
|
-
return false, nil, str
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
module Sass::Script
|
2
|
-
# A SassScript parse node representing a unary operation,
|
3
|
-
# such as `-$b` or `not true`.
|
4
|
-
#
|
5
|
-
# Currently only `-`, `/`, and `not` are unary operators.
|
6
|
-
class UnaryOperation < Node
|
7
|
-
# @param operand [Script::Node] The parse-tree node
|
8
|
-
# for the object of the operator
|
9
|
-
# @param operator [Symbol] The operator to perform
|
10
|
-
def initialize(operand, operator)
|
11
|
-
@operand = operand
|
12
|
-
@operator = operator
|
13
|
-
super()
|
14
|
-
end
|
15
|
-
|
16
|
-
# @return [String] A human-readable s-expression representation of the operation
|
17
|
-
def inspect
|
18
|
-
"(#{@operator.inspect} #{@operand.inspect})"
|
19
|
-
end
|
20
|
-
|
21
|
-
# @see Node#to_sass
|
22
|
-
def to_sass(opts = {})
|
23
|
-
operand = @operand.to_sass(opts)
|
24
|
-
if @operand.is_a?(Operation) ||
|
25
|
-
(@operator == :minus &&
|
26
|
-
(operand =~ Sass::SCSS::RX::IDENT) == 0)
|
27
|
-
operand = "(#{@operand.to_sass(opts)})"
|
28
|
-
end
|
29
|
-
op = Lexer::OPERATORS_REVERSE[@operator]
|
30
|
-
op + (op =~ /[a-z]/ ? " " : "") + operand
|
31
|
-
end
|
32
|
-
|
33
|
-
# Returns the operand of the operation.
|
34
|
-
#
|
35
|
-
# @return [Array<Node>]
|
36
|
-
# @see Node#children
|
37
|
-
def children
|
38
|
-
[@operand]
|
39
|
-
end
|
40
|
-
|
41
|
-
# @see Node#deep_copy
|
42
|
-
def deep_copy
|
43
|
-
node = dup
|
44
|
-
node.instance_variable_set('@operand', @operand.deep_copy)
|
45
|
-
node
|
46
|
-
end
|
47
|
-
|
48
|
-
protected
|
49
|
-
|
50
|
-
# Evaluates the operation.
|
51
|
-
#
|
52
|
-
# @param environment [Sass::Environment] The environment in which to evaluate the SassScript
|
53
|
-
# @return [Literal] The SassScript object that is the value of the operation
|
54
|
-
# @raise [Sass::SyntaxError] if the operation is undefined for the operand
|
55
|
-
def _perform(environment)
|
56
|
-
operator = "unary_#{@operator}"
|
57
|
-
literal = @operand.perform(environment)
|
58
|
-
literal.send(operator)
|
59
|
-
rescue NoMethodError => e
|
60
|
-
raise e unless e.name.to_s == operator.to_s
|
61
|
-
raise Sass::SyntaxError.new("Undefined unary operation: \"#{@operator} #{literal}\".")
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
module Sass
|
2
|
-
module Script
|
3
|
-
# A SassScript parse node representing a variable.
|
4
|
-
class Variable < Node
|
5
|
-
# The name of the variable.
|
6
|
-
#
|
7
|
-
# @return [String]
|
8
|
-
attr_reader :name
|
9
|
-
|
10
|
-
# The underscored name of the variable.
|
11
|
-
#
|
12
|
-
# @return [String]
|
13
|
-
attr_reader :underscored_name
|
14
|
-
|
15
|
-
# @param name [String] See \{#name}
|
16
|
-
def initialize(name)
|
17
|
-
@name = name
|
18
|
-
@underscored_name = name.gsub(/-/,"_")
|
19
|
-
super()
|
20
|
-
end
|
21
|
-
|
22
|
-
# @return [String] A string representation of the variable
|
23
|
-
def inspect(opts = {})
|
24
|
-
return "!important" if name == "important"
|
25
|
-
"$#{dasherize(name, opts)}"
|
26
|
-
end
|
27
|
-
alias_method :to_sass, :inspect
|
28
|
-
|
29
|
-
# Returns an empty array.
|
30
|
-
#
|
31
|
-
# @return [Array<Node>] empty
|
32
|
-
# @see Node#children
|
33
|
-
def children
|
34
|
-
[]
|
35
|
-
end
|
36
|
-
|
37
|
-
# @see Node#deep_copy
|
38
|
-
def deep_copy
|
39
|
-
dup
|
40
|
-
end
|
41
|
-
|
42
|
-
protected
|
43
|
-
|
44
|
-
# Evaluates the variable.
|
45
|
-
#
|
46
|
-
# @param environment [Sass::Environment] The environment in which to evaluate the SassScript
|
47
|
-
# @return [Literal] The SassScript object that is the value of the variable
|
48
|
-
# @raise [Sass::SyntaxError] if the variable is undefined
|
49
|
-
def _perform(environment)
|
50
|
-
raise SyntaxError.new("Undefined variable: \"$#{name}\".") unless val = environment.var(name)
|
51
|
-
if val.is_a?(Number)
|
52
|
-
val = val.dup
|
53
|
-
val.original = nil
|
54
|
-
end
|
55
|
-
return val
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'sass/scss/rx'
|
2
|
-
require 'sass/scss/script_lexer'
|
3
|
-
require 'sass/scss/script_parser'
|
4
|
-
require 'sass/scss/parser'
|
5
|
-
require 'sass/scss/sass_parser'
|
6
|
-
require 'sass/scss/static_parser'
|
7
|
-
require 'sass/scss/css_parser'
|
8
|
-
|
9
|
-
module Sass
|
10
|
-
# SCSS is the CSS syntax for Sass.
|
11
|
-
# It parses into the same syntax tree as Sass,
|
12
|
-
# and generates the same sort of output CSS.
|
13
|
-
#
|
14
|
-
# This module contains code for the parsing of SCSS.
|
15
|
-
# The evaluation is handled by the broader {Sass} module.
|
16
|
-
module SCSS; end
|
17
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'sass/script/css_parser'
|
2
|
-
|
3
|
-
module Sass
|
4
|
-
module SCSS
|
5
|
-
# This is a subclass of {Parser} which only parses plain CSS.
|
6
|
-
# It doesn't support any Sass extensions, such as interpolation,
|
7
|
-
# parent references, nested selectors, and so forth.
|
8
|
-
# It does support all the same CSS hacks as the SCSS parser, though.
|
9
|
-
class CssParser < StaticParser
|
10
|
-
# Parse a selector, and return its value as a string.
|
11
|
-
#
|
12
|
-
# @return [String, nil] The parsed selector, or nil if no selector was parsed
|
13
|
-
# @raise [Sass::SyntaxError] if there's a syntax error in the selector
|
14
|
-
def parse_selector_string
|
15
|
-
init_scanner!
|
16
|
-
str {return unless selector}
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def parent_selector; nil; end
|
22
|
-
def interpolation; nil; end
|
23
|
-
def interp_string; tok(STRING); end
|
24
|
-
def interp_ident(ident = IDENT); tok(ident); end
|
25
|
-
def use_css_import?; true; end
|
26
|
-
|
27
|
-
def block_child(context)
|
28
|
-
case context
|
29
|
-
when :ruleset
|
30
|
-
declaration
|
31
|
-
when :stylesheet
|
32
|
-
directive || ruleset
|
33
|
-
when :directive
|
34
|
-
directive || declaration_or_ruleset
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def nested_properties!(node, space)
|
39
|
-
expected('expression (e.g. 1px, bold)');
|
40
|
-
end
|
41
|
-
|
42
|
-
@sass_script_parser = Class.new(Sass::Script::CssParser)
|
43
|
-
@sass_script_parser.send(:include, ScriptParser)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,960 +0,0 @@
|
|
1
|
-
require 'strscan'
|
2
|
-
require 'set'
|
3
|
-
|
4
|
-
module Sass
|
5
|
-
module SCSS
|
6
|
-
# The parser for SCSS.
|
7
|
-
# It parses a string of code into a tree of {Sass::Tree::Node}s.
|
8
|
-
class Parser
|
9
|
-
# @param str [String, StringScanner] The source document to parse.
|
10
|
-
# Note that `Parser` *won't* raise a nice error message if this isn't properly parsed;
|
11
|
-
# for that, you should use the higher-level {Sass::Engine} or {Sass::CSS}.
|
12
|
-
# @param filename [String] The name of the file being parsed. Used for warnings.
|
13
|
-
# @param line [Fixnum] The line on which the source string appeared,
|
14
|
-
# if it's part of another document.
|
15
|
-
def initialize(str, filename, line = 1)
|
16
|
-
@template = str
|
17
|
-
@filename = filename
|
18
|
-
@line = line
|
19
|
-
@strs = []
|
20
|
-
end
|
21
|
-
|
22
|
-
# Parses an SCSS document.
|
23
|
-
#
|
24
|
-
# @return [Sass::Tree::RootNode] The root node of the document tree
|
25
|
-
# @raise [Sass::SyntaxError] if there's a syntax error in the document
|
26
|
-
def parse
|
27
|
-
init_scanner!
|
28
|
-
root = stylesheet
|
29
|
-
expected("selector or at-rule") unless @scanner.eos?
|
30
|
-
root
|
31
|
-
end
|
32
|
-
|
33
|
-
# Parses an identifier with interpolation.
|
34
|
-
# Note that this won't assert that the identifier takes up the entire input string;
|
35
|
-
# it's meant to be used with `StringScanner`s as part of other parsers.
|
36
|
-
#
|
37
|
-
# @return [Array<String, Sass::Script::Node>, nil]
|
38
|
-
# The interpolated identifier, or nil if none could be parsed
|
39
|
-
def parse_interp_ident
|
40
|
-
init_scanner!
|
41
|
-
interp_ident
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
include Sass::SCSS::RX
|
47
|
-
|
48
|
-
def init_scanner!
|
49
|
-
@scanner =
|
50
|
-
if @template.is_a?(StringScanner)
|
51
|
-
@template
|
52
|
-
else
|
53
|
-
StringScanner.new(@template.gsub("\r", ""))
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def stylesheet
|
58
|
-
node = node(Sass::Tree::RootNode.new(@scanner.string))
|
59
|
-
block_contents(node, :stylesheet) {s(node)}
|
60
|
-
end
|
61
|
-
|
62
|
-
def s(node)
|
63
|
-
while tok(S) || tok(CDC) || tok(CDO) || (c = tok(SINGLE_LINE_COMMENT)) || (c = tok(COMMENT))
|
64
|
-
next unless c
|
65
|
-
process_comment c, node
|
66
|
-
c = nil
|
67
|
-
end
|
68
|
-
true
|
69
|
-
end
|
70
|
-
|
71
|
-
def ss
|
72
|
-
nil while tok(S) || tok(SINGLE_LINE_COMMENT) || tok(COMMENT)
|
73
|
-
true
|
74
|
-
end
|
75
|
-
|
76
|
-
def ss_comments(node)
|
77
|
-
while tok(S) || (c = tok(SINGLE_LINE_COMMENT)) || (c = tok(COMMENT))
|
78
|
-
next unless c
|
79
|
-
process_comment c, node
|
80
|
-
c = nil
|
81
|
-
end
|
82
|
-
|
83
|
-
true
|
84
|
-
end
|
85
|
-
|
86
|
-
def whitespace
|
87
|
-
return unless tok(S) || tok(SINGLE_LINE_COMMENT) || tok(COMMENT)
|
88
|
-
ss
|
89
|
-
end
|
90
|
-
|
91
|
-
def process_comment(text, node)
|
92
|
-
silent = text =~ /^\/\//
|
93
|
-
line = @line - text.count("\n")
|
94
|
-
if loud = text =~ %r{^/[/*]!}
|
95
|
-
value = Sass::Engine.parse_interp(text, line, @scanner.pos - text.size, :filename => @filename)
|
96
|
-
value[0].slice!(2) # get rid of the "!"
|
97
|
-
else
|
98
|
-
value = [text]
|
99
|
-
end
|
100
|
-
|
101
|
-
if silent
|
102
|
-
value = Sass::Util.with_extracted_values(value) do |str|
|
103
|
-
str.sub(/^\s*\/\//, '/*').gsub(/^\s*\/\//, ' *') + ' */'
|
104
|
-
end
|
105
|
-
else
|
106
|
-
value.unshift(@scanner.
|
107
|
-
string[0...@scanner.pos].
|
108
|
-
reverse[/.*?\*\/(.*?)($|\Z)/, 1].
|
109
|
-
reverse.gsub(/[^\s]/, ' '))
|
110
|
-
end
|
111
|
-
|
112
|
-
comment = Sass::Tree::CommentNode.new(value, silent, loud)
|
113
|
-
comment.line = line
|
114
|
-
node << comment
|
115
|
-
end
|
116
|
-
|
117
|
-
DIRECTIVES = Set[:mixin, :include, :function, :return, :debug, :warn, :for,
|
118
|
-
:each, :while, :if, :else, :extend, :import, :media, :charset]
|
119
|
-
|
120
|
-
def directive
|
121
|
-
return unless tok(/@/)
|
122
|
-
name = tok!(IDENT)
|
123
|
-
ss
|
124
|
-
|
125
|
-
if dir = special_directive(name)
|
126
|
-
return dir
|
127
|
-
end
|
128
|
-
|
129
|
-
# Most at-rules take expressions (e.g. @import),
|
130
|
-
# but some (e.g. @page) take selector-like arguments
|
131
|
-
val = str {break unless expr}
|
132
|
-
val ||= CssParser.new(@scanner, @line).parse_selector_string
|
133
|
-
node = node(Sass::Tree::DirectiveNode.new("@#{name} #{val}".strip))
|
134
|
-
|
135
|
-
if tok(/\{/)
|
136
|
-
node.has_children = true
|
137
|
-
block_contents(node, :directive)
|
138
|
-
tok!(/\}/)
|
139
|
-
end
|
140
|
-
|
141
|
-
node
|
142
|
-
end
|
143
|
-
|
144
|
-
def special_directive(name)
|
145
|
-
sym = name.gsub('-', '_').to_sym
|
146
|
-
DIRECTIVES.include?(sym) && send("#{sym}_directive")
|
147
|
-
end
|
148
|
-
|
149
|
-
def mixin_directive
|
150
|
-
name = tok! IDENT
|
151
|
-
args = sass_script(:parse_mixin_definition_arglist)
|
152
|
-
ss
|
153
|
-
block(node(Sass::Tree::MixinDefNode.new(name, args)), :directive)
|
154
|
-
end
|
155
|
-
|
156
|
-
def include_directive
|
157
|
-
name = tok! IDENT
|
158
|
-
args, keywords = sass_script(:parse_mixin_include_arglist)
|
159
|
-
ss
|
160
|
-
node(Sass::Tree::MixinNode.new(name, args, keywords))
|
161
|
-
end
|
162
|
-
|
163
|
-
def function_directive
|
164
|
-
name = tok! IDENT
|
165
|
-
args = sass_script(:parse_function_definition_arglist)
|
166
|
-
ss
|
167
|
-
block(node(Sass::Tree::FunctionNode.new(name, args)), :function)
|
168
|
-
end
|
169
|
-
|
170
|
-
def return_directive
|
171
|
-
node(Sass::Tree::ReturnNode.new(sass_script(:parse)))
|
172
|
-
end
|
173
|
-
|
174
|
-
def debug_directive
|
175
|
-
node(Sass::Tree::DebugNode.new(sass_script(:parse)))
|
176
|
-
end
|
177
|
-
|
178
|
-
def warn_directive
|
179
|
-
node(Sass::Tree::WarnNode.new(sass_script(:parse)))
|
180
|
-
end
|
181
|
-
|
182
|
-
def for_directive
|
183
|
-
tok!(/\$/)
|
184
|
-
var = tok! IDENT
|
185
|
-
ss
|
186
|
-
|
187
|
-
tok!(/from/)
|
188
|
-
from = sass_script(:parse_until, Set["to", "through"])
|
189
|
-
ss
|
190
|
-
|
191
|
-
@expected = '"to" or "through"'
|
192
|
-
exclusive = (tok(/to/) || tok!(/through/)) == 'to'
|
193
|
-
to = sass_script(:parse)
|
194
|
-
ss
|
195
|
-
|
196
|
-
block(node(Sass::Tree::ForNode.new(var, from, to, exclusive)), :directive)
|
197
|
-
end
|
198
|
-
|
199
|
-
def each_directive
|
200
|
-
tok!(/\$/)
|
201
|
-
var = tok! IDENT
|
202
|
-
ss
|
203
|
-
|
204
|
-
tok!(/in/)
|
205
|
-
list = sass_script(:parse)
|
206
|
-
ss
|
207
|
-
|
208
|
-
block(node(Sass::Tree::EachNode.new(var, list)), :directive)
|
209
|
-
end
|
210
|
-
|
211
|
-
def while_directive
|
212
|
-
expr = sass_script(:parse)
|
213
|
-
ss
|
214
|
-
block(node(Sass::Tree::WhileNode.new(expr)), :directive)
|
215
|
-
end
|
216
|
-
|
217
|
-
def if_directive
|
218
|
-
expr = sass_script(:parse)
|
219
|
-
ss
|
220
|
-
node = block(node(Sass::Tree::IfNode.new(expr)), :directive)
|
221
|
-
pos = @scanner.pos
|
222
|
-
line = @line
|
223
|
-
ss
|
224
|
-
|
225
|
-
else_block(node) ||
|
226
|
-
begin
|
227
|
-
# Backtrack in case there are any comments we want to parse
|
228
|
-
@scanner.pos = pos
|
229
|
-
@line = line
|
230
|
-
node
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
def else_block(node)
|
235
|
-
return unless tok(/@else/)
|
236
|
-
ss
|
237
|
-
else_node = block(
|
238
|
-
Sass::Tree::IfNode.new((sass_script(:parse) if tok(/if/))),
|
239
|
-
:directive)
|
240
|
-
node.add_else(else_node)
|
241
|
-
pos = @scanner.pos
|
242
|
-
line = @line
|
243
|
-
ss
|
244
|
-
|
245
|
-
else_block(node) ||
|
246
|
-
begin
|
247
|
-
# Backtrack in case there are any comments we want to parse
|
248
|
-
@scanner.pos = pos
|
249
|
-
@line = line
|
250
|
-
node
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
def else_directive
|
255
|
-
err("Invalid CSS: @else must come after @if")
|
256
|
-
end
|
257
|
-
|
258
|
-
def extend_directive
|
259
|
-
node(Sass::Tree::ExtendNode.new(expr!(:selector)))
|
260
|
-
end
|
261
|
-
|
262
|
-
def import_directive
|
263
|
-
values = []
|
264
|
-
|
265
|
-
loop do
|
266
|
-
values << expr!(:import_arg)
|
267
|
-
break if use_css_import? || !tok(/,\s*/)
|
268
|
-
end
|
269
|
-
|
270
|
-
return values
|
271
|
-
end
|
272
|
-
|
273
|
-
def import_arg
|
274
|
-
return unless arg = tok(STRING) || (uri = tok!(URI))
|
275
|
-
path = @scanner[1] || @scanner[2] || @scanner[3]
|
276
|
-
ss
|
277
|
-
|
278
|
-
media = str {media_query_list}.strip
|
279
|
-
|
280
|
-
if uri || path =~ /^http:\/\// || !media.strip.empty? || use_css_import?
|
281
|
-
return node(Sass::Tree::DirectiveNode.new("@import #{arg} #{media}".strip))
|
282
|
-
end
|
283
|
-
|
284
|
-
node(Sass::Tree::ImportNode.new(path.strip))
|
285
|
-
end
|
286
|
-
|
287
|
-
def use_css_import?; false; end
|
288
|
-
|
289
|
-
def media_directive
|
290
|
-
val = str {media_query_list}.strip
|
291
|
-
block(node(Sass::Tree::MediaNode.new(val)), :directive)
|
292
|
-
end
|
293
|
-
|
294
|
-
# http://www.w3.org/TR/css3-mediaqueries/#syntax
|
295
|
-
def media_query_list
|
296
|
-
return unless media_query
|
297
|
-
|
298
|
-
ss
|
299
|
-
while tok(/,/)
|
300
|
-
ss; expr!(:media_query); ss
|
301
|
-
end
|
302
|
-
|
303
|
-
true
|
304
|
-
end
|
305
|
-
|
306
|
-
def media_query
|
307
|
-
if tok(/only|not/i)
|
308
|
-
ss
|
309
|
-
@expected = "media type (e.g. print, screen)"
|
310
|
-
tok!(IDENT)
|
311
|
-
ss
|
312
|
-
elsif !tok(IDENT) && !media_expr
|
313
|
-
return
|
314
|
-
end
|
315
|
-
|
316
|
-
ss
|
317
|
-
while tok(/and/i)
|
318
|
-
ss; expr!(:media_expr); ss
|
319
|
-
end
|
320
|
-
|
321
|
-
true
|
322
|
-
end
|
323
|
-
|
324
|
-
def media_expr
|
325
|
-
return unless tok(/\(/)
|
326
|
-
ss
|
327
|
-
@expected = "media feature (e.g. min-device-width, color)"
|
328
|
-
tok!(IDENT)
|
329
|
-
ss
|
330
|
-
|
331
|
-
if tok(/:/)
|
332
|
-
ss; expr!(:expr)
|
333
|
-
end
|
334
|
-
tok!(/\)/)
|
335
|
-
ss
|
336
|
-
|
337
|
-
true
|
338
|
-
end
|
339
|
-
|
340
|
-
def charset_directive
|
341
|
-
tok! STRING
|
342
|
-
name = @scanner[1] || @scanner[2]
|
343
|
-
ss
|
344
|
-
node(Sass::Tree::CharsetNode.new(name))
|
345
|
-
end
|
346
|
-
|
347
|
-
def variable
|
348
|
-
return unless tok(/\$/)
|
349
|
-
name = tok!(IDENT)
|
350
|
-
ss; tok!(/:/); ss
|
351
|
-
|
352
|
-
expr = sass_script(:parse)
|
353
|
-
guarded = tok(DEFAULT)
|
354
|
-
node(Sass::Tree::VariableNode.new(name, expr, guarded))
|
355
|
-
end
|
356
|
-
|
357
|
-
def operator
|
358
|
-
# Many of these operators (all except / and ,)
|
359
|
-
# are disallowed by the CSS spec,
|
360
|
-
# but they're included here for compatibility
|
361
|
-
# with some proprietary MS properties
|
362
|
-
str {ss if tok(/[\/,:.=]/)}
|
363
|
-
end
|
364
|
-
|
365
|
-
def unary_operator
|
366
|
-
tok(/[+-]/)
|
367
|
-
end
|
368
|
-
|
369
|
-
def ruleset
|
370
|
-
return unless rules = selector_sequence
|
371
|
-
block(node(Sass::Tree::RuleNode.new(rules.flatten.compact)), :ruleset)
|
372
|
-
end
|
373
|
-
|
374
|
-
def block(node, context)
|
375
|
-
node.has_children = true
|
376
|
-
tok!(/\{/)
|
377
|
-
block_contents(node, context)
|
378
|
-
tok!(/\}/)
|
379
|
-
node
|
380
|
-
end
|
381
|
-
|
382
|
-
# A block may contain declarations and/or rulesets
|
383
|
-
def block_contents(node, context)
|
384
|
-
block_given? ? yield : ss_comments(node)
|
385
|
-
node << (child = block_child(context))
|
386
|
-
while tok(/;/) || has_children?(child)
|
387
|
-
block_given? ? yield : ss_comments(node)
|
388
|
-
node << (child = block_child(context))
|
389
|
-
end
|
390
|
-
node
|
391
|
-
end
|
392
|
-
|
393
|
-
def block_child(context)
|
394
|
-
return variable || directive if context == :function
|
395
|
-
return variable || directive || ruleset if context == :stylesheet
|
396
|
-
variable || directive || declaration_or_ruleset
|
397
|
-
end
|
398
|
-
|
399
|
-
def has_children?(child_or_array)
|
400
|
-
return false unless child_or_array
|
401
|
-
return child_or_array.last.has_children if child_or_array.is_a?(Array)
|
402
|
-
return child_or_array.has_children
|
403
|
-
end
|
404
|
-
|
405
|
-
# This is a nasty hack, and the only place in the parser
|
406
|
-
# that requires backtracking.
|
407
|
-
# The reason is that we can't figure out if certain strings
|
408
|
-
# are declarations or rulesets with fixed finite lookahead.
|
409
|
-
# For example, "foo:bar baz baz baz..." could be either a property
|
410
|
-
# or a selector.
|
411
|
-
#
|
412
|
-
# To handle this, we simply check if it works as a property
|
413
|
-
# (which is the most common case)
|
414
|
-
# and, if it doesn't, try it as a ruleset.
|
415
|
-
#
|
416
|
-
# We could eke some more efficiency out of this
|
417
|
-
# by handling some easy cases (first token isn't an identifier,
|
418
|
-
# no colon after the identifier, whitespace after the colon),
|
419
|
-
# but I'm not sure the gains would be worth the added complexity.
|
420
|
-
def declaration_or_ruleset
|
421
|
-
old_use_property_exception, @use_property_exception =
|
422
|
-
@use_property_exception, false
|
423
|
-
decl_err = catch_error do
|
424
|
-
decl = declaration
|
425
|
-
unless decl && decl.has_children
|
426
|
-
# We want an exception if it's not there,
|
427
|
-
# but we don't want to consume if it is
|
428
|
-
tok!(/[;}]/) unless tok?(/[;}]/)
|
429
|
-
end
|
430
|
-
return decl
|
431
|
-
end
|
432
|
-
|
433
|
-
ruleset_err = catch_error {return ruleset}
|
434
|
-
rethrow(@use_property_exception ? decl_err : ruleset_err)
|
435
|
-
ensure
|
436
|
-
@use_property_exception = old_use_property_exception
|
437
|
-
end
|
438
|
-
|
439
|
-
def selector_sequence
|
440
|
-
if sel = tok(STATIC_SELECTOR)
|
441
|
-
return [sel]
|
442
|
-
end
|
443
|
-
|
444
|
-
rules = []
|
445
|
-
return unless v = selector
|
446
|
-
rules.concat v
|
447
|
-
|
448
|
-
ws = ''
|
449
|
-
while tok(/,/)
|
450
|
-
ws << str {ss}
|
451
|
-
if v = selector
|
452
|
-
rules << ',' << ws
|
453
|
-
rules.concat v
|
454
|
-
ws = ''
|
455
|
-
end
|
456
|
-
end
|
457
|
-
rules
|
458
|
-
end
|
459
|
-
|
460
|
-
def selector
|
461
|
-
return unless sel = _selector
|
462
|
-
sel.to_a
|
463
|
-
end
|
464
|
-
|
465
|
-
def selector_comma_sequence
|
466
|
-
return unless sel = _selector
|
467
|
-
selectors = [sel]
|
468
|
-
ws = ''
|
469
|
-
while tok(/,/)
|
470
|
-
ws << str{ss}
|
471
|
-
if sel = _selector
|
472
|
-
selectors << sel
|
473
|
-
selectors[-1] = Selector::Sequence.new(["\n"] + selectors.last.members) if ws.include?("\n")
|
474
|
-
ws = ''
|
475
|
-
end
|
476
|
-
end
|
477
|
-
Selector::CommaSequence.new(selectors)
|
478
|
-
end
|
479
|
-
|
480
|
-
def _selector
|
481
|
-
# The combinator here allows the "> E" hack
|
482
|
-
return unless val = combinator || simple_selector_sequence
|
483
|
-
nl = str{ss}.include?("\n")
|
484
|
-
res = []
|
485
|
-
res << val
|
486
|
-
res << "\n" if nl
|
487
|
-
|
488
|
-
while val = combinator || simple_selector_sequence
|
489
|
-
res << val
|
490
|
-
res << "\n" if str{ss}.include?("\n")
|
491
|
-
end
|
492
|
-
Selector::Sequence.new(res.compact)
|
493
|
-
end
|
494
|
-
|
495
|
-
def combinator
|
496
|
-
tok(PLUS) || tok(GREATER) || tok(TILDE)
|
497
|
-
end
|
498
|
-
|
499
|
-
def simple_selector_sequence
|
500
|
-
# This allows for stuff like http://www.w3.org/TR/css3-animations/#keyframes-
|
501
|
-
return expr unless e = element_name || id_selector || class_selector ||
|
502
|
-
attrib || negation || pseudo || parent_selector || interpolation_selector
|
503
|
-
res = [e]
|
504
|
-
|
505
|
-
# The tok(/\*/) allows the "E*" hack
|
506
|
-
while v = id_selector || class_selector || attrib || negation || pseudo ||
|
507
|
-
interpolation_selector || (tok(/\*/) && Selector::Universal.new(nil))
|
508
|
-
res << v
|
509
|
-
end
|
510
|
-
|
511
|
-
pos = @scanner.pos
|
512
|
-
line = @line
|
513
|
-
if sel = str? {simple_selector_sequence}
|
514
|
-
@scanner.pos = pos
|
515
|
-
@line = line
|
516
|
-
|
517
|
-
if sel =~ /^&/
|
518
|
-
begin
|
519
|
-
throw_error {expected('"{"')}
|
520
|
-
rescue Sass::SyntaxError => e
|
521
|
-
e.message << "\n\n\"#{sel}\" may only be used at the beginning of a selector."
|
522
|
-
raise e
|
523
|
-
end
|
524
|
-
else
|
525
|
-
Sass::Util.sass_warn(<<MESSAGE)
|
526
|
-
DEPRECATION WARNING:
|
527
|
-
On line #{@line}#{" of \"#{@filename}\"" if @filename}, after "#{self.class.prior_snippet(@scanner)}"
|
528
|
-
Starting in Sass 3.2, "#{sel}" may only be used at the beginning of a selector.
|
529
|
-
MESSAGE
|
530
|
-
end
|
531
|
-
end
|
532
|
-
|
533
|
-
Selector::SimpleSequence.new(res)
|
534
|
-
end
|
535
|
-
|
536
|
-
def parent_selector
|
537
|
-
return unless tok(/&/)
|
538
|
-
Selector::Parent.new
|
539
|
-
end
|
540
|
-
|
541
|
-
def class_selector
|
542
|
-
return unless tok(/\./)
|
543
|
-
@expected = "class name"
|
544
|
-
Selector::Class.new(merge(expr!(:interp_ident)))
|
545
|
-
end
|
546
|
-
|
547
|
-
def id_selector
|
548
|
-
return unless tok(/#(?!\{)/)
|
549
|
-
@expected = "id name"
|
550
|
-
Selector::Id.new(merge(expr!(:interp_name)))
|
551
|
-
end
|
552
|
-
|
553
|
-
def element_name
|
554
|
-
return unless name = interp_ident || tok(/\*/) || (tok?(/\|/) && "")
|
555
|
-
if tok(/\|/)
|
556
|
-
@expected = "element name or *"
|
557
|
-
ns = name
|
558
|
-
name = interp_ident || tok!(/\*/)
|
559
|
-
end
|
560
|
-
|
561
|
-
if name == '*'
|
562
|
-
Selector::Universal.new(merge(ns))
|
563
|
-
else
|
564
|
-
Selector::Element.new(merge(name), merge(ns))
|
565
|
-
end
|
566
|
-
end
|
567
|
-
|
568
|
-
def interpolation_selector
|
569
|
-
return unless script = interpolation
|
570
|
-
Selector::Interpolation.new(script)
|
571
|
-
end
|
572
|
-
|
573
|
-
def attrib
|
574
|
-
return unless tok(/\[/)
|
575
|
-
ss
|
576
|
-
ns, name = attrib_name!
|
577
|
-
ss
|
578
|
-
|
579
|
-
if op = tok(/=/) ||
|
580
|
-
tok(INCLUDES) ||
|
581
|
-
tok(DASHMATCH) ||
|
582
|
-
tok(PREFIXMATCH) ||
|
583
|
-
tok(SUFFIXMATCH) ||
|
584
|
-
tok(SUBSTRINGMATCH)
|
585
|
-
@expected = "identifier or string"
|
586
|
-
ss
|
587
|
-
if val = tok(IDENT)
|
588
|
-
val = [val]
|
589
|
-
else
|
590
|
-
val = expr!(:interp_string)
|
591
|
-
end
|
592
|
-
ss
|
593
|
-
end
|
594
|
-
tok(/\]/)
|
595
|
-
|
596
|
-
Selector::Attribute.new(merge(name), merge(ns), op, merge(val))
|
597
|
-
end
|
598
|
-
|
599
|
-
def attrib_name!
|
600
|
-
if name_or_ns = interp_ident
|
601
|
-
# E, E|E
|
602
|
-
if tok(/\|(?!=)/)
|
603
|
-
ns = name_or_ns
|
604
|
-
name = interp_ident
|
605
|
-
else
|
606
|
-
name = name_or_ns
|
607
|
-
end
|
608
|
-
else
|
609
|
-
# *|E or |E
|
610
|
-
ns = [tok(/\*/) || ""]
|
611
|
-
tok!(/\|/)
|
612
|
-
name = expr!(:interp_ident)
|
613
|
-
end
|
614
|
-
return ns, name
|
615
|
-
end
|
616
|
-
|
617
|
-
def pseudo
|
618
|
-
return unless s = tok(/::?/)
|
619
|
-
@expected = "pseudoclass or pseudoelement"
|
620
|
-
name = expr!(:interp_ident)
|
621
|
-
if tok(/\(/)
|
622
|
-
ss
|
623
|
-
arg = expr!(:pseudo_expr)
|
624
|
-
tok!(/\)/)
|
625
|
-
end
|
626
|
-
Selector::Pseudo.new(s == ':' ? :class : :element, merge(name), merge(arg))
|
627
|
-
end
|
628
|
-
|
629
|
-
def pseudo_expr
|
630
|
-
return unless e = tok(PLUS) || tok(/-/) || tok(NUMBER) ||
|
631
|
-
interp_string || tok(IDENT) || interpolation
|
632
|
-
res = [e, str{ss}]
|
633
|
-
while e = tok(PLUS) || tok(/-/) || tok(NUMBER) ||
|
634
|
-
interp_string || tok(IDENT) || interpolation
|
635
|
-
res << e << str{ss}
|
636
|
-
end
|
637
|
-
res
|
638
|
-
end
|
639
|
-
|
640
|
-
def negation
|
641
|
-
return unless name = tok(NOT) || tok(MOZ_ANY)
|
642
|
-
ss
|
643
|
-
@expected = "selector"
|
644
|
-
sel = selector_comma_sequence
|
645
|
-
tok!(/\)/)
|
646
|
-
Selector::SelectorPseudoClass.new(name[1...-1], sel)
|
647
|
-
end
|
648
|
-
|
649
|
-
def declaration
|
650
|
-
# This allows the "*prop: val", ":prop: val", and ".prop: val" hacks
|
651
|
-
if s = tok(/[:\*\.]|\#(?!\{)/)
|
652
|
-
@use_property_exception = s !~ /[\.\#]/
|
653
|
-
name = [s, str{ss}, *expr!(:interp_ident)]
|
654
|
-
else
|
655
|
-
return unless name = interp_ident
|
656
|
-
name = [name] if name.is_a?(String)
|
657
|
-
end
|
658
|
-
if comment = tok(COMMENT)
|
659
|
-
name << comment
|
660
|
-
end
|
661
|
-
ss
|
662
|
-
|
663
|
-
tok!(/:/)
|
664
|
-
space, value = value!
|
665
|
-
ss
|
666
|
-
require_block = tok?(/\{/)
|
667
|
-
|
668
|
-
node = node(Sass::Tree::PropNode.new(name.flatten.compact, value, :new))
|
669
|
-
|
670
|
-
return node unless require_block
|
671
|
-
nested_properties! node, space
|
672
|
-
end
|
673
|
-
|
674
|
-
def value!
|
675
|
-
space = !str {ss}.empty?
|
676
|
-
@use_property_exception ||= space || !tok?(IDENT)
|
677
|
-
|
678
|
-
return true, Sass::Script::String.new("") if tok?(/\{/)
|
679
|
-
# This is a bit of a dirty trick:
|
680
|
-
# if the value is completely static,
|
681
|
-
# we don't parse it at all, and instead return a plain old string
|
682
|
-
# containing the value.
|
683
|
-
# This results in a dramatic speed increase.
|
684
|
-
if val = tok(STATIC_VALUE)
|
685
|
-
return space, Sass::Script::String.new(val.strip)
|
686
|
-
end
|
687
|
-
return space, sass_script(:parse)
|
688
|
-
end
|
689
|
-
|
690
|
-
def plain_value
|
691
|
-
return unless tok(/:/)
|
692
|
-
space = !str {ss}.empty?
|
693
|
-
@use_property_exception ||= space || !tok?(IDENT)
|
694
|
-
|
695
|
-
expression = expr
|
696
|
-
expression << tok(IMPORTANT) if expression
|
697
|
-
# expression, space, value
|
698
|
-
return expression, space, expression || [""]
|
699
|
-
end
|
700
|
-
|
701
|
-
def nested_properties!(node, space)
|
702
|
-
err(<<MESSAGE) unless space
|
703
|
-
Invalid CSS: a space is required between a property and its definition
|
704
|
-
when it has other properties nested beneath it.
|
705
|
-
MESSAGE
|
706
|
-
|
707
|
-
@use_property_exception = true
|
708
|
-
@expected = 'expression (e.g. 1px, bold) or "{"'
|
709
|
-
block(node, :property)
|
710
|
-
end
|
711
|
-
|
712
|
-
def expr
|
713
|
-
return unless t = term
|
714
|
-
res = [t, str{ss}]
|
715
|
-
|
716
|
-
while (o = operator) && (t = term)
|
717
|
-
res << o << t << str{ss}
|
718
|
-
end
|
719
|
-
|
720
|
-
res
|
721
|
-
end
|
722
|
-
|
723
|
-
def term
|
724
|
-
unless e = tok(NUMBER) ||
|
725
|
-
tok(URI) ||
|
726
|
-
function ||
|
727
|
-
tok(STRING) ||
|
728
|
-
tok(UNICODERANGE) ||
|
729
|
-
tok(IDENT) ||
|
730
|
-
tok(HEXCOLOR)
|
731
|
-
|
732
|
-
return unless op = unary_operator
|
733
|
-
@expected = "number or function"
|
734
|
-
return [op, tok(NUMBER) || expr!(:function)]
|
735
|
-
end
|
736
|
-
e
|
737
|
-
end
|
738
|
-
|
739
|
-
def function
|
740
|
-
return unless name = tok(FUNCTION)
|
741
|
-
if name == "expression(" || name == "calc("
|
742
|
-
str, _ = Sass::Shared.balance(@scanner, ?(, ?), 1)
|
743
|
-
[name, str]
|
744
|
-
else
|
745
|
-
[name, str{ss}, expr, tok!(/\)/)]
|
746
|
-
end
|
747
|
-
end
|
748
|
-
|
749
|
-
def interpolation
|
750
|
-
return unless tok(INTERP_START)
|
751
|
-
sass_script(:parse_interpolated)
|
752
|
-
end
|
753
|
-
|
754
|
-
def interp_string
|
755
|
-
_interp_string(:double) || _interp_string(:single)
|
756
|
-
end
|
757
|
-
|
758
|
-
def _interp_string(type)
|
759
|
-
return unless start = tok(Sass::Script::Lexer::STRING_REGULAR_EXPRESSIONS[[type, false]])
|
760
|
-
res = [start]
|
761
|
-
|
762
|
-
mid_re = Sass::Script::Lexer::STRING_REGULAR_EXPRESSIONS[[type, true]]
|
763
|
-
# @scanner[2].empty? means we've started an interpolated section
|
764
|
-
while @scanner[2] == '#{'
|
765
|
-
@scanner.pos -= 2 # Don't consume the #{
|
766
|
-
res.last.slice!(-2..-1)
|
767
|
-
res << expr!(:interpolation) << tok(mid_re)
|
768
|
-
end
|
769
|
-
res
|
770
|
-
end
|
771
|
-
|
772
|
-
def interp_ident(start = IDENT)
|
773
|
-
return unless val = tok(start) || interpolation || tok(IDENT_HYPHEN_INTERP)
|
774
|
-
res = [val]
|
775
|
-
while val = tok(NAME) || interpolation
|
776
|
-
res << val
|
777
|
-
end
|
778
|
-
res
|
779
|
-
end
|
780
|
-
|
781
|
-
def interp_name
|
782
|
-
interp_ident NAME
|
783
|
-
end
|
784
|
-
|
785
|
-
def str
|
786
|
-
@strs.push ""
|
787
|
-
yield
|
788
|
-
@strs.last
|
789
|
-
ensure
|
790
|
-
@strs.pop
|
791
|
-
end
|
792
|
-
|
793
|
-
def str?(&block)
|
794
|
-
pos = @scanner.pos
|
795
|
-
line = @line
|
796
|
-
@strs.push ""
|
797
|
-
throw_error(&block) && @strs.last
|
798
|
-
rescue Sass::SyntaxError => e
|
799
|
-
@scanner.pos = pos
|
800
|
-
@line = line
|
801
|
-
nil
|
802
|
-
ensure
|
803
|
-
@strs.pop
|
804
|
-
end
|
805
|
-
|
806
|
-
def node(node)
|
807
|
-
node.line = @line
|
808
|
-
node
|
809
|
-
end
|
810
|
-
|
811
|
-
@sass_script_parser = Class.new(Sass::Script::Parser)
|
812
|
-
@sass_script_parser.send(:include, ScriptParser)
|
813
|
-
# @private
|
814
|
-
def self.sass_script_parser; @sass_script_parser; end
|
815
|
-
|
816
|
-
def sass_script(*args)
|
817
|
-
parser = self.class.sass_script_parser.new(@scanner, @line,
|
818
|
-
@scanner.pos - (@scanner.string[0...@scanner.pos].rindex("\n") || 0))
|
819
|
-
result = parser.send(*args)
|
820
|
-
@line = parser.line
|
821
|
-
result
|
822
|
-
rescue Sass::SyntaxError => e
|
823
|
-
throw(:_sass_parser_error, true) if @throw_error
|
824
|
-
raise e
|
825
|
-
end
|
826
|
-
|
827
|
-
def merge(arr)
|
828
|
-
arr && Sass::Util.merge_adjacent_strings([arr].flatten)
|
829
|
-
end
|
830
|
-
|
831
|
-
EXPR_NAMES = {
|
832
|
-
:media_query => "media query (e.g. print, screen, print and screen)",
|
833
|
-
:media_expr => "media expression (e.g. (min-device-width: 800px)))",
|
834
|
-
:pseudo_expr => "expression (e.g. fr, 2n+1)",
|
835
|
-
:interp_ident => "identifier",
|
836
|
-
:interp_name => "identifier",
|
837
|
-
:expr => "expression (e.g. 1px, bold)",
|
838
|
-
:_selector => "selector",
|
839
|
-
:selector_comma_sequence => "selector",
|
840
|
-
:simple_selector_sequence => "selector",
|
841
|
-
:import_arg => "file to import (string or url())",
|
842
|
-
}
|
843
|
-
|
844
|
-
TOK_NAMES = Sass::Util.to_hash(
|
845
|
-
Sass::SCSS::RX.constants.map {|c| [Sass::SCSS::RX.const_get(c), c.downcase]}).
|
846
|
-
merge(IDENT => "identifier", /[;}]/ => '";"')
|
847
|
-
|
848
|
-
def tok?(rx)
|
849
|
-
@scanner.match?(rx)
|
850
|
-
end
|
851
|
-
|
852
|
-
def expr!(name)
|
853
|
-
(e = send(name)) && (return e)
|
854
|
-
expected(EXPR_NAMES[name] || name.to_s)
|
855
|
-
end
|
856
|
-
|
857
|
-
def tok!(rx)
|
858
|
-
(t = tok(rx)) && (return t)
|
859
|
-
name = TOK_NAMES[rx]
|
860
|
-
|
861
|
-
unless name
|
862
|
-
# Display basic regexps as plain old strings
|
863
|
-
string = rx.source.gsub(/\\(.)/, '\1')
|
864
|
-
name = rx.source == Regexp.escape(string) ? string.inspect : rx.inspect
|
865
|
-
end
|
866
|
-
|
867
|
-
expected(name)
|
868
|
-
end
|
869
|
-
|
870
|
-
def expected(name)
|
871
|
-
throw(:_sass_parser_error, true) if @throw_error
|
872
|
-
self.class.expected(@scanner, @expected || name, @line)
|
873
|
-
end
|
874
|
-
|
875
|
-
def err(msg)
|
876
|
-
throw(:_sass_parser_error, true) if @throw_error
|
877
|
-
raise Sass::SyntaxError.new(msg, :line => @line)
|
878
|
-
end
|
879
|
-
|
880
|
-
def throw_error
|
881
|
-
old_throw_error, @throw_error = @throw_error, false
|
882
|
-
yield
|
883
|
-
ensure
|
884
|
-
@throw_error = old_throw_error
|
885
|
-
end
|
886
|
-
|
887
|
-
def catch_error(&block)
|
888
|
-
old_throw_error, @throw_error = @throw_error, true
|
889
|
-
pos = @scanner.pos
|
890
|
-
line = @line
|
891
|
-
expected = @expected
|
892
|
-
if catch(:_sass_parser_error, &block)
|
893
|
-
@scanner.pos = pos
|
894
|
-
@line = line
|
895
|
-
@expected = expected
|
896
|
-
{:pos => pos, :line => line, :expected => @expected, :block => block}
|
897
|
-
end
|
898
|
-
ensure
|
899
|
-
@throw_error = old_throw_error
|
900
|
-
end
|
901
|
-
|
902
|
-
def rethrow(err)
|
903
|
-
if @throw_err
|
904
|
-
throw :_sass_parser_error, err
|
905
|
-
else
|
906
|
-
@scanner = StringScanner.new(@scanner.string)
|
907
|
-
@scanner.pos = err[:pos]
|
908
|
-
@line = err[:line]
|
909
|
-
@expected = err[:expected]
|
910
|
-
err[:block].call
|
911
|
-
end
|
912
|
-
end
|
913
|
-
|
914
|
-
# @private
|
915
|
-
def self.expected(scanner, expected, line)
|
916
|
-
was = scanner.rest.dup
|
917
|
-
# Get rid of whitespace between pos and the next token,
|
918
|
-
# but only if there's a newline in there
|
919
|
-
was.gsub!(/^\s*\n\s*/, '')
|
920
|
-
# Also get rid of stuff after the next newline
|
921
|
-
was.gsub!(/\n.*/, '')
|
922
|
-
was = was[0...15] + "..." if was.size > 18
|
923
|
-
|
924
|
-
raise Sass::SyntaxError.new(
|
925
|
-
"Invalid CSS after \"#{prior_snippet(scanner)}\": expected #{expected}, was \"#{was}\"",
|
926
|
-
:line => line)
|
927
|
-
end
|
928
|
-
|
929
|
-
# @private
|
930
|
-
def self.prior_snippet(scanner)
|
931
|
-
pos = scanner.pos
|
932
|
-
|
933
|
-
after = scanner.string[0...pos]
|
934
|
-
# Get rid of whitespace between pos and the last token,
|
935
|
-
# but only if there's a newline in there
|
936
|
-
after.gsub!(/\s*\n\s*$/, '')
|
937
|
-
# Also get rid of stuff before the last newline
|
938
|
-
after.gsub!(/.*\n/, '')
|
939
|
-
after = "..." + after[-15..-1] if after.size > 18
|
940
|
-
after
|
941
|
-
end
|
942
|
-
|
943
|
-
# Avoid allocating lots of new strings for `#tok`.
|
944
|
-
# This is important because `#tok` is called all the time.
|
945
|
-
NEWLINE = "\n"
|
946
|
-
|
947
|
-
def tok(rx)
|
948
|
-
res = @scanner.scan(rx)
|
949
|
-
if res
|
950
|
-
@line += res.count(NEWLINE)
|
951
|
-
@expected = nil
|
952
|
-
if !@strs.empty? && rx != COMMENT && rx != SINGLE_LINE_COMMENT
|
953
|
-
@strs.each {|s| s << res}
|
954
|
-
end
|
955
|
-
res
|
956
|
-
end
|
957
|
-
end
|
958
|
-
end
|
959
|
-
end
|
960
|
-
end
|