redcar-html 1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/README.md +14 -0
  2. data/lib/html.rb +46 -0
  3. data/plugin.rb +9 -0
  4. metadata +48 -0
data/README.md ADDED
@@ -0,0 +1,14 @@
1
+ #_RedCar HTML Plugin_
2
+
3
+ ## About
4
+ Adds some helpful HTML commands and shortcuts for editing HTML documents.
5
+
6
+ ## Installation
7
+ cd ~/.redcar/plugins
8
+ git clone http://github.com/agmcleod/redcar-html.git html
9
+
10
+ ### Usage
11
+ Wrap multiple lines as a list:
12
+
13
+ - Select lines you wish to wrap
14
+ - Ctrl+Shift+L
data/lib/html.rb ADDED
@@ -0,0 +1,46 @@
1
+ module Redcar
2
+ class Html
3
+ def self.menus
4
+ Redcar::Menu::Builder.build do
5
+ sub_menu "Plugins" do
6
+ sub_menu "Html" do
7
+ item "Convert to List", ConvertToList
8
+ end
9
+ end
10
+ end
11
+ end
12
+
13
+ def self.keymaps
14
+ map = Redcar::Keymap.build("main", [:osx, :linux, :windows]) do
15
+ link "Ctrl+Shift+L", ConvertToList
16
+ end
17
+ [map]
18
+ end
19
+
20
+ class ConvertToList < Redcar::EditTabCommand
21
+ def execute
22
+ if doc.selection?
23
+ text = doc.selected_text
24
+ lines = text.split(/\n/)
25
+ lines.collect! do |c|
26
+ wrapped = wrap_text_in_white_space(c) { |t| "<li>#{t}</li>" }
27
+ p "Wrapped: |#{wrapped}|"
28
+ wrapped
29
+ end
30
+ doc.replace_selection(lines.join("\n"))
31
+ end
32
+ end
33
+
34
+ def wrap_text_in_white_space(text, &wrap_with)
35
+ r = /^[\t\s]+/
36
+ if r =~ text
37
+ partitions = text.partition(r)
38
+ wrapped = yield(partitions[2])
39
+ "#{partitions[1]}#{wrapped}"
40
+ else
41
+ yield(text)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
data/plugin.rb ADDED
@@ -0,0 +1,9 @@
1
+ Plugin.define do
2
+ name "HTML"
3
+ version "0.1"
4
+ file "lib", "html.rb"
5
+ object "Redcar::Html"
6
+ dependencies "core", ">0",
7
+ "application",">0",
8
+ "edit_view" ,">0"
9
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redcar-html
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Aaron McLeod
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-17 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: ''
15
+ email:
16
+ - aaron.g.mcleod@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/html.rb
22
+ - README.md
23
+ - plugin.rb
24
+ homepage: http://github.com/agmcleod/redcar-html
25
+ licenses: []
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 1.8.7
45
+ signing_key:
46
+ specification_version: 3
47
+ summary: A plugin for redcar that gives useful html commands and snippets
48
+ test_files: []