majek 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.travis.yml +14 -0
- data/CHANGELOG.md +27 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +4 -4
- data/README.md +30 -18
- data/lib/majek.rb +3 -1
- data/lib/majek/application.rb +18 -14
- data/lib/majek/jekyll_page.rb +20 -0
- data/lib/majek/version.rb +1 -1
- data/lib/md_inc/jekyll_commands.rb +35 -0
- data/lib/md_inc/octopress_commands.rb +4 -14
- data/majek.gemspec +2 -2
- metadata +14 -23
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YjgwM2QwZTU3OGQyNjFhNmYwMzgxOWY1NDc0YzZkOWEyNjQyYjllMw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OWEzZDI3NmVhM2NkZGNkMWZjMmYxYmQ3YzdmYzgyNmRiZGY5ODk4OA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ODBlZmJjNWE2NGE2ODg2NzBlNDQ2MGZhZDdkZmQ1YzMwM2EyNzlhYmQyOTE0
|
10
|
+
MDgyMGVjNTY4YzIzNmQ3YjhlNjM5NDgyMzEzODU2MDFjNDI1NmYyOTlmZGRl
|
11
|
+
ZGNmZGIzODk0OWM4YThkZDlhNzY2NDJkMjZiNzg2Mjk4N2IyYzA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MWY0N2E5ODhjNTc1MTgxMjA0MmE2YTJmNTZmMGVhNjVhYzc1NjVhYTc5ODE5
|
14
|
+
YmI0OTBhM2RlMTdmODkxYThlOGExMTJhMDE0ZjVlMDhkYzFkZjU3Zjk3NzBh
|
15
|
+
ZjAxZDY1MDg5YjdkNmMyOWRmMzcyNWU1ZmQ3OWI5NmQwYWU1YzU=
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
v0.1.3 (Mar 11 2013)
|
2
|
+
--------------------
|
3
|
+
|
4
|
+
* Only set post layout and post title in YAML front matter.
|
5
|
+
* Use post title *New Post* if none can be found.
|
6
|
+
* Read Markdown from standard input if file is absent.
|
7
|
+
* Add Travis config (no tests yet).
|
8
|
+
* Add this CHANGELOG file.
|
9
|
+
* Update to md_inc v0.2.9.
|
10
|
+
* Update README.
|
11
|
+
|
12
|
+
v0.1.2 (Feb 14 2013)
|
13
|
+
--------------------
|
14
|
+
|
15
|
+
* Big README update.
|
16
|
+
|
17
|
+
v0.1.1 (Feb 13 2013)
|
18
|
+
--------------------
|
19
|
+
|
20
|
+
* Add gemspec; source it in Gemfile.
|
21
|
+
* Add Rakefile.
|
22
|
+
* Add .gitignore.
|
23
|
+
|
24
|
+
v0.1.0 (Feb 13 2013)
|
25
|
+
--------------------
|
26
|
+
|
27
|
+
* First tagged version.
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
Majek
|
2
2
|
=====
|
3
3
|
|
4
|
-
Majek is a preprocessor for Jekyll
|
5
|
-
|
6
|
-
|
4
|
+
Majek is a preprocessor for Jekyll blog posts that helps you to concentrate on
|
5
|
+
writing. It allows you to include other files from your Markdown (thanks to
|
6
|
+
[md_inc]) and produce posts in Jekyll format.
|
7
7
|
|
8
8
|
Majek is especially helpful when you're writing Markdown with a tool like
|
9
9
|
[iA Writer] that is more about prose and less about code. Instead of including
|
10
10
|
bulky code snippets directly in your Markdown file, you simply insert short
|
11
|
-
commands like `.inc 'foo.txt'` or `.
|
12
|
-
expanded by Majek.
|
11
|
+
commands like `.inc 'foo.txt'` or `.highlight 'bar.rb', 'ruby'`, which will then
|
12
|
+
be expanded by Majek.
|
13
13
|
|
14
14
|
|
15
15
|
Installation
|
@@ -30,20 +30,37 @@ Alternatively, you can install the gem from source:
|
|
30
30
|
Usage
|
31
31
|
-----
|
32
32
|
|
33
|
-
usage: majek <markdown file>
|
33
|
+
usage: majek [<markdown file>]
|
34
34
|
|
35
|
-
Simply pass Majek a Markdown file and it will do the following
|
35
|
+
Simply pass Majek a Markdown file and it will do the following (if the file is
|
36
|
+
absent, Majek reads from the standard input):
|
36
37
|
|
37
38
|
- read the contents of the Markdown file
|
38
39
|
- process the text with md_inc which provides commands to include other text
|
39
|
-
files
|
40
|
-
-
|
41
|
-
|
42
|
-
in the future)
|
40
|
+
files, code snippets, and much more (see Commands)
|
41
|
+
- add Jekyll's YAML front matter with post layout and post title (will be
|
42
|
+
configurable in the future)
|
43
43
|
- output the final text to screen
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
|
46
|
+
Commands
|
47
|
+
--------
|
48
|
+
|
49
|
+
Majek provides all commands that come with md_inc as well as some additional
|
50
|
+
commands for Jekyll and Octopress:
|
51
|
+
|
52
|
+
### md_inc
|
53
|
+
|
54
|
+
- `.inc path`
|
55
|
+
- `.code_inc path [,language]`
|
56
|
+
|
57
|
+
Read the documentation of [md_inc] to learn more.
|
58
|
+
|
59
|
+
### Jekyll
|
60
|
+
|
61
|
+
- `.highlight path, language`
|
62
|
+
|
63
|
+
### Octopress
|
47
64
|
|
48
65
|
- `.blockquote path [,attributes...]`
|
49
66
|
- `.codeblock path [,attributes...]`
|
@@ -55,8 +72,6 @@ Octopress-specific commands:
|
|
55
72
|
- `.render_partial [attributes...]`
|
56
73
|
- `.video [attributes...]`
|
57
74
|
|
58
|
-
Make sure to also read the documentation of [md_inc] to learn more.
|
59
|
-
|
60
75
|
|
61
76
|
Examples
|
62
77
|
--------
|
@@ -78,9 +93,6 @@ $ majek one_month_of_coderwall_protips.md
|
|
78
93
|
---
|
79
94
|
layout: post
|
80
95
|
title: "One Month of Coderwall Protips"
|
81
|
-
date: 2013-02-14 11:01:09 +0100
|
82
|
-
comments: true
|
83
|
-
categories:
|
84
96
|
---
|
85
97
|
|
86
98
|
On 1 January 2013, I signed up on [Coderwall](https://coderwall.com/) -- a place
|
data/lib/majek.rb
CHANGED
data/lib/majek/application.rb
CHANGED
@@ -3,24 +3,28 @@ module Majek
|
|
3
3
|
MATCH_TITLE = %r{^# (.+)$}
|
4
4
|
|
5
5
|
def initialize(argv)
|
6
|
-
|
7
|
-
|
6
|
+
if argv.empty?
|
7
|
+
@markdown = STDIN.read
|
8
|
+
@base_dir = nil
|
9
|
+
else
|
10
|
+
filename = argv.first
|
11
|
+
@markdown = File.read(filename)
|
12
|
+
@base_dir = File.dirname(File.expand_path(filename))
|
13
|
+
end
|
8
14
|
end
|
9
15
|
|
10
16
|
def run
|
11
|
-
|
12
|
-
title =
|
13
|
-
|
14
|
-
|
15
|
-
layout: post
|
16
|
-
title: "#{title}"
|
17
|
-
date: #{Time.now}
|
18
|
-
comments: true
|
19
|
-
categories:
|
20
|
-
---)
|
21
|
-
MdInc::Commands::root(@base_dir)
|
17
|
+
match = @markdown.match(MATCH_TITLE)
|
18
|
+
title = match ? match[1] : 'New Post'
|
19
|
+
content = @markdown.sub(MATCH_TITLE, '').sub(/\n*/, '')
|
20
|
+
|
22
21
|
tp = MdInc::TextProcessor.new
|
23
|
-
|
22
|
+
tp.root(@base_dir) unless @base_dir.nil?
|
23
|
+
content = tp.process(content)
|
24
|
+
|
25
|
+
# TODO make variables configurable
|
26
|
+
page = JekyllPage.new content, :layout => 'post', :title => "\"#{title}\""
|
27
|
+
puts page.render
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Majek
|
2
|
+
class JekyllPage
|
3
|
+
def initialize(content, vars=nil)
|
4
|
+
@content = content
|
5
|
+
@vars = vars || Hash.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def content
|
9
|
+
@content
|
10
|
+
end
|
11
|
+
|
12
|
+
def front_matter
|
13
|
+
['---', @vars.map { |k, v| "#{k}: #{v}" }, '---'].join("\n")
|
14
|
+
end
|
15
|
+
|
16
|
+
def render
|
17
|
+
[front_matter, '', content].join("\n")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/majek/version.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Add Jekyll commands to MdInc.
|
2
|
+
module MdInc
|
3
|
+
module Commands
|
4
|
+
class << self
|
5
|
+
def jekyll_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: Jekyll command to include code that should be highlighted from
|
16
|
+
# a file.
|
17
|
+
#
|
18
|
+
# path - Path to the file to be included.
|
19
|
+
# language - Language identifier
|
20
|
+
#
|
21
|
+
# Examples
|
22
|
+
#
|
23
|
+
# .highlight 'snippets/stub-spec.rb', 'ruby'
|
24
|
+
# # =>
|
25
|
+
# # {% highlight ruby %}
|
26
|
+
# # contents of snippets/stub-spec.rb
|
27
|
+
# # {% endhighlight %}
|
28
|
+
#
|
29
|
+
# Returns the Jekyll tag as a String Array.
|
30
|
+
def highlight(path, language)
|
31
|
+
jekyll_tag(:highlight, [language], inc(path))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -2,16 +2,6 @@
|
|
2
2
|
module MdInc
|
3
3
|
module Commands
|
4
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
5
|
# Public: Octopress command to include other files.
|
16
6
|
#
|
17
7
|
# path - Path to the file to be included.
|
@@ -19,15 +9,15 @@ module MdInc
|
|
19
9
|
#
|
20
10
|
# Examples
|
21
11
|
#
|
22
|
-
# .codeblock 'snippets/stub-spec.rb', 'ruby'
|
12
|
+
# .codeblock 'snippets/stub-spec.rb', 'lang:ruby'
|
23
13
|
# # =>
|
24
|
-
# # {% codeblock ruby %}
|
14
|
+
# # {% codeblock lang:ruby %}
|
25
15
|
# # contents of snippets/stub-spec.rb
|
26
16
|
# # {% endcodeblock %}
|
27
17
|
#
|
28
18
|
# Returns the Octopress tag as a String Array.
|
29
19
|
%w(blockquote codeblock pullquote).each do |meth|
|
30
|
-
define_method(meth) { |path, *attrs|
|
20
|
+
define_method(meth) { |path, *attrs| jekyll_tag(meth, attrs, inc(path)) }
|
31
21
|
end
|
32
22
|
|
33
23
|
# Public: Octopress command that doesn't include anything; only added for
|
@@ -45,7 +35,7 @@ module MdInc
|
|
45
35
|
#
|
46
36
|
# Returns the Octopress tag as a String Array.
|
47
37
|
%w(gist img include_code jsfiddle render_partial video).each do |meth|
|
48
|
-
define_method(meth) { |*attrs|
|
38
|
+
define_method(meth) { |*attrs| jekyll_tag(meth, attrs) }
|
49
39
|
end
|
50
40
|
end
|
51
41
|
end
|
data/majek.gemspec
CHANGED
@@ -4,7 +4,7 @@ require File.expand_path('../lib/majek/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.authors = ['Mathias Lafeldt']
|
6
6
|
s.email = ['mathias.lafeldt@gmail.com']
|
7
|
-
s.description = %q{A preprocessor for Jekyll
|
7
|
+
s.description = %q{A preprocessor for Jekyll blog posts that helps you to concentrate on writing}
|
8
8
|
s.summary = s.description
|
9
9
|
s.homepage = 'http://mlafeldt.github.com/majek'
|
10
10
|
s.license = 'MIT'
|
@@ -16,6 +16,6 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.require_paths = ['lib']
|
17
17
|
s.version = Majek::VERSION
|
18
18
|
|
19
|
-
s.add_dependency 'md_inc'
|
19
|
+
s.add_dependency 'md_inc', '>= 0.2.9'
|
20
20
|
s.add_development_dependency 'rake'
|
21
21
|
end
|
metadata
CHANGED
@@ -1,36 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: majek
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Mathias Lafeldt
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: md_inc
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
version: 0.2.9
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ! '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
26
|
+
version: 0.2.9
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,13 +34,12 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ! '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
|
-
description: A preprocessor for Jekyll
|
47
|
-
|
41
|
+
description: A preprocessor for Jekyll blog posts that helps you to concentrate on
|
42
|
+
writing
|
48
43
|
email:
|
49
44
|
- mathias.lafeldt@gmail.com
|
50
45
|
executables:
|
@@ -53,6 +48,8 @@ extensions: []
|
|
53
48
|
extra_rdoc_files: []
|
54
49
|
files:
|
55
50
|
- .gitignore
|
51
|
+
- .travis.yml
|
52
|
+
- CHANGELOG.md
|
56
53
|
- Gemfile
|
57
54
|
- Gemfile.lock
|
58
55
|
- LICENSE
|
@@ -61,39 +58,33 @@ files:
|
|
61
58
|
- bin/majek
|
62
59
|
- lib/majek.rb
|
63
60
|
- lib/majek/application.rb
|
61
|
+
- lib/majek/jekyll_page.rb
|
64
62
|
- lib/majek/version.rb
|
63
|
+
- lib/md_inc/jekyll_commands.rb
|
65
64
|
- lib/md_inc/octopress_commands.rb
|
66
65
|
- majek.gemspec
|
67
66
|
homepage: http://mlafeldt.github.com/majek
|
68
67
|
licenses:
|
69
68
|
- MIT
|
69
|
+
metadata: {}
|
70
70
|
post_install_message:
|
71
71
|
rdoc_options: []
|
72
72
|
require_paths:
|
73
73
|
- lib
|
74
74
|
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
75
|
requirements:
|
77
76
|
- - ! '>='
|
78
77
|
- !ruby/object:Gem::Version
|
79
78
|
version: '0'
|
80
|
-
segments:
|
81
|
-
- 0
|
82
|
-
hash: 204157305799219663
|
83
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
-
none: false
|
85
80
|
requirements:
|
86
81
|
- - ! '>='
|
87
82
|
- !ruby/object:Gem::Version
|
88
83
|
version: '0'
|
89
|
-
segments:
|
90
|
-
- 0
|
91
|
-
hash: 204157305799219663
|
92
84
|
requirements: []
|
93
85
|
rubyforge_project:
|
94
|
-
rubygems_version:
|
86
|
+
rubygems_version: 2.0.2
|
95
87
|
signing_key:
|
96
|
-
specification_version:
|
97
|
-
summary: A preprocessor for Jekyll
|
98
|
-
on writing
|
88
|
+
specification_version: 4
|
89
|
+
summary: A preprocessor for Jekyll blog posts that helps you to concentrate on writing
|
99
90
|
test_files: []
|