jekyll-org 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9ca8bf2b1561648245687da19cec5ea812b400d3
4
- data.tar.gz: 97432c814b9e297e35489cd04ecb122a3242cf12
2
+ SHA256:
3
+ metadata.gz: e8867c7504d6f7a0543a5f9964076c2bda053cccf1cc2064eaa2625faf1a68b9
4
+ data.tar.gz: '087b4270646205c5c7a9129cc4a70df21c8904f8e44bbab81833a51af768435e'
5
5
  SHA512:
6
- metadata.gz: debccea10bbe9a9bf2ffaaddf7297e80746149c14f818b5db3a22f2499ada538dfb265993c98fae8676de59fe79e46091b4095613d6f8857717dd957224ecf5c
7
- data.tar.gz: 54b22764c592b1a60a75dde326183907d6135877c89eb0f0613938b96a73232fd59445701c128f07a378469a387e081cc62d6f467e6921791b33a7ef09f5e2ea
6
+ metadata.gz: 5125e60fff01be04c2023a0184a7700a66be2ab7b9ba8b72ebbcaf219233f46b932505335001d0c63a876270c19a23f28f931696bc27e0b340ff92c5d648850a
7
+ data.tar.gz: 6233e0e5100393fba66ec0457b209ea9ae385e3213f543228f421eca9d14559e28bbb24f1b58ea738c04181c34bfff526a7bdaad55324be9175766baedff2baa
data/README.org CHANGED
@@ -37,7 +37,7 @@ following lines:
37
37
  source 'https://rubygems.org'
38
38
 
39
39
  gem 'jekyll' , '>= 3.0.0'
40
- gem 'jekyll-org', '>= 1.0.2'
40
+ gem 'jekyll-org', '>= 1.1.0'
41
41
  #+end_src
42
42
 
43
43
  Install the gems with bundler:
@@ -49,7 +49,7 @@ bundle install
49
49
  To use the new converter add the following line to your ~_config.yml~:
50
50
 
51
51
  #+begin_src yml
52
- pulugins:
52
+ plugins:
53
53
  - jekyll-org
54
54
  #+end_src
55
55
 
@@ -65,12 +65,15 @@ with no lines:
65
65
 
66
66
  #+BEGIN_EXAMPLE
67
67
  #+TITLE: Jekyll and Org together
68
- #+LAYOUT: posts
69
- #+TAGS: jekyll org-mode
68
+ #+LAYOUT: post
69
+ #+TAGS: jekyll org-mode "tag with spaces"
70
70
 
71
71
  This is a blog post about Jekyll and Org mode.
72
72
  #+END_EXAMPLE
73
73
 
74
+ The value of =#+TAGS= is parsed into a list by splitting it on spaces,
75
+ tags containing spaces can be wrapped into quotes.
76
+
74
77
  ** Liquid templating
75
78
 
76
79
  By default the all content is exported to raw HTML with org-ruby, but
@@ -99,6 +102,17 @@ then you will get output like
99
102
  <p>2014-07-02T08:20:28+08:00</p>
100
103
  #+END_EXAMPLE
101
104
 
105
+ *** Site wide config
106
+
107
+ Alternatively, if you'd rather enable liquid by default for every
108
+ org file being converted, you can enable it in your /_config.yml/
109
+ file.
110
+
111
+ #+BEGIN_EXAMPLE
112
+ org:
113
+ liquid: true
114
+ #+END_EXAMPLE
115
+
102
116
  ** Source code highlighting
103
117
 
104
118
  Add a source code block as you would in Org, for example Ruby:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.2
1
+ 1.1.0
data/jekyll-org.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: jekyll-org 1.0.2 ruby lib
5
+ # stub: jekyll-org 1.1.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "jekyll-org".freeze
9
- s.version = "1.0.2"
9
+ s.version = "1.1.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["eggcaker".freeze]
14
- s.date = "2018-01-12"
14
+ s.date = "2019-12-11"
15
15
  s.description = "So you want org-mode support for Jekyll. Write your _posts in org-mode, then add 'gems: [jekyll-org]' to your _config.yml. Thats it!".freeze
