1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Merge branch 'stable'

This commit is contained in:
Nathan Weizenbaum 2010-01-17 17:50:07 -08:00
commit f663eb664b
13 changed files with 61 additions and 7 deletions

View file

@ -1,5 +1,8 @@
--readme README.md --readme README.md
--markup markdown --markup markdown
--markup-provider maruku --markup-provider maruku
--default-return ""
--hide-void-return
--protected --protected
--no-private
--no-highlight --no-highlight

View file

@ -239,7 +239,7 @@ begin
list.exclude('lib/haml/template/*.rb') list.exclude('lib/haml/template/*.rb')
list.exclude('lib/haml/helpers/action_view_mods.rb') list.exclude('lib/haml/helpers/action_view_mods.rb')
end.to_a end.to_a
t.options << '--use-cache' if Rake.application.top_level_tasks.include?('redoc') t.options << '--incremental' if Rake.application.top_level_tasks.include?('redoc')
t.options += FileList.new('yard/*.rb').to_a.map {|f| ['-e', f]}.flatten t.options += FileList.new('yard/*.rb').to_a.map {|f| ['-e', f]}.flatten
files = FileList.new('doc-src/*').to_a.sort_by {|s| s.size} + %w[MIT-LICENSE VERSION] files = FileList.new('doc-src/*').to_a.sort_by {|s| s.size} + %w[MIT-LICENSE VERSION]
t.options << '--files' << files.join(',') t.options << '--files' << files.join(',')

View file

@ -22,7 +22,7 @@ HAML_GEMSPEC = Gem::Specification.new do |spec|
but it can function as a stand-alone templating engine. but it can function as a stand-alone templating engine.
END END
spec.add_development_dependency 'yard', '>= 0.4.0' spec.add_development_dependency 'yard', '>= 0.5.3'
spec.add_development_dependency 'maruku', '>= 0.5.9' spec.add_development_dependency 'maruku', '>= 0.5.9'
# We need the revision file to exist, # We need the revision file to exist,

View file

@ -138,7 +138,7 @@ module Haml
# Haml::Engine.new("%p= upcase").render(s) #=> "<p>FOOBAR</p>" # Haml::Engine.new("%p= upcase").render(s) #=> "<p>FOOBAR</p>"
# #
# # s now extends Haml::Helpers # # s now extends Haml::Helpers
# s.responds_to?(:html_attrs) #=> true # s.respond_to?(:html_attrs) #=> true
# #
# `locals` is a hash of local variables to make available to the template. # `locals` is a hash of local variables to make available to the template.
# For example: # For example:

View file

@ -457,6 +457,7 @@ MESSAGE
end end
# Characters that need to be escaped to HTML entities from user input # Characters that need to be escaped to HTML entities from user input
# @private
HTML_ESCAPE = { '&'=>'&amp;', '<'=>'&lt;', '>'=>'&gt;', '"'=>'&quot;', "'"=>'&#039;', } HTML_ESCAPE = { '&'=>'&amp;', '<'=>'&lt;', '>'=>'&gt;', '"'=>'&quot;', "'"=>'&#039;', }
# Returns a copy of `text` with ampersands, angle brackets and quotes # Returns a copy of `text` with ampersands, angle brackets and quotes

View file

@ -85,6 +85,7 @@ end
# Haml monkeypatches various Hpricot classes # Haml monkeypatches various Hpricot classes
# to add methods for conversion to Haml. # to add methods for conversion to Haml.
# @private
module Hpricot module Hpricot
# @see Hpricot # @see Hpricot
module Node module Node
@ -145,9 +146,11 @@ module Haml
end end
alias_method :to_haml, :render alias_method :to_haml, :render
# @private
TEXT_REGEXP = /^(\s*).*$/ TEXT_REGEXP = /^(\s*).*$/
# @see Hpricot # @see Hpricot
# @private
class ::Hpricot::Doc class ::Hpricot::Doc
# @see Haml::HTML::Node#to_haml # @see Haml::HTML::Node#to_haml
def to_haml(tabs, options) def to_haml(tabs, options)
@ -156,6 +159,7 @@ module Haml
end end
# @see Hpricot # @see Hpricot
# @private
class ::Hpricot::XMLDecl class ::Hpricot::XMLDecl
# @see Haml::HTML::Node#to_haml # @see Haml::HTML::Node#to_haml
def to_haml(tabs, options) def to_haml(tabs, options)
@ -164,6 +168,7 @@ module Haml
end end
# @see Hpricot # @see Hpricot
# @private
class ::Hpricot::CData class ::Hpricot::CData
# @see Haml::HTML::Node#to_haml # @see Haml::HTML::Node#to_haml
def to_haml(tabs, options) def to_haml(tabs, options)
@ -174,6 +179,7 @@ module Haml
end end
# @see Hpricot # @see Hpricot
# @private
class ::Hpricot::DocType class ::Hpricot::DocType
# @see Haml::HTML::Node#to_haml # @see Haml::HTML::Node#to_haml
def to_haml(tabs, options) def to_haml(tabs, options)
@ -203,6 +209,7 @@ module Haml
end end
# @see Hpricot # @see Hpricot
# @private
class ::Hpricot::Comment class ::Hpricot::Comment
# @see Haml::HTML::Node#to_haml # @see Haml::HTML::Node#to_haml
def to_haml(tabs, options) def to_haml(tabs, options)
@ -221,6 +228,7 @@ module Haml
end end
# @see Hpricot # @see Hpricot
# @private
class ::Hpricot::Elem class ::Hpricot::Elem
# @see Haml::HTML::Node#to_haml # @see Haml::HTML::Node#to_haml
def to_haml(tabs, options) def to_haml(tabs, options)

