markdown-rails 1.0.0 → 2.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
2
  SHA256:
3
- metadata.gz: a772de4398029a4fa7ccb067e3c3c6ac59db0fbcbacffd89e6227fc048038105
4
- data.tar.gz: 78d68659281c660e18c31a5175ca44ecc8347263cde3b317921ca93700d4890d
3
+ metadata.gz: e552ca56be38b384f153880f11a5edb336f61b12e1e85448278b7e2f81723767
4
+ data.tar.gz: 9bbd303fb44492ffd820e0894144b51e387db88ed35197c3c4c76902a352118c
5
5
  SHA512:
6
- metadata.gz: 3250a18ee33f9200d8798353dffb59dfabd3063cf78550b6689e962c0dd278bfad30a0878ae3d3fcef1ca861d48f9b32f8ee25713dad858041e5cfcc03ca2f4f
7
- data.tar.gz: ba0c2637b6ab5ef69da35b691832dc529cfbd2f831731d5ae42dcf6950574eee19ba3dd0f410879206a5eb82eee06a9eaa68ffc8e06984ca7b58c542023e3369
6
+ metadata.gz: 78566da895833c13a2e604ad9462d98be9e9c710a8cef12435be8e765204da9a5404a93a51824155b804de743646d54193fb9fd1af208ef986a3c9121dc9f5aa
7
+ data.tar.gz: 017a386e646f20a08364d75827b956d8a12b933b360ff86e4105180e92ee5cb4ca58ed05a14ae6db5b8569568ce2dad300558ffab866aa81df986d154b0a9091
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,135 @@
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
+ 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!
6
4
 
7
- # markdown-rails
5
+ It is a comprehensive Markdown library for Rails that addresses the following pain points:
6
+
7
+ * Renders markdown files and partials that you can throw in your Rails view paths, like `./app/views/people/profile.html.md`.
8
+ * Parse Erb blocks in markdown files.
9
+ * Customize markdown tags like `![]()` to support embeds beyond images like YouTube links, code fences for syntax highlighting, etc.
10
+ * Plug into Rails asset pipeline so images defined in Markdown will be loaded from the forever-cached image assets.
11
+ * 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.
8
12
 
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!
13
+ 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
14
 
13
15
  ## Usage
14
16
 
15
- Add the following to your Gemfile:
17
+ Add the following to your application's Gemfile:
18
+
19
+ ```sh
20
+ $ bundle add 'markdown-rails'
21
+ ```
22
+
23
+ Then from the root of your Rails project, run:
24
+
25
+ ```sh
26
+ $ bin/rails g markdown_rails:install
27
+ ```
28
+
29
+ This adds a `config/initializers/markdown.rb` file where you can register template handler for your Markdown renders that are located in `./app/markdown/*.rb`.
30
+
31
+ Now add views or partials ending in `.md` in your `./app/views/**/**` directories and behold!
32
+
33
+ ### Upgrading from 1.x
34
+
35
+ Change your applications Gemfile to read:
36
+
37
+ ```ruby
38
+ gem "markdown-rails", "~> 2.0.0"
39
+ ```
40
+
41
+ Then from the root of your Rails project, run:
42
+
43
+ ```sh
44
+ $ bin/rails g markdown_rails:install
45
+ ```
46
+
47
+ 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.
48
+
49
+ ## Configuration
50
+
51
+ Applications commonly need various markdown variants within one application. For example,
52
+
53
+ ```ruby
54
+ # ./config/initializers/markdown.rb
55
+ # Restart the server to see changes made to this file.
56
+
57
+ # Setup markdown stacks to work with different template handler in Rails.
58
+ MarkdownRails.handle :md do
59
+ ApplicationMarkdown.new
60
+ end
61
+
62
+ MarkdownRails.handle :crazymd do
63
+ MyCrazyMarkdown.new
64
+ end
65
+ ```
66
+
67
+ ### Enable Erb in Markdown
68
+
69
+ 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.
70
+
71
+ ```ruby
72
+ # ./config/initializers/markdown.rb
73
+ MarkdownRails.handle :markerb do
74
+ ErbMarkdown.new
75
+ end
76
+ ```
77
+
78
+ 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:
79
+
80
+ ```ruby
81
+ # ./config/initializers/markdown.rb
82
+ # Restart the server to see changes made to this file.
83
+
84
+ # Setup markdown stacks to work with different template handler in Rails.
85
+ MarkdownRails.handle :md do
86
+ ApplicationMarkdown.new
87
+ end
88
+
89
+ MarkdownRails.handle :markerb do
90
+ ErbMarkdown.new
91
+ end
92
+ ```
93
+
94
+ The same technique can be used for preprocessing Markdown with other handlers, like liquid.
95
+
96
+ ## Customizing renderer
97
+
98
+ You might want to customize your Markdown handler to do things like syntax code highlighting, etc.
16
99
 