16
16
  s.email = "eggcaker@gmail.com".freeze
17
17
  s.extra_rdoc_files = [
@@ -36,7 +36,7 @@ Gem::Specification.new do |s|
36
36
  ]
37
37
  s.homepage = "http://eggcaker.github.io/jekyll-org".freeze
38
38
  s.licenses = ["MIT".freeze]
39
- s.rubygems_version = "2.6.14".freeze
39
+ s.rubygems_version = "3.0.3".freeze
40
40
  s.summary = "Jekyll converter for org-mode files".freeze
41
41
 
42
42
  if s.respond_to? :specification_version then
data/lib/jekyll-org.rb CHANGED
@@ -1,13 +1,13 @@
1
+ require 'csv'
1
2
  require 'org-ruby'
2
3
 
3
- if Jekyll::VERSION < "3.0"
4
- raise Jekyll::FatalException, "This version of jekyll-org is only compatible with Jekyll v3 and above."
4
+ if Jekyll::VERSION < '3.0'
5
+ raise Jekyll::FatalException, 'This version of jekyll-org is only compatible with Jekyll v3 and above.'
5
6
  end
6
7
 
7
8
  module Jekyll
8
9
  class OrgConverter < Converter
9
10
  safe true
10
-
11
11
  priority :low
12
12
 
13
13
  def matches(ext)
@@ -15,7 +15,7 @@ module Jekyll
15
15
  end
16
16
 
17
17
  def output_ext(ext)
18
- ".html"
18
+ '.html'
19
19
  end
20
20
 
21
21
  def convert(content)
@@ -31,65 +31,90 @@ module Jekyll
31
31
  end
32
32
  end
33
33
 
34
- # This overrides having to use YAML in the posts.
35
- # Instead use settings from Org mode.
36
- class Document
37
- DATELESS_FILENAME_MATCHER = %r!^(?:.+/)*(.*)(\.[^.]+)$!
38
- DATE_FILENAME_MATCHER = %r!^(?:.+/)*(\d{4}-\d{2}-\d{2})-(.*)(\.[^.]+)$!
34
+ module OrgDocument
35
+ def org_file?
36
+ extname.eql?(".org")
37
+ end
39
38
 
40
- alias :_orig_read :read
41
- def read(opts = {})
42
- unless relative_path.end_with?(".org")
43
- return _orig_read(opts)
44
- end
39
+ def site
40
+ @site ||= Jekyll.configuration({})
41
+ end
42
+
43
+ def org_config
44
+ site.config["org"] || Hash.new()
45
+ end
45
46
 
46
- Jekyll.logger.debug "Reading:", relative_path
47
+ # see https://github.com/bdewey/org-ruby/blob/master/lib/org-ruby/parser.rb
48
+ def _org_parser_options
49
+ org_config.fetch("_org_parser_options", { markup_file: 'html.tags.yml' })
50
+ end
51
+
52
+ ## override: read file & parse YAML... in this case, don't parse YAML
53
+ # see also: https://github.com/jekyll/jekyll/blob/master/lib/jekyll/document.rb
54
+ def read_content(opts = {})
55
+ return super unless org_file? # defer to default behaviour when not org file
47
56
 
48
57
  self.content = File.read(path, Utils.merged_file_read_opts(site, opts))
49
- self.data ||= {}
50
- liquid_enabled = false
51
58
 
52
- org_text = Orgmode::Parser.new(content, { markup_file: "html.tags.yml" })
59
+ org_text = Orgmode::Parser.new(content, _org_parser_options)
60
+ @liquid_enabled = org_config.fetch("liquid", false)
61
+
53
62
  org_text.in_buffer_settings.each_pair do |key, value|
54
63
  # Remove #+TITLE from the buffer settings to avoid double exporting
55
64
  org_text.in_buffer_settings.delete(key) if key =~ /title/i
