├── .gitignore ├── .travis.yml ├── Gemfile ├── History.md ├── LICENSE ├── README.org ├── Rakefile ├── VERSION ├── jekyll-org.gemspec ├── lib ├── jekyll-org.rb └── jekyll-org │ ├── converter.rb │ └── utils.rb ├── script ├── bootstrap ├── cibuild ├── console └── release └── spec ├── .#test_jekyll-org-mode-converter.rb ├── helper.rb └── test_jekyll-org.rb /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | Gemfile.lock 3 | spec/dest 4 | .bundle 5 | 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: ruby 3 | cache: bundler 4 | rvm: 5 | - 2.3.1 6 | matrix: 7 | include: 8 | - # GitHub Pages 9 | rvm: 2.3.1 10 | env: JEKYLL_VERSION=3.3.0 11 | env: 12 | matrix: 13 | - JEKYLL_VERSION=3.3 14 | branches: 15 | only: 16 | - master 17 | install: 18 | - travis_retry script/bootstrap 19 | script: script/cibuild 20 | notifications: 21 | irc: 22 | on_success: change 23 | on_failure: change 24 | channels: 25 | - irc.freenode.org#jekyll 26 | template: 27 | - '%{repository}#%{build_number} %{message} %{build_url}' 28 | email: 29 | on_success: never 30 | on_failure: change 31 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "http://rubygems.org" 2 | # Add dependencies required to use your gem here. 3 | # Example: 4 | # gem "activesupport", ">= 2.3.5" 5 | gem 'org-ruby' , '>= 0.9.12' 6 | gem 'jekyll', '>= 3.5.0' 7 | gem 'json', github: 'flori/json', branch: 'v1.8' 8 | 9 | 10 | # Add dependencies to develop your gem here. 11 | # Include everything needed to run rake, tests, features, etc. 12 | group :development do 13 | gem "shoulda", ">= 3.5.0" 14 | gem "rspec", ">=3.5.0" 15 | gem "rdoc", ">=3.12" 16 | gem "bundler", ">=1.0" 17 | gem "jeweler", ">=2.1.1" 18 | gem "simplecov", ">= 0.12.0" 19 | end 20 | -------------------------------------------------------------------------------- /History.md: -------------------------------------------------------------------------------- 1 | 2 | 1.1.1 / 2019-12-14 3 | ================== 4 | * add support for converting files in collections other than _posts 5 | 6 | 1.1.0 /2019-12-12 7 | 8 | * add site wide configuration support through _config.yml 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2016 eggcaker. http://yep8.org/jekyll-org/ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | * jekyll-org 2 | 3 | *Looking for a New Maintainer* 4 | 5 | *Notice*: I am currently not really using ruby and jekyll right now, and I am looking for someone who is interested and willing to take over its maintenance. If you're interested, please contact me using one of the methods below: 6 | Send an email to: eggcaker@gmail.com 7 | Leave a message in the issues. 8 | 9 | ** Overview 10 | 11 | This plugin adds [[http://orgmode.org/][Org mode]] support to [[http://jekyllrb.com][Jekyll]] and lets you write posts 12 | and pages in Org. 13 | 14 | ** Related Projects 15 | 16 | What's the difference with org2jekll 17 | You don’t need to any org-publish-project-alist to starting write post, just start with any editor that org-mode supported 18 | 19 | What’s the difference with org-jekyll? 20 | You don’t need to add some alien yaml in your org-mode file. You add specific org-mode headers and this will be used to format the jekyll post. 21 | 22 | What’s the difference with happyblogger? 23 | No more external ruby script. 24 | 25 | ** Requirements 26 | 27 | - Jekyll 28 | - org-ruby 29 | 30 | ** Installation 31 | *** Short version 32 | 33 | For experienced Jekyll users, you need to do 2 things to get 34 | ~jekyll-org~ to work : 35 | 36 | - Include the gem in your ~_config.yml~ 37 | - Include the gem in Gemfile 38 | 39 | *** Long version 40 | 41 | To use ~jekyll-org~ with Jekyll, you need to have Ruby RubyGems and 42 | Jekyll installed. See how to do that [[http://jekyllrb.com/docs/installation/][here]]. 43 | 44 | Create a new Jekyll project ~my-site~ run: 45 | 46 | #+begin_src sh 47 | jekyll new my-site 48 | #+end_src 49 | 50 | Create a Gemfile in the root of the project, and add at least the 51 | following lines: 52 | 53 | #+begin_src ruby 54 | source 'https://rubygems.org' 55 | 56 | gem 'jekyll' , '>= 3.0.0' 57 | gem 'jekyll-org', '>= 1.1.0' 58 | #+end_src 59 | 60 | Install the gems with bundler: 61 | 62 | #+begin_src sh 63 | bundle install 64 | #+end_src 65 | 66 | To use the new converter add the following line to your ~_config.yml~: 67 | 68 | #+begin_src yml 69 | plugins: 70 | - jekyll-org 71 | #+end_src 72 | 73 | :warning: If you are using Jekyll < 3.5.0 use the gems key instead of plugins. 74 | 75 | ** Usage 76 | 77 | Create a new file with =.org= extension in =_posts=, and write the post 78 | with Org. That is all! Generate your Jekyll site as you usually do. 79 | 80 | ** Front matter 81 | 82 | Instead of YAML the front matter is configured in the usual Org way, 83 | with no lines. 84 | 85 | Below is an example of an Org post, featuring front matter, tags, tables, 86 | liquid templating and syntax highlighting. To render this example, remove 87 | the leading hash symbols (#) at =#+begin_src= and =#+begin_end= beforehand 88 | (this is a workaround for GitHub's org rendering). 89 | 90 | #+BEGIN_EXAMPLE 91 | #+TITLE: Jekyll and Org together 92 | #+LAYOUT: post 93 | #+TAGS: jekyll org-mode "tag with spaces" 94 | 95 | This is a blog post about Jekyll and Org mode. 96 | 97 | ** org-table demo 98 | 99 | | a | b | c | d | e | 100 | |---+---+---+---+---| 101 | | 1 | 2 | 3 | 4 | 5 | 102 | 103 | ** Liquid demo 104 | #+liquid: enabled 105 | #+foo: hello world 106 | {{ page.foo }} 107 | 108 | or 109 | 110 | {{ site.time | date_to_xmlschema }} 111 | 112 | ** Code highlighting 113 | Jekyll-org also offers powerful support for code snippets: 114 | ##+begin_src ruby 115 | def print_hi(name) 116 | puts "Hi, #{name}" 117 | end 118 | print_hi('Tom') 119 | 120 | #=> prints 'Hi, Tom' to STDOUT. 121 | ##+end_src 122 | #+END_EXAMPLE 123 | 124 | The value of =#+TAGS= is parsed into a list by splitting it on spaces, 125 | tags containing spaces can be wrapped into quotes. 126 | 127 | ** Liquid templating 128 | 129 | By default the all content is exported to raw HTML with org-ruby, but 130 | you can add =#+liquid: whatevervalue== in the header. Then you can use 131 | [[http://docs.shopify.com/themes/liquid-documentation/basics][Liquid]] tags. 132 | 133 | For example, if your Org file contains 134 | 135 | #+BEGIN_EXAMPLE 136 | #+liquid: enabled 137 | #+foo: hello world 138 | 139 | {{ page.foo }} 140 | 141 | or 142 | 143 | {{ site.time | date_to_xmlschema }} 144 | 145 | #+END_EXAMPLE 146 | 147 | then you will get output like 148 | 149 | #+BEGIN_EXAMPLE 150 |

