Skip to content

Commit

Permalink
Add manual-markdown plugin that allows explicit declaration of markdo…
Browse files Browse the repository at this point in the history
…wn blocks in liquid syntax
  • Loading branch information
quincylvania committed Jul 3, 2024
1 parent a7f52bf commit 6550724
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source "https://rubygems.org"

# these gems aren't published so we need to tell ruby where they're located
gem "absolute-urls", path: "_plugins/absolute-urls"
gem "manual-markdown", path: "_plugins/manual-markdown"
gem "post-aliases", path: "_plugins/post-aliases"
gem "unwrap-img", path: "_plugins/unwrap-img"

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ gem "osmus-dogwood", path: "dogwood"

# theme plugins
gem "absolute-urls", path: "./dogwood/_plugins/absolute-urls"
gem "manual-markdown", path: "./dogwood/_plugins/manual-markdown"
gem "post-aliases", path: "./dogwood/_plugins/post-aliases"
gem "unwrap-img", path: "./dogwood/_plugins/unwrap-img"
```
Expand Down
4 changes: 4 additions & 0 deletions _plugins/manual-markdown/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

source "https://rubygems.org"
gemspec
14 changes: 14 additions & 0 deletions _plugins/manual-markdown/lib/manual-markdown.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Jekyll
class MarkdownBlock < Liquid::Block
def initialize(tag_name, text, tokens)
super
end
require "kramdown"
def render(context)
content = super
"#{Kramdown::Document.new(content).to_html}"
end
end
end

Liquid::Template.register_tag('markdown', Jekyll::MarkdownBlock)
16 changes: 16 additions & 0 deletions _plugins/manual-markdown/manual-markdown.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

Gem::Specification.new do |spec|
spec.name = "manual-markdown"
spec.version = "0.1.0"
spec.authors = ["Quincy Morgan"]
spec.email = ["[email protected]"]

spec.summary = "Declare markdown blocks using {% markdown %} and {% endmarkdown %}"
spec.homepage = "https://github.com/osmus/dogwood"
spec.license = "MIT"

spec.files = Dir["lib/**/*"]

spec.add_runtime_dependency "jekyll", "~> 4.3"
end
1 change: 1 addition & 0 deletions dogwood.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency 'jekyll-include-cache', "~> 0.2.1"

spec.add_runtime_dependency "absolute-urls"
spec.add_runtime_dependency "manual-markdown"
spec.add_runtime_dependency "post-aliases"
spec.add_runtime_dependency "unwrap-img"
end

0 comments on commit 6550724

Please sign in to comment.