Skip to content

Commit

Permalink
Add wrap flag to text languages
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Oct 7, 2012
1 parent 9e9500d commit ebd6077
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/linguist/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ def initialize(attributes = {})
raise(ArgumentError, "#{@name} is missing lexer")

@ace_mode = attributes[:ace_mode]
@wrap = attributes[:wrap] || false

# Set legacy search term
@search_term = attributes[:search_term] || default_alias_name
Expand Down Expand Up @@ -312,6 +313,11 @@ def initialize(attributes = {})
# Returns a String name or nil
attr_reader :ace_mode

# Public: Should language lines be wrapped
#
# Returns true or false
attr_reader :wrap

# Public: Get extensions
#
# Examples
Expand Down Expand Up @@ -462,6 +468,7 @@ def inspect
:aliases => options['aliases'],
:lexer => options['lexer'],
:ace_mode => options['ace_mode'],
:wrap => options['wrap'],
:group_name => options['group'],
:searchable => options.key?('searchable') ? options['searchable'] : true,
:search_term => options['search_term'],
Expand Down
4 changes: 4 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# aliases - An Array of additional aliases (implicitly
# includes name.downcase)
# ace_mode - A String name of Ace Mode (if available)
# wrap - Boolean wrap to enable line wrapping (default: false)
# extension - An Array of associated extensions
# primary_extension - A String for the main extension associated with
# the language. Must be unique. Used when a Language is picked
Expand Down Expand Up @@ -741,6 +742,7 @@ Markdown:
type: markup
lexer: Text only
ace_mode: markdown
wrap: true
primary_extension: .md
extensions:
- .markdown
Expand Down Expand Up @@ -1188,6 +1190,7 @@ Textile:
type: markup
lexer: Text only
ace_mode: textile
wrap: true
primary_extension: .textile
extensions:
- .textile
Expand Down Expand Up @@ -1332,6 +1335,7 @@ ooc:

reStructuredText:
type: markup
wrap: true
search_term: rst
aliases:
- rst
Expand Down
5 changes: 5 additions & 0 deletions test/test_language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@ def test_ace_modes
assert !Language.ace_modes.include?(Language['FORTRAN'])
end

def test_wrap
assert_equal false, Language['C'].wrap
assert_equal true, Language['Markdown'].wrap
end

def test_extensions
assert Language['Perl'].extensions.include?('.pl')
assert Language['Python'].extensions.include?('.py')
Expand Down

0 comments on commit ebd6077

Please sign in to comment.