View file

@ -8,46 +8,60 @@ module Haml
include Haml::Util include Haml::Util
# Designates an XHTML/XML element. # Designates an XHTML/XML element.
# @private
ELEMENT = ?% ELEMENT = ?%
# Designates a `<div>` element with the given class. # Designates a `<div>` element with the given class.
# @private
DIV_CLASS = ?. DIV_CLASS = ?.
# Designates a `<div>` element with the given id. # Designates a `<div>` element with the given id.
# @private
DIV_ID = ?# DIV_ID = ?#
# Designates an XHTML/XML comment. # Designates an XHTML/XML comment.
# @private
COMMENT = ?/ COMMENT = ?/
# Designates an XHTML doctype or script that is never HTML-escaped. # Designates an XHTML doctype or script that is never HTML-escaped.
# @private
DOCTYPE = ?! DOCTYPE = ?!
# Designates script, the result of which is output. # Designates script, the result of which is output.
# @private
SCRIPT = ?= SCRIPT = ?=
# Designates script that is always HTML-escaped. # Designates script that is always HTML-escaped.
# @private
SANITIZE = ?& SANITIZE = ?&
# Designates script, the result of which is flattened and output. # Designates script, the result of which is flattened and output.
# @private
FLAT_SCRIPT = ?~ FLAT_SCRIPT = ?~
# Designates script which is run but not output. # Designates script which is run but not output.
# @private
SILENT_SCRIPT = ?- SILENT_SCRIPT = ?-
# When following SILENT_SCRIPT, designates a comment that is not output. # When following SILENT_SCRIPT, designates a comment that is not output.
# @private
SILENT_COMMENT = ?# SILENT_COMMENT = ?#
# Designates a non-parsed line. # Designates a non-parsed line.
# @private
ESCAPE = ?\\ ESCAPE = ?\\
# Designates a block of filtered text. # Designates a block of filtered text.
# @private
FILTER = ?: FILTER = ?:
# Designates a non-parsed line. Not actually a character. # Designates a non-parsed line. Not actually a character.
# @private
PLAIN_TEXT = -1 PLAIN_TEXT = -1
# Keeps track of the ASCII values of the characters that begin a # Keeps track of the ASCII values of the characters that begin a
# specially-interpreted line. # specially-interpreted line.
# @private
SPECIAL_CHARACTERS = [ SPECIAL_CHARACTERS = [
ELEMENT, ELEMENT,
DIV_CLASS, DIV_CLASS,
@ -64,6 +78,7 @@ module Haml
# The value of the character that designates that a line is part # The value of the character that designates that a line is part
# of a multiline string. # of a multiline string.
# @private
MULTILINE_CHAR_VALUE = ?| MULTILINE_CHAR_VALUE = ?|
# Regex to match keywords that appear in the middle of a Ruby block # Regex to match keywords that appear in the middle of a Ruby block
@ -79,12 +94,15 @@ module Haml
# #
# The block is ended after `%p no!`, because `else` # The block is ended after `%p no!`, because `else`
# is a member of this array. # is a member of this array.
# @private
MID_BLOCK_KEYWORD_REGEX = /^-\s*(#{%w[else elsif rescue ensure when end].join('|')})\b/ MID_BLOCK_KEYWORD_REGEX = /^-\s*(#{%w[else elsif rescue ensure when end].join('|')})\b/
# The Regex that matches a Doctype command. # The Regex that matches a Doctype command.
# @private
DOCTYPE_REGEX = /(\d(?:\.\d)?)?[\s]*([a-z]*)/i DOCTYPE_REGEX = /(\d(?:\.\d)?)?[\s]*([a-z]*)/i
# The Regex that matches a literal string or symbol value # The Regex that matches a literal string or symbol value
# @private
LITERAL_VALUE_REGEX = /:(\w*)|(["'])((?![\\#]|\2).|\\.)*\2/ LITERAL_VALUE_REGEX = /:(\w*)|(["'])((?![\\#]|\2).|\\.)*\2/
private private
@ -124,6 +142,7 @@ END
end.join(';') + ';' end.join(';') + ';'
end end
# @private
class Line < Struct.new(:text, :unstripped, :full, :index, :precompiler, :eod) class Line < Struct.new(:text, :unstripped, :full, :index, :precompiler, :eod)
alias_method :eod?, :eod alias_method :eod?, :eod

View file

@ -77,45 +77,57 @@ module Sass
end end
# The character that begins a CSS property. # The character that begins a CSS property.
# @private
PROPERTY_CHAR = ?: PROPERTY_CHAR = ?:
# The character that designates that # The character that designates that
# a property should be assigned to a SassScript expression. # a property should be assigned to a SassScript expression.
# @private
SCRIPT_CHAR = ?= SCRIPT_CHAR = ?=
# The character that designates the beginning of a comment, # The character that designates the beginning of a comment,
# either Sass or CSS. # either Sass or CSS.
# @private
COMMENT_CHAR = ?/ COMMENT_CHAR = ?/
# The character that follows the general COMMENT_CHAR and designates a Sass comment, # The character that follows the general COMMENT_CHAR and designates a Sass comment,
# which is not output as a CSS comment. # which is not output as a CSS comment.
# @private
SASS_COMMENT_CHAR = ?/ SASS_COMMENT_CHAR = ?/
# The character that follows the general COMMENT_CHAR and designates a CSS comment, # The character that follows the general COMMENT_CHAR and designates a CSS comment,
# which is embedded in the CSS document. # which is embedded in the CSS document.
# @private
CSS_COMMENT_CHAR = ?* CSS_COMMENT_CHAR = ?*
# The character used to denote a compiler directive. # The character used to denote a compiler directive.
# @private
DIRECTIVE_CHAR = ?@ DIRECTIVE_CHAR = ?@
# Designates a non-parsed rule. # Designates a non-parsed rule.
# @private
ESCAPE_CHAR = ?\\ ESCAPE_CHAR = ?\\
# Designates block as mixin definition rather than CSS rules to output # Designates block as mixin definition rather than CSS rules to output
# @private
MIXIN_DEFINITION_CHAR = ?= MIXIN_DEFINITION_CHAR = ?=
# Includes named mixin declared using MIXIN_DEFINITION_CHAR # Includes named mixin declared using MIXIN_DEFINITION_CHAR
# @private
MIXIN_INCLUDE_CHAR = ?+ MIXIN_INCLUDE_CHAR = ?+
# The regex that matches properties of the form `name: prop`. # The regex that matches properties of the form `name: prop`.
# @private
PROPERTY_NEW_MATCHER = /^[^\s:"\[]+\s*[=:](\s|$)/ PROPERTY_NEW_MATCHER = /^[^\s:"\[]+\s*[=:](\s|$)/
# The regex that matches and extracts data from # The regex that matches and extracts data from
# properties of the form `name: prop`. # properties of the form `name: prop`.
# @private
PROPERTY_NEW = /^([^\s=:"]+)(\s*=|:)(?:\s+|$)(.*)/ PROPERTY_NEW = /^([^\s=:"]+)(\s*=|:)(?:\s+|$)(.*)/
# The regex that matches and extracts data from # The regex that matches and extracts data from
# properties of the form `:name prop`. # properties of the form `:name prop`.
# @private
PROPERTY_OLD = /^:([^\s=:"]+)\s*(=?)(?:\s+|$)(.*)/ PROPERTY_OLD = /^:([^\s=:"]+)\s*(=?)(?:\s+|$)(.*)/
# The default options for Sass::Engine. # The default options for Sass::Engine.

View file

@ -13,12 +13,15 @@ module Sass
# This module contains code that handles the parsing and evaluation of SassScript. # This module contains code that handles the parsing and evaluation of SassScript.
module Script module Script
# The character that begins a variable. # The character that begins a variable.
# @private
VARIABLE_CHAR = ?! VARIABLE_CHAR = ?!
# The regular expression used to parse variables. # The regular expression used to parse variables.
# @private
MATCH = /^!([a-zA-Z_]\w*)\s*((?:\|\|)?=)\s*(.+)/ MATCH = /^!([a-zA-Z_]\w*)\s*((?:\|\|)?=)\s*(.+)/
# The regular expression used to validate variables without matching. # The regular expression used to validate variables without matching.
# @private
VALIDATE = /^![a-zA-Z_]\w*$/ VALIDATE = /^![a-zA-Z_]\w*$/
# Parses a string of SassScript # Parses a string of SassScript

View file

@ -19,6 +19,7 @@ module Sass::Script
class << self; include Haml::Util; end class << self; include Haml::Util; end
# A hash from color names to `[red, green, blue]` value arrays. # A hash from color names to `[red, green, blue]` value arrays.
# @private
HTML4_COLORS = map_vals({ HTML4_COLORS = map_vals({
'black' => 0x000000, 'black' => 0x000000,
'silver' => 0xc0c0c0, 'silver' => 0xc0c0c0,
@ -38,6 +39,7 @@ module Sass::Script
'aqua' => 0x00ffff 'aqua' => 0x00ffff
}) {|color| (0..2).map {|n| color >> (n << 3) & 0xff}.reverse} }) {|color| (0..2).map {|n| color >> (n << 3) & 0xff}.reverse}
# A hash from `[red, green, blue]` value arrays to color names. # A hash from `[red, green, blue]` value arrays to color names.
# @private
HTML4_COLORS_REVERSE = map_hash(HTML4_COLORS) {|k, v| [v, k]} HTML4_COLORS_REVERSE = map_hash(HTML4_COLORS) {|k, v| [v, k]}
# Constructs an RGB or HSL color object, # Constructs an RGB or HSL color object,

View file

@ -8,20 +8,21 @@ module Sass
class Lexer class Lexer
# A struct containing information about an individual token. # A struct containing information about an individual token.
# #
# `type`: \[{Symbol}\] # `type`: \[`Symbol`\]
# : The type of token. # : The type of token.
# #
# `value`: \[{Object}\] # `value`: \[`Object`\]
# : The Ruby object corresponding to the value of the token. # : The Ruby object corresponding to the value of the token.
# #
# `line`: \[{Fixnum}\] # `line`: \[`Fixnum`\]
# : The line of the source file on which the token appears. # : The line of the source file on which the token appears.
# #
# `offset`: \[{Fixnum}\] # `offset`: \[`Fixnum`\]
# : The number of bytes into the line the SassScript token appeared. # : The number of bytes into the line the SassScript token appeared.
Token = Struct.new(:type, :value, :line, :offset) Token = Struct.new(:type, :value, :line, :offset)
# A hash from operator strings to the corresponding token types. # A hash from operator strings to the corresponding token types.
# @private
OPERATORS = { OPERATORS = {
'+' => :plus, '+' => :plus,
'-' => :minus, '-' => :minus,
@ -47,9 +48,11 @@ module Sass
# A list of operator strings ordered with longer names first # A list of operator strings ordered with longer names first
# so that `>` and `<` don't clobber `>=` and `<=`. # so that `>` and `<` don't clobber `>=` and `<=`.
# @private
OP_NAMES = OPERATORS.keys.sort_by {|o| -o.size} OP_NAMES = OPERATORS.keys.sort_by {|o| -o.size}
# A hash of regular expressions that are used for tokenizing. # A hash of regular expressions that are used for tokenizing.
# @private
REGULAR_EXPRESSIONS = { REGULAR_EXPRESSIONS = {
:whitespace => /\s*/, :whitespace => /\s*/,
:variable => /!([\w-]+)/, :variable => /!([\w-]+)/,

View file

@ -351,7 +351,9 @@ module Sass::Script
end end
# A hash of unit names to their index in the conversion table # A hash of unit names to their index in the conversion table
# @private
CONVERTABLE_UNITS = {"in" => 0, "cm" => 1, "pc" => 2, "mm" => 3, "pt" => 4} CONVERTABLE_UNITS = {"in" => 0, "cm" => 1, "pc" => 2, "mm" => 3, "pt" => 4}
# @private
CONVERSION_TABLE = [[ 1, 2.54, 6, 25.4, 72 ], # in CONVERSION_TABLE = [[ 1, 2.54, 6, 25.4, 72 ], # in
[ nil, 1, 2.36220473, 10, 28.3464567], # cm [ nil, 1, 2.36220473, 10, 28.3464567], # cm
[ nil, nil, 1, 4.23333333, 12 ], # pc [ nil, nil, 1, 4.23333333, 12 ], # pc

View file

@ -6,6 +6,7 @@ module Sass::Tree
# @see Sass::Tree # @see Sass::Tree
class RuleNode < Node class RuleNode < Node
# The character used to include the parent selector # The character used to include the parent selector
# @private
PARENT = '&' PARENT = '&'
# The CSS selectors for this rule. # The CSS selectors for this rule.