56
- buffer_setting = key.downcase
65
+ org_assign_setting(key, value)
66
+ end
57
67
 
58
- if buffer_setting == 'liquid'
59
- liquid_enabled = true
60
- end
68
+ self.content = _org_buffer_handle_liquid(org_text)
69
+ end
61
70
 
62
- self.data[buffer_setting] = value
63
- end
64
- # set default slug
65
- # copy and edit frmo jekyll:lib/jekyll/document.rb -- populate_title
66
- if relative_path =~ DATE_FILENAME_MATCHER
67
- date, slug, ext = Regexp.last_match.captures
68
- modify_date(date)
69
- elsif relative_path =~ DATELESS_FILENAME_MATCHER
70
- slug, ext = Regexp.last_match.captures
71
+ def org_assign_setting(key, value)
72
+ key = key.downcase
73
+
74
+ case key
75
+ when "liquid"
76
+ value = _parse_boolean_value(value, "unknown LIQUID setting")
77
+ @liquid_enabled = value unless value.nil?
78
+ when "tags", "categories"
79
+ # Parse a string of tags separated by spaces into a list.
80
+ # Tags containing spaces can be wrapped in quotes,
81
+ # e.g. '#+TAGS: foo "with spaces"'.
82
+ #
83
+ # The easiest way to do this is to use rubys builtin csv parser
84
+ # and use spaces instead of commas as column separator.
85
+ self.data[key] = CSV::parse_line(value, col_sep: ' ')
86
+ else
87
+ value_bool = _parse_boolean_value(value)
88
+ self.data[key] = (value_bool.nil?) ? value : value_bool
71
89
  end
72
- self.data["title"] ||= Utils.titleize_slug(slug)
73
- self.data["slug"] ||= slug
74
- self.data["ext"] ||= ext
75
-
76
- # Disable Liquid tags from the output by default or enabled with liquid_enabled tag
77
- if liquid_enabled
78
- self.content = org_text.to_html
79
- self.content = self.content.gsub("&#8216;","'")
80
- self.content = self.content.gsub("&#8217;", "'")
90
+ end
91
+
92
+ # format the org buffer text by enabling or disabling
93
+ # the presence of liquid tags.
94
+ def _org_buffer_handle_liquid(org_text)
95
+ if @liquid_enabled
96
+ org_text.to_html.gsub("&#8216;", "'").gsub("&#8217;", "'")
81
97
  else
82
- self.content = [
83
- '{% raw %}',
84
- org_text.to_html,
85
- '{% endraw %}'
86
- ].join(" ")
98
+ '{% raw %} ' + org_text.to_html + ' {% endraw %}'
87
99
  end
88
- begin
89
- self.data
90
- rescue => e
91
- puts "Error converting file #{relative_path}: #{e.message} #{e.backtrace}"
100
+ end
101
+
102
+ @@truthy_regexps = [/enabled/, /yes/, /true/]
103
+ @@falsy_regexps = [/disabled/, /no/, /false/]
104
+
105
+ def _parse_boolean_value(value, error_msg=nil)
106
+ case value.downcase
107
+ when *@@truthy_regexps
108
+ true
109
+ when *@@falsy_regexps
110
+ false
111
+ else
112
+ unless error_msg.nil?
113
+ Jekyll.logger.warn("OrgDocument:", error_msg + ": #{value}")
114
+ end
92
115
  end
93
116
  end
94
117
  end
95
118
  end
119
+
120
+ Jekyll::Document.prepend(Jekyll::OrgDocument)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-org
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - eggcaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-12 00:00:00.000000000 Z
11
+ date: 2019-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: org-ruby
@@ -178,8 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
178
  - !ruby/object:Gem::Version
179
179
  version: '0'
180
180
  requirements: []
181
- rubyforge_project:
182
- rubygems_version: 2.6.14
181
+ rubygems_version: 3.0.3
183
182
  signing_key:
184
183
  specification_version: 4
185
184
  summary: Jekyll converter for org-mode files