markdown-rails 0.2.1 → 2.0.0.alpha1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 332076319e0211f26f2f3fe8ddb43864df474a0f746baac13bd7ad157224ba98
4
+ data.tar.gz: e331da478c55aeb4169457f3e79c13a396e2af439c079ebd36252653f9f413a4
5
+ SHA512:
6
+ metadata.gz: ba18f8f0ae1b4f7af5b113355aaa3f43a58f366e177118d4506ac6b16d317520044a86ce69a3436da6cb1b7f96e3ef225557996fbb309ac9fb7e16c7f8823734
7
+ data.tar.gz: f7d859e209008e71bdc8c6c1ba5ae5f63b1f0f4b71ce43b36b8682af5b96761f49c842cc255fe9cef05d33d71d8820247461078698d62678a4aa8763523b26df
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2022 Brad Gessler
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,23 +1,99 @@
1
1
  # markdown-rails
2
2
 
3
- [![Dependency Status](https://gemnasium.com/joliss/markdown-rails.png)](https://gemnasium.com/joliss/markdown-rails)
3
+ > **Note**
4
+ > **Everything below will be implemented in 2.0.0.alpha1, which is not yet released.** This was written to get feedback about the Dev UX of this gem as the proof-of-concept is brought over from https://github.com/bradgessler/view-playground.
5
+ > You can start using this by adding to `gem "markdown-rails", github: "sitepress/markdown-rails"` to your Gemfile.
4
6
 
5
- This gem allows you to write static Rails views and partials using the
6
- [Markdown](http://daringfireball.net/projects/markdown/syntax) syntax. No more
7
- editing prose in HTML!
7
+ This gem allows you to write static Rails views and partials using the [Markdown](http://daringfireball.net/projects/markdown/syntax) syntax. No more editing prose in HTML!
8
+
9
+ It is a comprehensive Markdown library for Rails that addresses the following pain points:
10
+
11
+ * Renders markdown files and partials that you can throw in your Rails view paths, like `./app/views/people/profile.html.md`.
12
+ * Parse Erb blocks in markdown files.
13
+ * Customize markdown tags like `![]()` to support embeds beyond images like YouTube links, code fences for syntax highlighting, etc.
14
+ * Plug into Rails asset pipeline so images defined in Markdown will be loaded from the forever-cached image assets.
15
+ * Define multiple markdown renders so you can render more dangerous-user upload markdown content vs markdown that you can trust, like content files checked into your Rails project.
16
+
17
+ This project is used heavily by https://sitepress.cc to manage content files in Rails, but it can be used on its own for Rails views.
8
18
 
9
19
  ## Usage
10
20
 
11
- Add the following to your Gemfile:
21
+ Add the following to your application's Gemfile:
22
+
23
+ ```sh
24
+ $ bundle add 'markdown-rails'
25
+ ```
26
+
27
+ Then from the root of your Rails project, run:
28
+
29
+ ```sh
30
+ $ bin/rails g markdown:install
31
+ ```
32
+
33
+ This adds a `config/initializers/markdown.rb` file where you can register template handlers for your Markdown renders that are located in `./app/markdown/*.rb`.
34
+
35
+ Now add views or partials ending in `.md` in your `./app/views/**/**` directories and behold!
36
+
37
+ ## Configuration
38
+
39
+ Applications commonly need various markdown variants within one application. For example,
40
+
12
41
 
13
42
  ```ruby
14
- gem 'markdown-rails'
43
+ # ./config/initializers/markdown.rb
44
+ # Restart your server after making changes to these files.
45
+
46
+ # Renders markdown without Erb, which is safe for user inputs
47
+ # unless you have some crazy unsafe blocks in the `ApplicationMarkdown` stack.
48
+ MarkdownRails::Handler.register :md do
49
+ ApplicationMarkdown.new
50
+ end
51
+
52
+ # Use Erb in markdown templates, which is NOT safe for untrusted inputs
53
+ # like blog post from a user. You should only use this for content that
54
+ # you trust won't execute arbitrary Ruby code like views and templates in
55
+ # your repo.
56
+ MarkdownRails::ErbHandler.register :markerb do
57
+ ApplicationMarkdown.new
58
+ end
15
59
  ```
16
60
 
17
- Now add views or partials ending in `.md` or `.markdown`.
61
+ You might want to customize your Markdown handlers to do things like syntax code highlighting, etc. Here's what that looks like:
62
+
63
+ ```ruby
64
+ # ./app/markdown/application_markdown.rb
65
+ class ApplicationMarkdown < RailsMarkdown
66
+ include Redcarpet::Render::SmartyPants
67
+
68
+ def enable
69
+ [:fenced_code_blocks]
70
+ end
71
+
72
+ def block_code(code, language)
73
+ render Views::CodeBlock.new(code, syntax: language)
74
+ end
75
+
76
+ def image(link, title, alt)
77
+ url = URI(link)
78
+ case url.host
79
+ when "www.youtube.com"
80
+ render Views::YoutubeEmbed.new(url)
81
+ else
82
+ super
83
+ end
84
+ end
85
+
86
+ private
87
+ def render(component)
88
+ component.call
89
+ end
90
+ end
91
+ ```
18
92
 
19
93
  ## Examples
20
94
 
95
+ Your best bet is to use this with a content management site like https://sitepress.cc/ if you're going to be dealing with a lot of markdown content on your website.
96
+
21
97
  ### Static View
22
98
 
23
99
  In `app/views/home/about.html.md`:
@@ -28,9 +104,7 @@ In `app/views/home/about.html.md`:
28
104
  *Markdown code goes here ...*
29
105
  ```
30
106
 
31
- Keep in mind that unlike static files dropped in `public`, you still need a
32
- matching route, such as `get ':action', :controller => :home`, to route
33
- `/about` to `home#about`.
107
+ Keep in mind that unlike static files dropped in `public`, you still need a matching route, such as `get ':action', :controller => :home`, to route `/about` to `home#about`. You could also [use Sitepress](https://sitepress.cc) to automatically manage these routes for you if you're dealing with a lot of pages.
34
108
 
35
109
  ### Static Partial
36
110
 
@@ -57,62 +131,7 @@ mode](http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#ugly-option),
57
131
  causing leading white-space to appear in development mode. To fix this, set
58
132
  `Haml::Template.options[:ugly] = true`.
59
133
 
60
- ## Configuration
61
-
62
- By default markdown-rails uses the
63
- [RDiscount](https://github.com/rtomayko/rdiscount) parser. You can change this
64
- by calling `config.render` like so:
65
-
66
- ```ruby
67
- MarkdownRails.configure do |config|
68
- config.render do |markdown_source|
69
- # Return compiled HTML here ...
70
- end
71
- end
72
- ```
73
-
74
- You might in particular want to use
75
- [Redcarpet](https://github.com/tanoku/redcarpet), which allows you to enable
76
- various aspects of [GitHub Flavored
77
- Markdown](http://github.github.com/github-flavored-markdown/) through its
78
- parser options. To do so, add the `redcarpet` gem to your Gemfile, and add the
79
- following into a `config/initializers/markdown.rb` file:
80
-
81
- ```ruby
82
- MarkdownRails.configure do |config|
83
- markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
84
- :fenced_code_blocks => true,
85
- :autolink => true,
86
- ... etc ...)
87
- config.render do |markdown_source|
88
- markdown.render(markdown_source)
89
- end
90
- end
91
- ```
92
134
 
93
135
  ## Security
94
136
 
95
- Despite Markdown being a static language, you should not use this gem to
96
- process untrusted Markdown views (or partials). In other words, do not add
97
- Markdown views from a source if you wouldn't trust Erb views from them.
98
-
99
- ## Limitations
100
-
101
- * It's not possible to embed Ruby code in the Markdown code. Unfortunately,
102
- you cannot simply chain template handlers (`.md.erb`) like you can with
103
- asset handlers. This is reasonable if you consider that unlike assets,
104
- templates are precompiled not into strings but into Ruby code, which is
105
- then called every time the template is served. Still, the performance of
106
- modern Markdown parsers is good enough that you could afford to reparse the
107
- Markdown on every template view, so having Markdown with Erb in it should
108
- be possible in principle.
109
-
110
- In the meantime, you can [use HAML's :markdown
111
- filter](http://stackoverflow.com/a/4418389/525872) to the same effect.
112
-
113
- * The only truly Markdown-specific code in the source is
114
- `RDiscount.new(markdown_source).to_html` and the `.md`/`.markdown` file
115
- name extensions. This gem can and should be generalized into a
116
- general-purpose static template gem, so that you can easily use other
117
- static templating languages in Rails. Perhaps
118
- [tilt](https://github.com/rtomayko/tilt) will come in useful.
137
+ Despite Markdown being a static language, you should not use this gem to process untrusted Markdown views (or partials). In other words, do not add Markdown views from a source if you wouldn't trust Erb views from them.
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/setup"
2
+
3
+ load "rails/tasks/statistics.rake"
4
+
5
+ require "bundler/gem_tasks"
File without changes
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ bin/rails generate install Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,8 @@
1
+ class Markdown::InstallGenerator < Rails::Generators::Base
2
+ source_root File.expand_path("templates", __dir__)
3
+
4
+ def copy_files
5
+ directory "app"
6
+ directory "config"
7
+ end
8
+ end
@@ -0,0 +1,60 @@
1
+ # You should read the docs at https://github.com/vmg/redcarpet and probably
2
+ # delete a bunch of stuff below if you don't need it.
3
+
4
+ class ApplicationMarkdown < Markdown::Rails::Renderers::Rails
5
+ # Reformats your boring punctation like " and " into “ and ” so you can look
6
+ # and feel smarter. Read the docs at https://github.com/vmg/redcarpet#also-now-our-pants-are-much-smarter
7
+ include Redcarpet::Render::SmartyPants
8
+
9
+ # If you need access to ActionController::Base.helpers, you can delegate by uncommenting
10
+ # and adding to the list below. Several are already included for you in the `Markdown::Rails::Renderers::Rails`,
11
+ # but you can add more here.
12
+ #
13
+ # To see a list of methods available run `bin/rails runner "puts ActionController::Base.helpers.public_methods.sort"`
14
+ #
15
+ # delegate \
16
+ # :request,
17
+ # :cache,
18
+ # :turbo_frame_tag,
19
+ # to: :helpers
20
+
21
+ # These flags control features in the Redcarpet renderer, which you can read
22
+ # about at https://github.com/vmg/redcarpet#and-its-like-really-simple-to-use
23
+ # Make sure you know what you're doing if you're using this to render user inputs.
24
+ def enable
25
+ [:fenced_code_blocks]
26
+ end
27
+
28
+ # These methods are called as the Markdown document is parsed. Block-level calls are
29
+ # documented at https://github.com/vmg/redcarpet#block-level-calls and span level calls
30
+ # are documented at https://github.com/vmg/redcarpet#block-level-calls so feel free to
31
+ # add more as you see fit.
32
+ def block_code(code, language)
33
+ content_tag :pre, class: language do
34
+ code # You could implement syntax highlighting here with Rouge.
35
+ end
36
+ end
37
+
38
+ # Example of how you might override the images to show embeds, like a YouTube video.
39
+ def image(link, title, alt)
40
+ url = URI(link)
41
+ case url.host
42
+ when "www.youtube.com"
43
+ youtube_tag url
44
+ else
45
+ super
46
+ end
47
+ end
48
+
49
+ private
50
+ # This is provided as an example; there's many more YouTube URLs that this wouldn't catch.
51
+ def youtube_tag(url)
52
+ embed_url = "https://www.youtube-nocookie.com/embed/#{CGI.parse(url.query).fetch("v").first}"
53
+ tag :iframe,
54
+ width: 560,
55
+ height: 325,
56
+ src: embed_url,
57
+ allow: "encrypted-media; picture-in-picture",
58
+ allowfullscreen: true
59
+ end
60
+ end
@@ -0,0 +1,17 @@
1
+ # Restart the server to see changes made to this file.
2
+
3
+ # Setup markdown stacks to work with different template handlers in Rails.
4
+ Markdown::Rails.handle :md, :markdown do
5
+ ApplicationMarkdown.new
6
+ end
7
+
8
+ # Don't use Erb for untrusted markdown content created by users; otherwise they
9
+ # can execute arbitrary code on your server. This should only be used for input you
10
+ # trust, like content files from your code repo.
11
+ #
12
+ # Make sure you know what you're doing before you uncomment the block below to get
13
+ # Erb working with Markdown.
14
+
15
+ # Markdown::Rails.handle :markerb, with: Markdown::Rails::Handlers::Erb do
16
+ # ApplicationMarkdown.new
17
+ # end
@@ -0,0 +1,6 @@
1
+ module Markdown
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,24 @@
1
+ module Markdown
2
+ module Rails
3
+ module Handlers
4
+ class Erb < Markdown
5
+ def call(template, source = template.source)
6
+ compiled_source = compile_erb template, source
7
+ # TODO: This won't properly handle initializer blocks. Somehow
8
+ # I need to pass a reference to the block that's passed in.
9
+ "#{markdown.class.name}.new.renderer.render(begin;#{compiled_source};end).html_safe"
10
+ end
11
+
12
+ private
13
+
14
+ def compile_erb(template, source)
15
+ erb.call(template, source)
16
+ end
17
+
18
+ def erb
19
+ ActionView::Template.registered_template_handler(:erb)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,39 @@
1
+ module Markdown
2
+ module Rails
3
+ module Handlers
4
+ # We cannot use Markdown::Rails because it conflicts with RDiscount's Markdown class
5
+ class Markdown
6
+ def initialize(&block)
7
+ @markdown = block
8
+ end
9
+
10
+ def call(template, source = template.source)
11
+ renderer.render(source).inspect + '.html_safe'
12
+ end
13
+
14
+ def self.handle(*extensions, &block)
15
+ Array(extensions).each do |extension|
16
+ handler = new &block
17
+ ActionView::Template.register_template_handler extension, handler
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def markdown
24
+ @cache = nil unless cache_enabled?
25
+ @cache ||= @markdown.call
26
+ end
27
+
28
+ def renderer
29
+ @renderer = nil unless cache_enabled?
30
+ @renderer ||= markdown.renderer
31
+ end
32
+
33
+ def cache_enabled?
34
+ ::Rails.configuration.cache_classes
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,6 @@
1
+ module Markdown
2
+ module Rails
3
+ class Railtie < ::Rails::Railtie
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,28 @@
1
+ module Markdown
2
+ module Rails
3
+ module Renderers
4
+ class Base < Redcarpet::Render::HTML
5
+ def enable
6
+ # This is a very restrictive Markdown renderer that errs on the side of safety.
7
+ # For more details read the docs at https://github.com/vmg/redcarpet#darling-i-packed-you-a-couple-renderers-for-lunch
8
+ [
9
+ :filter_html,
10
+ :no_images,
11
+ :no_links,
12
+ :no_styles,
13
+ :safe_links_only
14
+ ]
15
+ end
16
+
17
+ def renderer
18
+ ::Redcarpet::Markdown.new(self.class, **features)
19
+ end
20
+
21
+ private
22
+ def features
23
+ Hash[Array(enable).map{ |feature| [ feature, true ] }]
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,41 @@
1
+ module Markdown
2
+ module Rails
3
+ module Renderers
4
+ class Rails < Base
5
+ include ::Rails.application.routes.url_helpers
6
+
7
+ delegate \
8
+ :asset_digest_path,
9
+ :asset_path,
10
+ :asset_url,
11
+ :audio_path,
12
+ :audio_tag,
13
+ :audio_url,
14
+ :font_path,
15
+ :font_url,
16
+ :image_path,
17
+ :image_tag,
18
+ :image_url,
19
+ :video_path,
20
+ :video_tag,
21
+ :video_url,
22
+ :tag,
23
+ :content_tag,
24
+ :render,
25
+ :request,
26
+ :turbo_frame_tag,
27
+ :controller,
28
+ to: :helpers
29
+
30
+ def image(link, title, alt)
31
+ image_tag link, title: title, alt: alt
32
+ end
33
+
34
+ protected
35
+ def helpers
36
+ ::ActionController::Base.helpers
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,5 @@
1
+ module Markdown
2
+ module Rails
3
+ VERSION = "2.0.0.alpha1"
4
+ end
5
+ end
@@ -0,0 +1,20 @@
1
+ require "markdown/rails/version"
2
+ require "markdown/rails/engine"
3
+
4
+ module Markdown
5
+ module Rails
6
+ def self.handle(*extensions, with: Handlers::Markdown, &block)
7
+ with.handle *extensions, &block
8
+ end
9
+
10
+ module Handlers
11
+ autoload :Markdown, "markdown/rails/handlers/markdown"
12
+ autoload :Erb, "markdown/rails/handlers/erb"
13
+ end
14
+
15
+ module Renderers
16
+ autoload :Base, "markdown/rails/renderers/base"
17
+ autoload :Rails, "markdown/rails/renderers/rails"
18
+ end
19
+ end
20
+ end
@@ -1,2 +1 @@
1
- require 'markdown-rails/version'
2
- require 'markdown-rails/engine'
1
+ require "markdown/rails"
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :markdown_rails do
3
+ # # Task goes here
4
+ # end
metadata CHANGED
@@ -1,93 +1,94 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
5
- prerelease:
4
+ version: 2.0.0.alpha1
6
5
  platform: ruby
7
6
  authors:
8
- - Jo Liss
9
- autorequire:
7
+ - Brad Gessler
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-08-16 00:00:00.000000000 Z
11
+ date: 2022-09-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: 7.0.4
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: '0'
26
+ version: 7.0.4
30
27
  - !ruby/object:Gem::Dependency
31
- name: rdiscount
28
+ name: redcarpet
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
- version: 1.6.8
38
- - - <
39
- - !ruby/object:Gem::Version
40
- version: '2.0'
33
+ version: 3.0.0
41
34
  type: :runtime
42
35
  prerelease: false
43
36
  version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
37
  requirements:
46
- - - ! '>='
47
- - !ruby/object:Gem::Version
48
- version: 1.6.8
49
- - - <
38
+ - - ">="
50
39
  - !ruby/object:Gem::Version
51
- version: '2.0'
52
- description: Markdown as a static templating language for Rails views and partials
40
+ version: 3.0.0
41
+ description: Markdown Rails is a comprehensive stack for rendering Markdown templates
42
+ and partials in Rails.
53
43
  email:
54
- - joliss42@gmail.com
44
+ - bradgessler@gmail.com
55
45
  executables: []
56
46
  extensions: []
57
47
  extra_rdoc_files: []
58
48
  files:
59
- - .gitignore
60
- - Gemfile
61
- - History.md
62
- - License.txt
49
+ - MIT-LICENSE
63
50
  - README.md
51
+ - Rakefile
52
+ - app/assets/config/markdown_rails_manifest.js
53
+ - lib/generators/markdown/install/USAGE
54
+ - lib/generators/markdown/install/install_generator.rb
55
+ - lib/generators/markdown/install/templates/app/markdown/application_markdown.rb
56
+ - lib/generators/markdown/install/templates/config/initializers/markdown.rb
64
57
  - lib/markdown-rails.rb
65
- - lib/markdown-rails/engine.rb
66
- - lib/markdown-rails/version.rb
67
- - markdown-rails.gemspec
68
- homepage: https://github.com/joliss/markdown-rails
69
- licenses: []
70
- post_install_message:
58
+ - lib/markdown/rails.rb
59
+ - lib/markdown/rails/engine.rb
60
+ - lib/markdown/rails/handlers/erb.rb
61
+ - lib/markdown/rails/handlers/markdown.rb
62
+ - lib/markdown/rails/railtie.rb
63
+ - lib/markdown/rails/renderers/base.rb
64
+ - lib/markdown/rails/renderers/rails.rb
65
+ - lib/markdown/rails/version.rb
66
+ - lib/tasks/markdown/rails_tasks.rake
67
+ homepage: https://github.com/sitepress/markdown-rails
68
+ licenses:
69
+ - MIT
70
+ metadata:
71
+ allowed_push_host: https://rubygems.org/
72
+ homepage_uri: https://github.com/sitepress/markdown-rails
73
+ source_code_uri: https://github.com/sitepress/markdown-rails
74
+ changelog_uri: https://github.com/sitepress/markdown-rails
75
+ post_install_message:
71
76
  rdoc_options: []
72
77
  require_paths:
73
78
  - lib
74
79
  required_ruby_version: !ruby/object:Gem::Requirement
75
- none: false
76
80
  requirements:
77
- - - ! '>='
81
+ - - ">="
78
82
  - !ruby/object:Gem::Version
79
83
  version: '0'
80
84
  required_rubygems_version: !ruby/object:Gem::Requirement
81
- none: false
82
85
  requirements:
83
- - - ! '>='
86
+ - - ">"
84
87
  - !ruby/object:Gem::Version
85
- version: 1.3.6
88
+ version: 1.3.1
86
89
  requirements: []
87
- rubyforge_project:
88
- rubygems_version: 1.8.23
89
- signing_key:
90
- specification_version: 3
91
- summary: Markdown as a Rails templating language
90
+ rubygems_version: 3.3.7
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Markdown templates and partials in Rails.
92
94
  test_files: []
93
- has_rdoc:
data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- Gemfile.lock
2
- *.gem
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source :rubygems
2
-
3
- gemspec
data/History.md DELETED
@@ -1,12 +0,0 @@
1
- # 0.2.1
2
-
3
- * Add support for Rails 2.x
4
-
5
- # 0.2.0
6
-
7
- * Use MarkdownRails instead of Markdown::Rails to avoid conflict with
8
- RDiscount's Markdown class
9
-
10
- # 0.1.0
11
-
12
- * Initial release
data/License.txt DELETED
@@ -1,19 +0,0 @@
1
- Copyright (c) 2012 Jo Liss
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all
11
- copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- SOFTWARE.
@@ -1,54 +0,0 @@
1
- require 'rdiscount'
2
- require 'action_view'
3
-
4
- # We cannot use Markdown::Rails because it conflicts with RDiscount's Markdown class
5
- module MarkdownRails
6
- class Handler
7
- def initialize
8
- end
9
-
10
- def call(template)
11
- # Return Ruby code that returns the compiled template
12
- MarkdownRails.renderer.call(template.source).inspect + '.html_safe'
13
- end
14
- end
15
-
16
- class <<self
17
- def configure
18
- yield self
19
- end
20
-
21
- attr_accessor :renderer
22
-
23
- def render(&block)
24
- self.renderer = block
25
- end
26
- end
27
- end
28
-
29
- MarkdownRails.configure do |config|
30
- config.render do |markdown_source|
31
- RDiscount.new(markdown_source).to_html
32
- end
33
- end
34
-
35
- handler = MarkdownRails::Handler.new
36
-
37
- [:md, :markdown].each do |extension|
38
- # >= v3.0.5
39
- if defined? ActionView::Template::Handlers and ActionView::Template::Handlers.respond_to? :register_template_handler
40
- ActionView::Template::Handlers
41
- # >= v2.1.0 <= v2.1.0
42
- elsif defined? ActionView::Template and ActionView::Template.respond_to? :register_template_handler
43
- ActionView::Template
44
- # >= v2.2.1 <= v2.3.8
45
- elsif defined? ActionView::TemplateHandlers and ActionView::TemplateHandlers.respond_to? :register_template_handler
46
- ActionView::TemplateHandlers
47
- # <= v2.0.3
48
- elsif defined? ActionView::Base and ActionView::Base.respond_to? :register_template_handler
49
- ActionView::Base
50
- # I give up...
51
- else
52
- raise "Couldn't find `register_template_handler' method in ActionView module."
53
- end.register_template_handler extension, handler
54
- end
@@ -1,3 +0,0 @@
1
- module MarkdownRails
2
- VERSION = "0.2.1"
3
- end
@@ -1,21 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/markdown-rails/version', __FILE__)
3
-
4
- Gem::Specification.new do |s|
5
- s.name = "markdown-rails"
6
- s.version = MarkdownRails::VERSION
7
- s.authors = ["Jo Liss"]
8
- s.email = ["joliss42@gmail.com"]
9
- s.homepage = "https://github.com/joliss/markdown-rails"
10
- s.summary = "Markdown as a Rails templating language"
11
- s.description = "Markdown as a static templating language for Rails views and partials"
12
-
13
- s.required_rubygems_version = ">= 1.3.6"
14
-
15
- s.add_dependency "rails"
16
- s.add_dependency "rdiscount", [">= 1.6.8", "< 2.0"]
17
-
18
- s.files = `git ls-files`.split("\n").reject { |f| f =~ /^testapp/ }
19
- s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
20
- s.require_path = 'lib'
21
- end