markdown-rails 1.0.0 → 2.0.0.alpha2

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
2
  SHA256:
3
- metadata.gz: a772de4398029a4fa7ccb067e3c3c6ac59db0fbcbacffd89e6227fc048038105
4
- data.tar.gz: 78d68659281c660e18c31a5175ca44ecc8347263cde3b317921ca93700d4890d
3
+ metadata.gz: ff3573eb380c93787dd4df94e7244809402da5a8bd59482aa2b6606b6294f154
4
+ data.tar.gz: 7de29bab934217a0a8f38ff868d6fe7d0fa87d8c9a3b2de8c93a27d5f61496d8
5
5
  SHA512:
6
- metadata.gz: 3250a18ee33f9200d8798353dffb59dfabd3063cf78550b6689e962c0dd278bfad30a0878ae3d3fcef1ca861d48f9b32f8ee25713dad858041e5cfcc03ca2f4f
7
- data.tar.gz: ba0c2637b6ab5ef69da35b691832dc529cfbd2f831731d5ae42dcf6950574eee19ba3dd0f410879206a5eb82eee06a9eaa68ffc8e06984ca7b58c542023e3369
6
+ metadata.gz: b4f738f2f721f7d542f8986d0c63a7f1ac27f266d46091d938afa086b1c08ed967a8e77ebd9a4c8964787d3bddf396ba9eb86e9dd78bf511b937c182f9ce7127
7
+ data.tar.gz: 85496233bed31fabcc2585f9e9ef30f92a295b456058bce2d35228ac4e284bc276804570cedddbbfb399cac8f7594d3f69f40d0f1332e8c35d2afa1f39a67762
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,28 +1,138 @@
1
- **For a perhaps better solution for .html.md files that also supports
2
- embedding Erb in your Markdown, check out @wjbuys's [answer on
3
- Stackoverflow](http://stackoverflow.com/a/10131299/525872).**
1
+ # markdown-rails
4
2
 
5
- ------------------------
3
+ > **Note**
4
+ > **Everything below is implemented in 2.0.0.alpha1.** . You can start using this by adding to `gem "markdown-rails", version: "2.0.0.alpha"` to your Gemfile or by looking at it being used in the https://github.com/bradgessler/view-playground repo.
6
5
 
7
- # markdown-rails
6
+ 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!
7
+
8
+ It is a comprehensive Markdown library for Rails that addresses the following pain points:
8
9
 
9
- This gem allows you to write static Rails views and partials using the
10
- [Markdown](http://daringfireball.net/projects/markdown/syntax) syntax. No more
11
- editing prose in HTML!
10
+ * Renders markdown files and partials that you can throw in your Rails view paths, like `./app/views/people/profile.html.md`.
11
+ * Parse Erb blocks in markdown files.
12
+ * Customize markdown tags like `![]()` to support embeds beyond images like YouTube links, code fences for syntax highlighting, etc.
13
+ * Plug into Rails asset pipeline so images defined in Markdown will be loaded from the forever-cached image assets.
14
+ * 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.
15
+
16
+ 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.
12
17
 
13
18
  ## Usage
14
19
 
15
- Add the following to your Gemfile:
20
+ Add the following to your application's Gemfile:
21
+
22
+ ```sh
23
+ $ bundle add 'markdown-rails'
24
+ ```
25
+
26
+ Then from the root of your Rails project, run:
27
+
28
+ ```sh
29
+ $ bin/rails g markdown:install
30
+ ```
31
+
32
+ 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`.
33
+
34
+ Now add views or partials ending in `.md` in your `./app/views/**/**` directories and behold!
35
+
36
+ ### Upgrading from 1.x
37
+
38
+ Change your applications Gemfile to read:
39
+
40
+ ```ruby
41
+ gem "markdown-rails", "~> 2.0.0"
42
+ ```
43
+
44
+ Then from the root of your Rails project, run:
45
+
46
+ ```sh
47
+ $ bin/rails g markdown:install
48
+ ```
49
+
50
+ If you have an existing file in `config/initializers/markdown.rb` you'll need to move those settings over. Note that 1.x used `RDiscount` as the default renderer, which was replaced by `Redcarpet` in 2.x.
51
+
52
+ ## Configuration
53
+
54
+ Applications commonly need various markdown variants within one application. For example,
55
+
56
+ ```ruby
57
+ # ./config/initializers/markdown.rb
58
+ # Restart the server to see changes made to this file.
59
+
60
+ # Setup markdown stacks to work with different template handlers in Rails.
61
+ Markdown::Rails.handle :md do
62
+ ApplicationMarkdown.new
63
+ end
64
+
65
+ Markdown::Rails.handle :crazymd do
66
+ MyCrazyMarkdown.new
67
+ end
68
+ ```
69
+
70
+ ### Enable Erb in Markdown
71
+
72
+ Only enable Erb in Markdown if you trust the source of the file. Do not enable it for markdown provided by users or they will be able to execute arbitrary Ruby code.
73
+
74
+ To enable Erb, you can tell Rails to render all view files ending with `.markerb` using the `Markdown::Rails::Handlers::Erb` handler.
16
75
 
17
76
  ```ruby
18
- gem 'markdown-rails'
77
+ # ./config/initializers/markdown.rb
78
+ Markdown::Rails.handle :markerb, with: Markdown::Rails::Handlers::Erb do
79
+ ApplicationMarkdown.new
80
+ end
19
81
  ```
20
82
 
21
- Now add views or partials ending in `.md` or `.markdown`.
83
+ You *could* change `:markerb` to `:md`, but I don't recommend it for all Markdown files or you'll run into problems if you have content like `<%= Time.current %>` inside of an `erb` codefence. You're better off having two configurations: one that handles Erb and another that doesn't, like this:
84
+
85
+ ```ruby
86
+ # ./config/initializers/markdown.rb
87
+ # Restart the server to see changes made to this file.
88
+
89
+ # Setup markdown stacks to work with different template handlers in Rails.
90
+ Markdown::Rails.handle :md do
91
+ ApplicationMarkdown.new
92
+ end
93
+
94
+ Markdown::Rails.handle :markerb, with: Markdown::Rails::Handlers::Erb do
95
+ ApplicationMarkdown.new
96
+ end
97
+ ```
98
+
99
+ ## Customizing renderers
100
+
101
+ You might want to customize your Markdown handlers to do things like syntax code highlighting, etc.
102
+
103
+ ```ruby
104
+ # ./app/markdown/application_markdown.rb
105
+ require "rouge"
106
+
107
+ class ApplicationMarkdown < RailsMarkdown
108
+ include Redcarpet::Render::SmartyPants
109
+
110
+ FORMATTER = Rouge::Formatters::HTMLInline.new("monokai.sublime")
111
+
112
+ def enable
113
+ [:fenced_code_blocks]
114
+ end
115
+
116
+ def block_code(code, language)
117
+ lexer = Rouge::Lexer.find(language)
118
+ content_tag :pre, class: language do
119
+ raw FORMATTER.format(lexer.lex(code))
120
+ end
121
+ end
122
+ end
123
+ ```
124
+
125
+ Consider using a componet farmework, like [phlex](https://www.phlex.fun) to generate tags outside of the Rails view context.
22
126
 
23
127
  ## Examples
24
128
 
25
- ### Static View
129
+ There's a lot of ways to use Markdown in your Rails app.
130
+
131
+ ### The easy way
132
+
133
+ 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.
134
+
135
+ ### Static view
26
136
 
27
137
  In `app/views/home/about.html.md`:
28
138
 
@@ -32,11 +142,9 @@ In `app/views/home/about.html.md`:
32
142
  *Markdown code goes here ...*
33
143
  ```
34
144
 
35
- Keep in mind that unlike static files dropped in `public`, you still need a
36
- matching route, such as `get ':action', :controller => :home`, to route
37
- `/about` to `home#about`.
145
+ 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.
38
146
 
39
- ### Static Partial
147
+ ### Static partial
40
148
 
41
149
  In `app/views/posts/edit.html.erb`:
42
150
 
@@ -55,68 +163,8 @@ In `app/views/posts/_edit_help.html.md`:
55
163
  This text is written in **Markdown**. :-)
56
164
  ```
57
165
 
58
- Note: If you are including Markdown partials from a Haml view, `<pre>` blocks
59
- inside your Markdown may be indented when Haml is not in ["ugly" (production)
60
- mode](http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#ugly-option),
61
- causing leading white-space to appear in development mode. To fix this, set
62
- `Haml::Template.options[:ugly] = true`.
63
-
64
- ## Configuration
65
-
66
- By default markdown-rails uses the
67
- [RDiscount](https://github.com/rtomayko/rdiscount) parser. You can change this
68
- by calling `config.render` like so:
69
-
70
- ```ruby
71
- MarkdownRails.configure do |config|
72
- config.render do |markdown_source|
73
- # Return compiled HTML here ...
74
- end
75
- end
76
- ```
77
-
78
- You might in particular want to use
79
- [Redcarpet](https://github.com/tanoku/redcarpet), which allows you to enable
80
- various aspects of [GitHub Flavored
81
- Markdown](http://github.github.com/github-flavored-markdown/) through its
82
- parser options. To do so, add the `redcarpet` gem to your Gemfile, and add the
83
- following into a `config/initializers/markdown.rb` file:
84
-
85
- ```ruby
86
- MarkdownRails.configure do |config|
87
- markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
88
- :fenced_code_blocks => true,
89
- :autolink => true,
90
- ... etc ...)
91
- config.render do |markdown_source|
92
- markdown.render(markdown_source)
93
- end
94
- end
95
- ```
166
+ Note: If you are including Markdown partials from a Haml view, `<pre>` blocks inside your Markdown may be indented when Haml is not in ["ugly" (production) mode](http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#ugly-option), causing leading white-space to appear in development mode. To fix this, set `Haml::Template.options[:ugly] = true`.
96
167
 
97
168
  ## Security
98
169
 
99
- Despite Markdown being a static language, you should not use this gem to
100
- process untrusted Markdown views (or partials). In other words, do not add
101
- Markdown views from a source if you wouldn't trust Erb views from them.
102
-
103
- ## Limitations
104
-
105
- * It's not possible to embed Ruby code in the Markdown code. Unfortunately,
106
- you cannot simply chain template handlers (`.md.erb`) like you can with
107
- asset handlers. This is reasonable if you consider that unlike assets,
108
- templates are precompiled not into strings but into Ruby code, which is
109
- then called every time the template is served. Still, the performance of
110
- modern Markdown parsers is good enough that you could afford to reparse the
111
- Markdown on every template view, so having Markdown with Erb in it should
112
- be possible in principle.
113
-
114
- In the meantime, you can [use HAML's :markdown
115
- filter](http://stackoverflow.com/a/4418389/525872) to the same effect.
116
-
117
- * The only truly Markdown-specific code in the source is
118
- `RDiscount.new(markdown_source).to_html` and the `.md`/`.markdown` file
119
- name extensions. This gem can and should be generalized into a
120
- general-purpose static template gem, so that you can easily use other
121
- static templating languages in Rails. Perhaps
122
- [tilt](https://github.com/rtomayko/tilt) will come in useful.
170
+ 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 CHANGED
@@ -1 +1,5 @@
1
+ require "bundler/setup"
2
+
3
+ load "rails/tasks/statistics.rake"
4
+
1
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,61 @@
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, alt
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, alt)
52
+ embed_url = "https://www.youtube-nocookie.com/embed/#{CGI.parse(url.query).fetch("v").first}"
53
+ content_tag :iframe,
54
+ src: embed_url,
55
+ width: 560,
56
+ height: 325,
57
+ allow: "encrypted-media; picture-in-picture",
58
+ allowfullscreen: true \
59
+ do alt end
60
+ end
61
+ end
@@ -0,0 +1,13 @@
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
+ Markdown::Rails.handle :markerb, with: Markdown::Rails::Handlers::Erb do
12
+ ApplicationMarkdown.new
13
+ 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,42 @@
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
+ :raw,
29
+ to: :helpers
30
+
31
+ def image(link, title, alt)
32
+ image_tag link, title: title, alt: alt
33
+ end
34
+
35
+ protected
36
+ def helpers
37
+ ::ActionController::Base.helpers
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,5 @@
1
+ module Markdown
2
+ module Rails
3
+ VERSION = "2.0.0.alpha2"
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0.alpha2
5
5
  platform: ruby
6
6
  authors:
7
- - Jo Liss
7
+ - Brad Gessler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-19 00:00:00.000000000 Z
11
+ date: 2022-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,49 +16,62 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 7.0.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 7.0.4
27
27
  - !ruby/object:Gem::Dependency
28
- name: rdiscount
28
+ name: redcarpet
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.6.8
33
+ version: 3.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 1.6.8
41
- 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.
42
43
  email:
43
- - joliss42@gmail.com
44
+ - bradgessler@gmail.com
44
45
  executables: []
45
46
  extensions: []
46
47
  extra_rdoc_files: []
47
48
  files:
48
- - ".gitignore"
49
- - CODE_OF_CONDUCT.md
50
- - Gemfile
51
- - History.md
52
- - License.txt
49
+ - MIT-LICENSE
53
50
  - README.md
54
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
55
57
  - lib/markdown-rails.rb
56
- - lib/markdown-rails/engine.rb
57
- - lib/markdown-rails/version.rb
58
- - markdown-rails.gemspec
59
- homepage: https://github.com/joliss/markdown-rails
60
- licenses: []
61
- metadata: {}
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
62
75
  post_install_message:
63
76
  rdoc_options: []
64
77
  require_paths:
@@ -70,12 +83,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
70
83
  version: '0'
71
84
  required_rubygems_version: !ruby/object:Gem::Requirement
72
85
  requirements:
73
- - - ">="
86
+ - - ">"
74
87
  - !ruby/object:Gem::Version
75
- version: 1.3.6
88
+ version: 1.3.1
76
89
  requirements: []
77
- rubygems_version: 3.1.4
90
+ rubygems_version: 3.3.7
78
91
  signing_key:
79
92
  specification_version: 4
80
- summary: Markdown as a Rails templating language
93
+ summary: Markdown templates and partials in Rails.
81
94
  test_files: []
data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- Gemfile.lock
2
- *.gem
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at brad@polleverywhere.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [https://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: https://contributor-covenant.org
74
- [version]: https://contributor-covenant.org/version/1/4/
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, source = template.source)
11
- # Return Ruby code that returns the compiled template
12
- MarkdownRails.renderer.call(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 = "1.0.0"
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"
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