minisyntax 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +7 -0
- data/README.md +40 -0
- data/Rakefile +52 -0
- data/lib/minisyntax.rb +35 -0
- data/spec/minisyntax_spec.rb +7 -0
- data/spec/spec_helper.rb +12 -0
- metadata +111 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# MiniSyntax
|
2
|
+
|
3
|
+
A simple and powerful syntax highlighter for Ruby. It uses `<em>`, `<b>`, `<q>`, … instead of `<span class="keyword">` to reduce the HTML output. It preferes to keep it simple over having a color for every detail of a language as its major usecase is enhancing blog posts.
|
4
|
+
|
5
|
+
Have a look at those blog posts and inspect the HTML of the source code sections:
|
6
|
+
|
7
|
+
* <http://www.hagenburger.net/BLOG/HTML5-Input-Placeholder-Fix-With-jQuery.html>
|
8
|
+
* <http://www.hagenburger.net/BLOG/3d-Github-badge-with-pure-CSS3.html>
|
9
|
+
* <http://www.hagenburger.net/BLOG/Simple-HTML5-Fix-for-IE.html>
|
10
|
+
|
11
|
+
|
12
|
+
## Supported Languages
|
13
|
+
|
14
|
+
* command_line
|
15
|
+
* css
|
16
|
+
* erb
|
17
|
+
* haml (with embedded ruby)
|
18
|
+
* html (with embedded javascript)
|
19
|
+
* javascript
|
20
|
+
* php
|
21
|
+
* ruby
|
22
|
+
* yaml
|
23
|
+
|
24
|
+
|
25
|
+
## Contributing to MiniSyntax
|
26
|
+
|
27
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
28
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
29
|
+
* Fork the project
|
30
|
+
* Start a feature/bugfix branch
|
31
|
+
* Commit and push until you are happy with your contribution
|
32
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
33
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
34
|
+
|
35
|
+
|
36
|
+
## Copyright
|
37
|
+
|
38
|
+
Copyright (c) 2010 [Nico Hagenburger](http://www.hagenburger.net). See MIT-LICENSE.txt for
|
39
|
+
further details.
|
40
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
$: << File.join(File.dirname(__FILE__), 'lib')
|
14
|
+
require 'minisyntax'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
gem.version = '0.1.0'
|
17
|
+
gem.name = "minisyntax"
|
18
|
+
gem.homepage = "http://github.com/hagenburger/minisyntax"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{A simple powerful syntax highlighter with minimal HTML output}
|
21
|
+
gem.description = %Q{A simple powerful syntax highlighter with minimal HTML output}
|
22
|
+
gem.email = "nico@hagenburger.net"
|
23
|
+
gem.authors = ["Nico Hagenburger"]
|
24
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
25
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
26
|
+
gem.add_runtime_dependency 'nokogiri', '~> 1.4.4'
|
27
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
28
|
+
end
|
29
|
+
Jeweler::RubygemsDotOrgTasks.new
|
30
|
+
|
31
|
+
require 'rspec/core'
|
32
|
+
require 'rspec/core/rake_task'
|
33
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
34
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
35
|
+
end
|
36
|
+
|
37
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
38
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
39
|
+
spec.rcov = true
|
40
|
+
end
|
41
|
+
|
42
|
+
task :default => :spec
|
43
|
+
|
44
|
+
require 'rake/rdoctask'
|
45
|
+
Rake::RDocTask.new do |rdoc|
|
46
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
47
|
+
|
48
|
+
rdoc.rdoc_dir = 'rdoc'
|
49
|
+
rdoc.title = "minisyntax #{version}"
|
50
|
+
rdoc.rdoc_files.include('README*')
|
51
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
52
|
+
end
|
data/lib/minisyntax.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module MiniSyntax
|
2
|
+
module Version
|
3
|
+
MAJOR = 0
|
4
|
+
MINOR = 1
|
5
|
+
PATCH = 0
|
6
|
+
BUILD = ''
|
7
|
+
|
8
|
+
STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
|
9
|
+
end
|
10
|
+
|
11
|
+
@@languages = {}
|
12
|
+
|
13
|
+
def self.register(lang, lang_module)
|
14
|
+
@@languages[lang] = lang_module
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.highlight(code, lang)
|
18
|
+
if highlighter = @@languages[lang.to_sym]
|
19
|
+
highlighter.highlight(code)
|
20
|
+
elsif lang.is_a?(String)
|
21
|
+
lang.split(/\s*\+\s*/).each do |lang|
|
22
|
+
code = highlight(code, lang.strip.to_sym)
|
23
|
+
end
|
24
|
+
code
|
25
|
+
else
|
26
|
+
code
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
require 'minisyntax/highlighter'
|
32
|
+
|
33
|
+
if defined? Rack
|
34
|
+
require 'minisyntax/integration/rack'
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'minisyntax'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minisyntax
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Nico Hagenburger
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2010-12-30 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70318166847640 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.3.0
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70318166847640
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: bundler
|
27
|
+
requirement: &70318166847160 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70318166847160
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: jeweler
|
38
|
+
requirement: &70318166846680 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.5.2
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70318166846680
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rcov
|
49
|
+
requirement: &70318166846200 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70318166846200
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: nokogiri
|
60
|
+
requirement: &70318166845720 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.4.4
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70318166845720
|
69
|
+
description: A simple powerful syntax highlighter with minimal HTML output
|
70
|
+
email: nico@hagenburger.net
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files:
|
74
|
+
- README.md
|
75
|
+
files:
|
76
|
+
- .document
|
77
|
+
- .rspec
|
78
|
+
- Gemfile
|
79
|
+
- Rakefile
|
80
|
+
- lib/minisyntax.rb
|
81
|
+
- spec/minisyntax_spec.rb
|
82
|
+
- spec/spec_helper.rb
|
83
|
+
- README.md
|
84
|
+
homepage: http://github.com/hagenburger/minisyntax
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 1.8.10
|
106
|
+
signing_key:
|
107
|
+
specification_version: 3
|
108
|
+
summary: A simple powerful syntax highlighter with minimal HTML output
|
109
|
+
test_files:
|
110
|
+
- spec/minisyntax_spec.rb
|
111
|
+
- spec/spec_helper.rb
|