majek 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +18 -0
- data/LICENSE +22 -0
- data/README.md +33 -0
- data/Rakefile +6 -0
- data/bin/majek +7 -0
- data/lib/majek.rb +5 -0
- data/lib/majek/application.rb +26 -0
- data/lib/majek/version.rb +3 -0
- data/lib/md_inc/octopress_commands.rb +52 -0
- data/majek.gemspec +21 -0
- metadata +97 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Mathias Lafeldt
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
Majek
|
2
|
+
=====
|
3
|
+
|
4
|
+
Tool to convert Markdown to Jekyll post format
|
5
|
+
|
6
|
+
|
7
|
+
Installation
|
8
|
+
------------
|
9
|
+
|
10
|
+
TODO
|
11
|
+
|
12
|
+
|
13
|
+
Usage
|
14
|
+
-----
|
15
|
+
|
16
|
+
usage: majek <markdown file>
|
17
|
+
|
18
|
+
|
19
|
+
License
|
20
|
+
-------
|
21
|
+
|
22
|
+
Majek is licensed under the terms of the MIT License. See [LICENSE] file.
|
23
|
+
|
24
|
+
|
25
|
+
Contact
|
26
|
+
-------
|
27
|
+
|
28
|
+
* Web: <http://mlafeldt.github.com/majek>
|
29
|
+
* Mail: <mathias.lafeldt@gmail.com>
|
30
|
+
* Twitter: [@mlafeldt](https://twitter.com/mlafeldt)
|
31
|
+
|
32
|
+
|
33
|
+
[LICENSE]: https://github.com/mlafeldt/majek/blob/master/LICENSE
|
data/Rakefile
ADDED
data/bin/majek
ADDED
data/lib/majek.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Majek
|
2
|
+
class Application
|
3
|
+
MATCH_TITLE = %r{^# (.+)$}
|
4
|
+
|
5
|
+
def initialize(argv)
|
6
|
+
@filename = argv.first
|
7
|
+
@base_dir = File.dirname(File.expand_path(@filename))
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
markdown = File.read(@filename)
|
12
|
+
title = markdown.match(MATCH_TITLE)[1]
|
13
|
+
jekyll_body = markdown.gsub(MATCH_TITLE, '')
|
14
|
+
jekyll_header = %Q(---
|
15
|
+
layout: post
|
16
|
+
title: "#{title}"
|
17
|
+
date: #{Time.now}
|
18
|
+
comments: true
|
19
|
+
categories:
|
20
|
+
---)
|
21
|
+
MdInc::Commands::root(@base_dir)
|
22
|
+
tp = MdInc::TextProcessor.new
|
23
|
+
puts tp.process(jekyll_header + jekyll_body)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Add Octopress commands to MdInc.
|
2
|
+
module MdInc
|
3
|
+
module Commands
|
4
|
+
class << self
|
5
|
+
def octo_tag(name, attrs=[], lines=[])
|
6
|
+
output = []
|
7
|
+
output << "{% #{([name] + attrs).join(" ")} %}"
|
8
|
+
unless lines.empty?
|
9
|
+
output += lines
|
10
|
+
output << "{% end#{name} %}"
|
11
|
+
end
|
12
|
+
output
|
13
|
+
end
|
14
|
+
|
15
|
+
# Public: Octopress command to include other files.
|
16
|
+
#
|
17
|
+
# path - Path to the file to be included.
|
18
|
+
# attrs - Array of attributes passed to the Octopress tag.
|
19
|
+
#
|
20
|
+
# Examples
|
21
|
+
#
|
22
|
+
# .codeblock 'snippets/stub-spec.rb', 'ruby'
|
23
|
+
# # =>
|
24
|
+
# # {% codeblock ruby %}
|
25
|
+
# # contents of snippets/stub-spec.rb
|
26
|
+
# # {% endcodeblock %}
|
27
|
+
#
|
28
|
+
# Returns the Octopress tag as a String Array.
|
29
|
+
%w(blockquote codeblock pullquote).each do |meth|
|
30
|
+
define_method(meth) { |path, *attrs| octo_tag(meth, attrs, inc(path)) }
|
31
|
+
end
|
32
|
+
|
33
|
+
# Public: Octopress command that doesn't include anything; only added for
|
34
|
+
# consistency and convenience.
|
35
|
+
#
|
36
|
+
# attrs - Array of attributes passed to the Octopress tag.
|
37
|
+
#
|
38
|
+
# Examples
|
39
|
+
#
|
40
|
+
# .gist 1234
|
41
|
+
# # => {% gist 1234 %}
|
42
|
+
#
|
43
|
+
# .img 'left', 'http://placekitten.com/320/250', 'Place Kitten #2'
|
44
|
+
# # => {% img left http://placekitten.com/320/250 Place Kitten #2 %}
|
45
|
+
#
|
46
|
+
# Returns the Octopress tag as a String Array.
|
47
|
+
%w(gist img include_code jsfiddle render_partial video).each do |meth|
|
48
|
+
define_method(meth) { |*attrs| octo_tag(meth, attrs) }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/majek.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/majek/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.authors = ['Mathias Lafeldt']
|
6
|
+
s.email = ['mathias.lafeldt@gmail.com']
|
7
|
+
s.description = %q{Tool to convert Markdown to Jekyll post format}
|
8
|
+
s.summary = s.description
|
9
|
+
s.homepage = 'http://mlafeldt.github.com/majek'
|
10
|
+
s.license = 'MIT'
|
11
|
+
|
12
|
+
s.files = `git ls-files`.split($\)
|
13
|
+
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
15
|
+
s.name = 'majek'
|
16
|
+
s.require_paths = ['lib']
|
17
|
+
s.version = Majek::VERSION
|
18
|
+
|
19
|
+
s.add_dependency 'md_inc'
|
20
|
+
s.add_development_dependency 'rake'
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: majek
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mathias Lafeldt
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: md_inc
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Tool to convert Markdown to Jekyll post format
|
47
|
+
email:
|
48
|
+
- mathias.lafeldt@gmail.com
|
49
|
+
executables:
|
50
|
+
- majek
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- Gemfile.lock
|
57
|
+
- LICENSE
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- bin/majek
|
61
|
+
- lib/majek.rb
|
62
|
+
- lib/majek/application.rb
|
63
|
+
- lib/majek/version.rb
|
64
|
+
- lib/md_inc/octopress_commands.rb
|
65
|
+
- majek.gemspec
|
66
|
+
homepage: http://mlafeldt.github.com/majek
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
hash: -2670310394678098680
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
hash: -2670310394678098680
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 1.8.23
|
94
|
+
signing_key:
|
95
|
+
specification_version: 3
|
96
|
+
summary: Tool to convert Markdown to Jekyll post format
|
97
|
+
test_files: []
|