17
100
  ```ruby
18
- gem 'markdown-rails'
101
+ # ./app/markdown/application_markdown.rb
102
+ require "rouge"
103
+
104
+ class ApplicationMarkdown < RailsMarkdown
105
+ include Redcarpet::Render::SmartyPants
106
+
107
+ FORMATTER = Rouge::Formatters::HTMLInline.new("monokai.sublime")
108
+
109
+ def enable
110
+ [:fenced_code_blocks]
111
+ end
112
+
113
+ def block_code(code, language)
114
+ lexer = Rouge::Lexer.find(language)
115
+ content_tag :pre, class: language do
116
+ raw FORMATTER.format(lexer.lex(code))
117
+ end
118
+ end
119
+ end
19
120
  ```
20
121
 
21
- Now add views or partials ending in `.md` or `.markdown`.
122
+ Consider using a componet farmework, like [phlex](https://www.phlex.fun) to generate tags outside of the Rails view context.
22
123
 
23
124
  ## Examples
24
125
 
25
- ### Static View
126
+ There's a lot of ways to use Markdown in your Rails app.
127
+
128
+ ### The easy way
129
+
130
+ 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.
131
+
132
+ ### Static view
26
133
 
27
134
  In `app/views/home/about.html.md`:
28
135
 
@@ -32,11 +139,9 @@ In `app/views/home/about.html.md`:
32
139
  *Markdown code goes here ...*
33
140
  ```
34
141
 
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`.
142
+ 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
143
 
39
- ### Static Partial
144
+ ### Static partial
40
145
 
41
146
  In `app/views/posts/edit.html.erb`:
42
147
 
@@ -55,68 +160,8 @@ In `app/views/posts/_edit_help.html.md`:
55
160
  This text is written in **Markdown**. :-)
56
161
  ```
57
162
 
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
- ```
163
+ 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
164
 
97
165
  ## Security
98
166
 
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.
167
+ 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,9 @@
1
+ Description:
2
+ Installs MarkdownRails to your Rails project
3
+
4
+ Example:
5
+ bin/rails generate markdown_rails:install
6
+
7
+ This will create:
8
+ config/initializers/markdown.rb
9
+ app/markdown/application_markdown.rb
@@ -0,0 +1,8 @@
1
+ class MarkdownRails::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,54 @@
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 < MarkdownRails::Renderer::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
+ # Run `bundle add rouge` and uncomment the include below for syntax highlighting
10
+ # include MarkdownRails::Helper::Rouge
11
+
12
+ # If you need access to ActionController::Base.helpers, you can delegate by uncommenting
13
+ # and adding to the list below. Several are already included for you in the `MarkdownRails::Renderer::Rails`,
14
+ # but you can add more here.
15
+ #
16
+ # To see a list of methods available run `bin/rails runner "puts ActionController::Base.helpers.public_methods.sort"`
17
+ #
18
+ # delegate \
19
+ # :request,
20
+ # :cache,
21
+ # :turbo_frame_tag,
22
+ # to: :helpers
23
+
24
+ # These flags control features in the Redcarpet renderer, which you can read
25
+ # about at https://github.com/vmg/redcarpet#and-its-like-really-simple-to-use
26
+ # Make sure you know what you're doing if you're using this to render user inputs.
27
+ def enable
28
+ [:fenced_code_blocks]
29
+ end
30
+
31
+ # Example of how you might override the images to show embeds, like a YouTube video.
32
+ def image(link, title, alt)
33
+ url = URI(link)
34
+ case url.host
35
+ when "www.youtube.com"
36
+ youtube_tag url, alt
37
+ else
38
+ super
39
+ end
40
+ end
41
+
42
+ private
43
+ # This is provided as an example; there's many more YouTube URLs that this wouldn't catch.
44
+ def youtube_tag(url, alt)
45
+ embed_url = "https://www.youtube-nocookie.com/embed/#{CGI.parse(url.query).fetch("v").first}"
46
+ content_tag :iframe,
47
+ src: embed_url,
48
+ width: 560,
49
+ height: 325,
50
+ allow: "encrypted-media; picture-in-picture",
51
+ allowfullscreen: true \
52
+ do alt end
53
+ end
54
+ end
@@ -0,0 +1,11 @@
1
+ # DANGER! This parses Erb, which means arbitrary Ruby can be run. Make sure
2
+ # you trust the source of your markdown and that its not user input.
3
+
4
+ class ErbMarkdown < ApplicationMarkdown
5
+ # Enables Erb to render for the entire doc before the markdown is rendered.
6
+ # This works great, except when you have an `erb` code fence.
7
+ def preprocess(html)
8
+ # Read more about this render call at https://guides.rubyonrails.org/layouts_and_rendering.html
9
+ render inline: html, handler: :erb
10
+ end
11
+ 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 handler in Rails.
4
+ MarkdownRails.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
+ MarkdownRails.handle :markerb do
12
+ ErbMarkdown.new
13
+ end
@@ -1,54 +1,10 @@
1
- require 'rdiscount'
2
- require 'action_view'
3
-
4
- # We cannot use Markdown::Rails because it conflicts with RDiscount's Markdown class
5
1
  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