hello world

151 |

or

152 |

2014-07-02T08:20:28+08:00

153 | #+END_EXAMPLE 154 | 155 | *** Site wide config 156 | 157 | Alternatively, if you'd rather enable liquid by default for every 158 | org file being converted, you can enable it in your /_config.yml/ 159 | file. 160 | 161 | #+BEGIN_EXAMPLE 162 | org: 163 | liquid: true 164 | #+END_EXAMPLE 165 | 166 | ** Source code highlighting 167 | 168 | To enable source code highlighting, run =bundle add pygments.rb=. If your Jekyll 169 | theme has built-in support for syntax highlighting, you're all set! Otherwise, add a =pygments=-compatible 170 | CSS file to your site's =/assets/css/= folder. You can find a bunch of CSS themes for =pygments= in 171 | [[https://github.com/richleland/pygments-css][this repository]], or create your own (some related =pygments= documentation is [[https://pygments.org/docs/styles/][here]]). 172 | 173 | Then, add a source code block as you would in Org, for example Ruby: 174 | 175 | #+BEGIN_EXAMPLE 176 | #+BEGIN_SRC 177 | require 'rubygems' 178 | require 'org-ruby' 179 | data = IO.read(filename) 180 | puts Orgmode::Parser.new(data).to_html 181 | #+END_SRC 182 | #+END_EXAMPLE 183 | 184 | And the output will have code highlighting: 185 | 186 | #+BEGIN_SRC ruby 187 | require 'rubygems' 188 | require 'org-ruby' 189 | data = IO.read(filename) 190 | puts Orgmode::Parser.new(data).to_html 191 | #+END_SRC 192 | 193 | ** Author 194 | 195 | eggcaker 196 | 197 | ** License 198 | 199 | MIT 200 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require 'rubygems' 4 | require 'bundler' 5 | require 'org-ruby' 6 | 7 | begin 8 | Bundler.setup(:default, :development) 9 | rescue Bundler::BundlerError => e 10 | $stderr.puts e.message 11 | $stderr.puts "Run `bundle install` to install missing gems" 12 | exit e.status_code 13 | end 14 | 15 | require 'rake' 16 | require 'jeweler' 17 | 18 | Jeweler::Tasks.new do |gem| 19 | # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options 20 | gem.name = "jekyll-org" 21 | gem.homepage = "http://eggcaker.github.io/jekyll-org" 22 | gem.license = "MIT" 23 | gem.summary = %Q{Jekyll converter for org-mode files} 24 | gem.description = %Q{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!} 25 | gem.email = "eggcaker@gmail.com" 26 | gem.authors = "eggcaker" 27 | # dependencies defined in Gemfile 28 | end 29 | 30 | Jeweler::RubygemsDotOrgTasks.new 31 | 32 | require 'rake/testtask' 33 | Rake::TestTask.new(:test) do |test| 34 | test.libs << 'lib' << 'test' 35 | test.pattern = 'test/**/test_*.rb' 36 | test.verbose = true 37 | end 38 | 39 | desc "Code coverage detail" 40 | task :simplecov do 41 | ENV['COVERAGE'] = "true" 42 | Rake::Task['test'].execute 43 | end 44 | 45 | task :default => :test 46 | 47 | require 'rdoc/task' 48 | Rake::RDocTask.new do |rdoc| 49 | version = File.exist?('VERSION') ? File.read('VERSION') : "" 50 | 51 | rdoc.rdoc_dir = 'rdoc' 52 | rdoc.title = "jekyll-org #{version}" 53 | rdoc.rdoc_files.include('README*') 54 | rdoc.rdoc_files.include('lib/**/*.rb') 55 | end 56 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1.1.1 2 | -------------------------------------------------------------------------------- /jekyll-org.gemspec: -------------------------------------------------------------------------------- 1 | # Generated by jeweler 2 | # DO NOT EDIT THIS FILE DIRECTLY 3 | # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' 4 | # -*- encoding: utf-8 -*- 5 | # stub: jekyll-org 1.1.1 ruby lib 6 | 7 | Gem::Specification.new do |s| 8 | s.name = "jekyll-org".freeze 9 | s.version = "1.1.1" 10 | 11 | s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= 12 | s.require_paths = ["lib".freeze] 13 | s.authors = ["eggcaker".freeze] 14 | s.date = "2019-12-14" 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 | s.email = "eggcaker@gmail.com".freeze 17 | s.extra_rdoc_files = [ 18 | "LICENSE", 19 | "README.org" 20 | ] 21 | s.files = [ 22 | ".travis.yml", 23 | "Gemfile", 24 | "LICENSE", 25 | "README.org", 26 | "Rakefile", 27 | "VERSION", 28 | "jekyll-org.gemspec", 29 | "lib/jekyll-org.rb", 30 | "lib/jekyll-org/converter.rb", 31 | "lib/jekyll-org/utils.rb", 32 | "script/bootstrap", 33 | "script/cibuild", 34 | "script/console", 35 | "script/release", 36 | "spec/helper.rb", 37 | "spec/test_jekyll-org.rb" 38 | ] 39 | s.homepage = "http://eggcaker.github.io/jekyll-org".freeze 40 | s.licenses = ["MIT".freeze] 41 | s.rubygems_version = "3.0.3".freeze 42 | s.summary = "Jekyll converter for org-mode files".freeze 43 | 44 | if s.respond_to? :specification_version then 45 | s.specification_version = 4 46 | 47 | if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then 48 | s.add_runtime_dependency(%q.freeze, [">= 0.9.12"]) 49 | s.add_runtime_dependency(%q.freeze, [">= 3.5.0"]) 50 | s.add_runtime_dependency(%q.freeze, [">= 0"]) 51 | s.add_development_dependency(%q.freeze, [">= 3.5.0"]) 52 | s.add_development_dependency(%q.freeze, [">= 3.5.0"]) 53 | s.add_development_dependency(%q.freeze, [">= 3.12"]) 54 | s.add_development_dependency(%q.freeze, [">= 1.0"]) 55 | s.add_development_dependency(%q.freeze, [">= 2.1.1"]) 56 | s.add_development_dependency(%q.freeze, [">= 0.12.0"]) 57 | else 58 | s.add_dependency(%q.freeze, [">= 0.9.12"]) 59 | s.add_dependency(%q.freeze, [">= 3.5.0"]) 60 | s.add_dependency(%q.freeze, [">= 0"]) 61 | s.add_dependency(%q.freeze, [">= 3.5.0"]) 62 | s.add_dependency(%q.freeze, [">= 3.5.0"]) 63 | s.add_dependency(%q.freeze, [">= 3.12"]) 64 | s.add_dependency(%q.freeze, [">= 1.0"]) 65 | s.add_dependency(%q.freeze, [">= 2.1.1"]) 66 | s.add_dependency(%q.freeze, [">= 0.12.0"]) 67 | end 68 | else 69 | s.add_dependency(%q.freeze, [">= 0.9.12"]) 70 | s.add_dependency(%q.freeze, [">= 3.5.0"]) 71 | s.add_dependency(%q.freeze, [">= 0"]) 72 | s.add_dependency(%q.freeze, [">= 3.5.0"]) 73 | s.add_dependency(%q.freeze, [">= 3.5.0"]) 74 | s.add_dependency(%q.freeze, [">= 3.12"]) 75 | s.add_dependency(%q.freeze, [">= 1.0"]) 76 | s.add_dependency(%q.freeze, [">= 2.1.1"]) 77 | s.add_dependency(%q.freeze, [">= 0.12.0"]) 78 | end 79 | end 80 | 81 | -------------------------------------------------------------------------------- /lib/jekyll-org.rb: -------------------------------------------------------------------------------- 1 | if Jekyll::VERSION < '3.0' 2 | raise Jekyll::FatalException, 'This version of jekyll-org is only compatible with Jekyll v3 and above.' 3 | end 4 | 5 | require_relative './jekyll-org/converter' 6 | 7 | module Jekyll 8 | module Filters 9 | def orgify(input) 10 | site = @context.registers[:site] 11 | converter = site.find_converter_instance(Jekyll::Converters::Org) 12 | converter.convert(input) 13 | end 14 | end 15 | 16 | module OrgDocument 17 | def org_file? 18 | Jekyll::Converters::Org.matches(extname) 19 | end 20 | 21 | ## override: read file & parse YAML... in this case, don't parse YAML 22 | # see also: https://github.com/jekyll/jekyll/blob/master/lib/jekyll/document.rb 23 | def read_content(opts = {}) 24 | return super(**opts) unless org_file? # defer to default behaviour when not org file 25 | 26 | self.content = File.read(path, **Utils.merged_file_read_opts(site, opts)) 27 | converter = site.find_converter_instance(Jekyll::Converters::Org) 28 | parser, settings = converter.parse_org(self.content) 29 | 30 | @data = Utils.deep_merge_hashes(self.data, settings) 31 | self.content = converter.actually_convert(parser) 32 | end 33 | end 34 | 35 | module OrgPage 36 | # Don't parse YAML blocks when working with an org file, parse it as 37 | # an org file and then extracts the settings from there. 38 | def read_yaml(base, name, opts = {}) 39 | extname = File.extname(name) 40 | return super unless Jekyll::Converters::Org.matches(extname) 41 | filename = File.join(base, name) 42 | 43 | self.data ||= Hash.new() 44 | self.content = File.read(@path || site.in_source_dir(base, name), 45 | **Utils.merged_file_read_opts(site, opts)) 46 | converter = site.find_converter_instance(Jekyll::Converters::Org) 47 | parser, settings = converter.parse_org(self.content) 48 | 49 | self.content = converter.actually_convert(parser) 50 | self.data = Utils.deep_merge_hashes(self.data, settings) 51 | end 52 | end 53 | 54 | class Collection 55 | # make jekyll collections aside from _posts also convert org files. 56 | def read 57 | filtered_entries.each do |file_path| 58 | full_path = collection_dir(file_path) 59 | next if File.directory?(full_path) 60 | 61 | if Utils.has_yaml_header?(full_path) || 62 | Jekyll::Converters::Org.matches_path(full_path) 63 | read_document(full_path) 64 | else 65 | read_static_file(file_path, full_path) 66 | end 67 | end 68 | 69 | # TODO remove support for jekyll 3 on 4s release 70 | (Jekyll::VERSION < '4.0') ? docs.sort! : sort_docs! 71 | end 72 | end 73 | 74 | class Reader 75 | def retrieve_org_files(dir, files) 76 | retrieve_pages(dir, files) 77 | end 78 | 79 | # don't interpret org files without YAML as static files. 80 | def retrieve_static_files(dir, files) 81 | org_files, static_files = files.partition(&Jekyll::Converters::Org.method(:matches_path)) 82 | 83 | retrieve_org_files(dir, org_files) unless org_files.empty? 84 | site.static_files.concat(StaticFileReader.new(site, dir).read(static_files)) 85 | end 86 | end 87 | end 88 | 89 | Jekyll::Document.prepend(Jekyll::OrgDocument) 90 | Jekyll::Page.prepend(Jekyll::OrgPage) 91 | -------------------------------------------------------------------------------- /lib/jekyll-org/converter.rb: -------------------------------------------------------------------------------- 1 | require 'csv' 2 | require 'org-ruby' 3 | require_relative './utils' 4 | 5 | module Jekyll 6 | module Converters 7 | class Org < Converter 8 | include Jekyll::OrgUtils 9 | 10 | safe true 11 | priority :low 12 | 13 | # true if current file is an org file 14 | def self.matches(ext) 15 | ext =~ /org/i 16 | end 17 | 18 | # matches, but accepts complete path 19 | def self.matches_path(path) 20 | matches(File.extname(path)) 21 | end 22 | 23 | def matches(ext) 24 | self.class.matches ext 25 | end 26 | 27 | def output_ext(ext) 28 | '.html' 29 | end 30 | 31 | # because by the time an org file reaches the 32 | # converter... it will have already been converted. 33 | def convert(content) 34 | content 35 | end 36 | 37 | def actually_convert(content) 38 | case content 39 | when Orgmode::Parser 40 | if liquid_enabled?(content) 41 | content.to_html.gsub("‘", "'").gsub("’", "'") 42 | else 43 | '{% raw %} ' + content.to_html + ' {% endraw %}' 44 | end 45 | else 46 | parser, variables = parse_org(content) 47 | convert(parser) 48 | end 49 | end 50 | 51 | def parse_org(content) 52 | parser = Orgmode::Parser.new(content, parser_options) 53 | settings = { :liquid => org_config.fetch("liquid", false) } 54 | 55 | parser.in_buffer_settings.each_pair do |key, value| 56 | # Remove #+TITLE from the buffer settings to avoid double exporting 57 | parser.in_buffer_settings.delete(key) if key =~ /title/i 58 | assign_setting(key, value, settings) 59 | end 60 | 61 | return parser, settings 62 | end 63 | 64 | private 65 | 66 | def config_liquid_enabled? 67 | org_config.fetch("liquid", false) 68 | end 69 | 70 | def liquid_enabled?(parser) 71 | tuple = parser.in_buffer_settings.each_pair.find do |key, _| 72 | key =~ /liquid/i 73 | end 74 | 75 | if tuple.nil? 76 | config_liquid_enabled? # default value, as per config 77 | else 78 | _parse_boolean(tuple[1], "unknown LIQUID setting") 79 | end 80 | end 81 | 82 | # see https://github.com/bdewey/org-ruby/blob/master/lib/org-ruby/parser.rb 83 | def parser_options 84 | org_config.fetch("parser_options", { markup_file: 'html.tags.yml' }) 85 | end 86 | 87 | def assign_setting(key, value, settings) 88 | key = key.downcase 89 | 90 | case key 91 | when "liquid" 92 | value = _parse_boolean(value, "unknown LIQUID setting") 93 | settings[:liquid] = value unless value.nil? 94 | when "tags", "categories" 95 | # Parse a string of tags separated by spaces into a list. 96 | # Tags containing spaces can be wrapped in quotes, 97 | # e.g. '#+TAGS: foo "with spaces"'. 98 | # 99 | # The easiest way to do this is to use rubys builtin csv parser 100 | # and use spaces instead of commas as column separator. 101 | settings[key] = CSV::parse_line(value, col_sep: ' ') 102 | else 103 | value_bool = _parse_boolean(value) 104 | settings[key] = (value_bool.nil?) ? value : value_bool 105 | end 106 | end 107 | 108 | @@truthy_regexps = [/^enabled$/, /^yes$/, /^true$/] 109 | @@falsy_regexps = [/^disabled$/, /^no$/, /^false$/] 110 | 111 | def _parse_boolean(value, error_msg=nil) 112 | case value.downcase 113 | when *@@truthy_regexps 114 | true 115 | when *@@falsy_regexps 116 | false 117 | else 118 | unless error_msg.nil? 119 | Jekyll.logger.warn("OrgDocument:", error_msg + ": #{value}") 120 | end 121 | end 122 | end 123 | end 124 | end 125 | end 126 | -------------------------------------------------------------------------------- /lib/jekyll-org/utils.rb: -------------------------------------------------------------------------------- 1 | module Jekyll 2 | module OrgUtils 3 | def self.site 4 | @@site ||= Jekyll.configuration({}) 5 | end 6 | 7 | def self.org_config 8 | site["org"] || Hash.new() 9 | end 10 | 11 | def site 12 | OrgUtils.site 13 | end 14 | 15 | def org_config 16 | OrgUtils.org_config 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /script/bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | 4 | bundle install 5 | -------------------------------------------------------------------------------- /script/cibuild: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | bundle exec rspec 5 | bundle exec rspec spec/test_jekyll-org.rb 6 | if [ "$JEKYLL_VERSION" = "3.0" ]; then 7 | bundle exec rubocop -S -D 8 | fi 9 | -------------------------------------------------------------------------------- /script/console: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby 2 | 3 | def relative_to_root(path) 4 | File.expand_path(path, File.dirname(File.dirname(__FILE__))) 5 | end 6 | 7 | require 'jekyll' 8 | require relative_to_root('lib/jekyll-org.rb') 9 | require 'pry-debugger' 10 | 11 | SOURCE_DIR = relative_to_root('spec/fixtures') 12 | DEST_DIR = relative_to_root('spec/dest') 13 | 14 | def source_dir(*files) 15 | File.join(SOURCE_DIR, *files) 16 | end 17 | 18 | def dest_dir(*files) 19 | File.join(DEST_DIR, *files) 20 | end 21 | 22 | def config(overrides = {}) 23 | Jekyll.configuration({ 24 | "source" => source_dir, 25 | "destination" => dest_dir, 26 | "url" => "http://example.org" 27 | }).merge(overrides) 28 | end 29 | 30 | def site(configuration = config) 31 | Jekyll::Site.new(configuration) 32 | end 33 | 34 | binding.pry 35 | -------------------------------------------------------------------------------- /script/release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | 4 | set -e 5 | 6 | script/cibuild 7 | bundle exec rake release 8 | -------------------------------------------------------------------------------- /spec/.#test_jekyll-org-mode-converter.rb: -------------------------------------------------------------------------------- 1 | eggcaker@Eggs-MacBook-Pro.local.472 -------------------------------------------------------------------------------- /spec/helper.rb: -------------------------------------------------------------------------------- 1 | require 'jekyll' 2 | require File.expand_path('../lib/jekyll-org', File.dirname(__FILE__)) 3 | 4 | Jekyll.logger.log_level = :error 5 | 6 | RSpec.configure do |config| 7 | config.run_all_when_everything_filtered = true 8 | config.filter_run :focus 9 | config.order = 'random' 10 | 11 | SOURCE_DIR = File.expand_path("../fixtures", __FILE__) 12 | DEST_DIR = File.expand_path("../dest", __FILE__) 13 | 14 | def source_dir(*files) 15 | File.join(SOURCE_DIR, *files) 16 | end 17 | 18 | def dest_dir(*files) 19 | File.join(DEST_DIR, *files) 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /spec/test_jekyll-org.rb: -------------------------------------------------------------------------------- 1 | require 'helper' 2 | 3 | describe("should working with unit test") do 4 | it "added some test cases" do 5 | end 6 | end 7 | --------------------------------------------------------------------------------