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

Merge branch 'master' into fssm

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

View file

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

View file

@ -252,7 +252,7 @@ begin
list.exclude('lib/haml/template/*.rb')
list.exclude('lib/haml/helpers/action_view_mods.rb')
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
files = FileList.new('doc-src/*').to_a.sort_by {|s| s.size} + %w[MIT-LICENSE VERSION]
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.
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'
# 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>"
#
# # 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.
# For example:

View file

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

View file

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

View file

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

View file

@ -77,45 +77,57 @@ module Sass
end
# The character that begins a CSS property.
# @private
PROPERTY_CHAR = ?:
# The character that designates that
# a property should be assigned to a SassScript expression.
# @private
SCRIPT_CHAR = ?=
# The character that designates the beginning of a comment,
# either Sass or CSS.
# @private
COMMENT_CHAR = ?/
# The character that follows the general COMMENT_CHAR and designates a Sass comment,
# which is not output as a CSS comment.
# @private
SASS_COMMENT_CHAR = ?/
# The character that follows the general COMMENT_CHAR and designates a CSS comment,
# which is embedded in the CSS document.
# @private
CSS_COMMENT_CHAR = ?*
# The character used to denote a compiler directive.
# @private
DIRECTIVE_CHAR = ?@
# Designates a non-parsed rule.
# @private
ESCAPE_CHAR = ?\\
# Designates block as mixin definition rather than CSS rules to output
# @private
MIXIN_DEFINITION_CHAR = ?=
# Includes named mixin declared using MIXIN_DEFINITION_CHAR
# @private
MIXIN_INCLUDE_CHAR = ?+
# The regex that matches properties of the form `name: prop`.
# @private
PROPERTY_NEW_MATCHER = /^[^\s:"\[]+\s*[=:](\s|$)/
# The regex that matches and extracts data from
# properties of the form `name: prop`.
# @private
PROPERTY_NEW = /^([^\s=:"]+)(\s*=|:)(?:\s+|$)(.*)/
# The regex that matches and extracts data from
# properties of the form `:name prop`.
# @private
PROPERTY_OLD = /^:([^\s=:"]+)\s*(=?)(?:\s+|$)(.*)/
# 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.
module Script
# The character that begins a variable.
# @private
VARIABLE_CHAR = ?!
# The regular expression used to parse variables.
# @private
MATCH = /^!([a-zA-Z_]\w*)\s*((?:\|\|)?=)\s*(.+)/
# The regular expression used to validate variables without matching.
# @private
VALIDATE = /^![a-zA-Z_]\w*$/
# Parses a string of SassScript

View file

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

View file

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

View file

@ -351,7 +351,9 @@ module Sass::Script
end
# 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}
# @private
CONVERSION_TABLE = [[ 1, 2.54, 6, 25.4, 72 ], # in
[ nil, 1, 2.36220473, 10, 28.3464567], # cm
[ nil, nil, 1, 4.23333333, 12 ], # pc

View file

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