2
+ class Engine < ::Rails::Engine
3
+ # Check if the `.md` extension has been registered after the
4
+ # config/initializer files are processed. This makes the `:md`
5
+ # extension work if the user forgot to install the initializers.
6
+ config.before_initialize do
7
+ MarkdownRails::Handler.register_default
25
8
  end
26
9
  end
27
10
  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
@@ -0,0 +1,43 @@
1
+ module MarkdownRails
2
+ # We cannot use MarkdownRails because it conflicts with RDiscount's Markdown class
3
+ class Handler
4
+ DEFAULT_EXTENSION = :md
5
+
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
+ # Registers a default `.md` handler for Rails templates. This might be
22
+ # replaced by a handler in the `config/initializers/markdown.rb` file.
23
+ def self.register_default
24
+ handle(DEFAULT_EXTENSION) { MarkdownRails::Renderer::Rails.new }
25
+ end
26
+
27
+ private
28
+
29
+ def markdown
30
+ @cache = nil unless cache_enabled?
31
+ @cache ||= @markdown.call
32
+ end
33
+
34
+ def renderer
35
+ @renderer = nil unless cache_enabled?
36
+ @renderer ||= markdown.renderer
37
+ end
38
+
39
+ def cache_enabled?
40
+ ::Rails.configuration.cache_classes
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,34 @@
1
+ require "rouge"
2
+
3
+ module MarkdownRails
4
+ module Helper
5
+ module Rouge
6
+ def rouge_theme
7
+ "gruvbox".freeze
8
+ end
9
+
10
+ def rouge_formatter
11
+ ::Rouge::Formatters::HTMLInline.new(rouge_theme)
12
+ end
13
+
14
+ def rouge_fallback_lexer
15
+ rouge_lexer "text"
16
+ end
17
+
18
+ def highlight_code(code, language)
19
+ lexer = rouge_lexer(language) || rouge_fallback_lexer
20
+ rouge_formatter.format(lexer.lex(code))
21
+ end
22
+
23
+ def block_code(code, language)
24
+ content_tag :pre, class: language do
25
+ raw highlight_code code, language
26
+ end
27
+ end
28
+
29
+ def rouge_lexer(language)
30
+ ::Rouge::Lexer.find language
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,4 @@
1
+ module MarkdownRails
2
+ class Railtie < ::Rails::Railtie
3
+ end
4
+ end
@@ -0,0 +1,28 @@
1
+ require "redcarpet"
2
+
3
+ module MarkdownRails
4
+ module Renderer
5
+ class Base < Redcarpet::Render::HTML
6
+ def enable
7
+ # This is a very restrictive Markdown renderer that errs on the side of safety.
8
+ # For more details read the docs at https://github.com/vmg/redcarpet#darling-i-packed-you-a-couple-renderer-for-lunch
9
+ [
10
+ :filter_html,
11
+ :no_images,
12
+ :no_links,
13
+ :no_styles,
14
+ :safe_links_only
15
+ ]
16
+ end
17
+
18
+ def renderer
19
+ ::Redcarpet::Markdown.new(self.class, **features)
20
+ end
21
+
22
+ private
23
+ def features
24
+ Hash[Array(enable).map{ |feature| [ feature, true ] }]
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,47 @@
1
+ module MarkdownRails
2
+ module Renderer
3
+ class Rails < Base
4
+ include ::Rails.application.routes.url_helpers
5
+
6
+ # Rendering from Markdown is actually outside of the view
7
+ # context, so we need to delegate render to the ApplicationController
8
+ # render method that can render outside of the view context.
9
+ delegate \
10
+ :helpers,
11
+ :render,
12
+ to: :base_controller
13
+
14
+ delegate \
15
+ :asset_digest_path,
16
+ :asset_path,
17
+ :asset_url,
18
+ :audio_path,
19
+ :audio_tag,
20
+ :audio_url,
21
+ :font_path,
22
+ :font_url,
23
+ :image_path,
24
+ :image_tag,
25
+ :image_url,
26
+ :video_path,
27
+ :video_tag,
28
+ :video_url,
29
+ :tag,
30
+ :content_tag,
31
+ :request,
32
+ :turbo_frame_tag,
33
+ :controller,
34
+ :raw,
35
+ to: :helpers
36
+
37
+ def image(link, title, alt)
38
+ image_tag link, title: title, alt: alt
39
+ end
40
+
41
+ protected
42
+ def base_controller
43
+ ::ApplicationController
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,3 +1,3 @@
1
1
  module MarkdownRails
