mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-08 20:38:47 +00:00
Add wrap flag to text languages
This commit is contained in:
@@ -222,6 +222,7 @@ module Linguist
|
|||||||
raise(ArgumentError, "#{@name} is missing lexer")
|
raise(ArgumentError, "#{@name} is missing lexer")
|
||||||
|
|
||||||
@ace_mode = attributes[:ace_mode]
|
@ace_mode = attributes[:ace_mode]
|
||||||
|
@wrap = attributes[:wrap] || false
|
||||||
|
|
||||||
# Set legacy search term
|
# Set legacy search term
|
||||||
@search_term = attributes[:search_term] || default_alias_name
|
@search_term = attributes[:search_term] || default_alias_name
|
||||||
@@ -312,6 +313,11 @@ module Linguist
|
|||||||
# Returns a String name or nil
|
# Returns a String name or nil
|
||||||
attr_reader :ace_mode
|
attr_reader :ace_mode
|
||||||
|
|
||||||
|
# Public: Should language lines be wrapped
|
||||||
|
#
|
||||||
|
# Returns true or false
|
||||||
|
attr_reader :wrap
|
||||||
|
|
||||||
# Public: Get extensions
|
# Public: Get extensions
|
||||||
#
|
#
|
||||||
# Examples
|
# Examples
|
||||||
@@ -462,6 +468,7 @@ module Linguist
|
|||||||
:aliases => options['aliases'],
|
:aliases => options['aliases'],
|
||||||
:lexer => options['lexer'],
|
:lexer => options['lexer'],
|
||||||
:ace_mode => options['ace_mode'],
|
:ace_mode => options['ace_mode'],
|
||||||
|
:wrap => options['wrap'],
|
||||||
:group_name => options['group'],
|
:group_name => options['group'],
|
||||||
:searchable => options.key?('searchable') ? options['searchable'] : true,
|
:searchable => options.key?('searchable') ? options['searchable'] : true,
|
||||||
:search_term => options['search_term'],
|
:search_term => options['search_term'],
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
# aliases - An Array of additional aliases (implicitly
|
# aliases - An Array of additional aliases (implicitly
|
||||||
# includes name.downcase)
|
# includes name.downcase)
|
||||||
# ace_mode - A String name of Ace Mode (if available)
|
# 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
|
# extension - An Array of associated extensions
|
||||||
# primary_extension - A String for the main extension associated with
|
# primary_extension - A String for the main extension associated with
|
||||||
# the language. Must be unique. Used when a Language is picked
|
# the language. Must be unique. Used when a Language is picked
|
||||||
@@ -741,6 +742,7 @@ Markdown:
|
|||||||
type: markup
|
type: markup
|
||||||
lexer: Text only
|
lexer: Text only
|
||||||
ace_mode: markdown
|
ace_mode: markdown
|
||||||
|
wrap: true
|
||||||
primary_extension: .md
|
primary_extension: .md
|
||||||
extensions:
|
extensions:
|
||||||
- .markdown
|
- .markdown
|
||||||
@@ -1188,6 +1190,7 @@ Textile:
|
|||||||
type: markup
|
type: markup
|
||||||
lexer: Text only
|
lexer: Text only
|
||||||
ace_mode: textile
|
ace_mode: textile
|
||||||
|
wrap: true
|
||||||
primary_extension: .textile
|
primary_extension: .textile
|
||||||
extensions:
|
extensions:
|
||||||
- .textile
|
- .textile
|
||||||
@@ -1332,6 +1335,7 @@ ooc:
|
|||||||
|
|
||||||
reStructuredText:
|
reStructuredText:
|
||||||
type: markup
|
type: markup
|
||||||
|
wrap: true
|
||||||
search_term: rst
|
search_term: rst
|
||||||
aliases:
|
aliases:
|
||||||
- rst
|
- rst
|
||||||
|
|||||||
@@ -286,6 +286,11 @@ class TestLanguage < Test::Unit::TestCase
|
|||||||
assert !Language.ace_modes.include?(Language['FORTRAN'])
|
assert !Language.ace_modes.include?(Language['FORTRAN'])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_wrap
|
||||||
|
assert_equal false, Language['C'].wrap
|
||||||
|
assert_equal true, Language['Markdown'].wrap
|
||||||
|
end
|
||||||
|
|
||||||
def test_extensions
|
def test_extensions
|
||||||
assert Language['Perl'].extensions.include?('.pl')
|
assert Language['Perl'].extensions.include?('.pl')
|
||||||
assert Language['Python'].extensions.include?('.py')
|
assert Language['Python'].extensions.include?('.py')
|
||||||
|
|||||||
Reference in New Issue
Block a user