2
- VERSION = "1.0.0"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -1,2 +1,19 @@
1
- require 'markdown-rails/version'
2
- require 'markdown-rails/engine'
1
+ require "markdown-rails/version"
2
+ require "markdown-rails/engine"
3
+
4
+ module MarkdownRails
5
+ def self.handle(*extensions, &block)
6
+ Handler.handle(*extensions, &block)
7
+ end
8
+
9
+ autoload :Handler, "markdown-rails/handler"
10
+
11
+ module Renderer
12
+ autoload :Base, "markdown-rails/renderer/base"
13
+ autoload :Rails, "markdown-rails/renderer/rails"
14
+ end
15
+
16
+ module Helper
17
+ autoload :Rouge, "markdown-rails/helper/rouge"
18
+ end
19
+ end
@@ -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,64 +1,105 @@
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.1.0
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: 2023-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 6.0.0
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: 6.0.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: rdiscount
28
+ name: actionview
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: 6.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: 6.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 6.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 6.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: redcarpet
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0
69
+ description: Markdown Rails is a comprehensive stack for rendering Markdown templates
70
+ and partials in Rails.
42
71
  email:
43
- - joliss42@gmail.com
72
+ - bradgessler@gmail.com
44
73
  executables: []
45
74
  extensions: []
46
75
  extra_rdoc_files: []
47
76
  files:
48
- - ".gitignore"
49
- - CODE_OF_CONDUCT.md
50
- - Gemfile
51
- - History.md
52
- - License.txt
77
+ - MIT-LICENSE
53
78
  - README.md
54
79
  - Rakefile
80
+ - app/assets/config/markdown_rails_manifest.js
81
+ - lib/generators/markdown_rails/install/USAGE
82
+ - lib/generators/markdown_rails/install/install_generator.rb
83
+ - lib/generators/markdown_rails/install/templates/app/markdown/application_markdown.rb
84
+ - lib/generators/markdown_rails/install/templates/app/markdown/erb_markdown.rb
85
+ - lib/generators/markdown_rails/install/templates/config/initializers/markdown.rb
55
86
  - lib/markdown-rails.rb
56
87
  - lib/markdown-rails/engine.rb
88
+ - lib/markdown-rails/handler.rb
89
+ - lib/markdown-rails/helper/rouge.rb
90
+ - lib/markdown-rails/railtie.rb
91
+ - lib/markdown-rails/renderer/base.rb
92
+ - lib/markdown-rails/renderer/rails.rb
57
93
  - lib/markdown-rails/version.rb
58
- - markdown-rails.gemspec
59
- homepage: https://github.com/joliss/markdown-rails
60
- licenses: []
61
- metadata: {}
94
+ - lib/tasks/markdown/rails_tasks.rake
95
+ homepage: https://github.com/sitepress/markdown-rails
96
+ licenses:
97
+ - MIT
98
+ metadata:
99
+ allowed_push_host: https://rubygems.org/
100
+ homepage_uri: https://github.com/sitepress/markdown-rails
101
+ source_code_uri: https://github.com/sitepress/markdown-rails
102
+ changelog_uri: https://github.com/sitepress/markdown-rails
62
103
  post_install_message:
63
104
  rdoc_options: []
64
105
  require_paths:
@@ -72,10 +113,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
113
  requirements:
73
114
  - - ">="
74
115
  - !ruby/object:Gem::Version
75
- version: 1.3.6
116
+ version: '0'
76
117
  requirements: []
77
- rubygems_version: 3.1.4
118
+ rubygems_version: 3.4.6
78
119
  signing_key:
79
120
  specification_version: 4
80
- summary: Markdown as a Rails templating language
121
+ summary: Markdown templates and partials in Rails.
81
122
  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,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