Skip to content

Commit

Permalink
Replace kramdown with redcarpet.
Browse files Browse the repository at this point in the history
  • Loading branch information
castwide committed Aug 10, 2019
1 parent 9aa6f2d commit 697bca9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 33 deletions.
7 changes: 0 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ source 'https://rubygems.org'

gemspec name: 'solargraph'

if RUBY_VERSION =~ /^2\.(1|2)\./
gem 'kramdown', '~> 1.16'
else
gem 'kramdown', '~> 2.0'
gem 'kramdown-parser-gfm', '~> 1.0'
end

# Local gemfile for development tools, etc.
local_gemfile = File.expand_path(".Gemfile", __dir__)
instance_eval File.read local_gemfile if File.exist? local_gemfile
15 changes: 3 additions & 12 deletions lib/solargraph/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'ostruct'
require 'tilt'
require 'kramdown'
require 'redcarpet'
require 'htmlentities'
require 'cgi'

Expand All @@ -24,17 +24,8 @@ def initialize locals, render_method
# @param text [String]
# @return [String]
def htmlify text
Kramdown::Document.new(
text.to_s.lines.map{|l| l.gsub(/^ /, "\t")}.join,
input: 'GFM',
entity_output: :symbolic,
syntax_highlighter_opts: {
block: {
line_numbers: false
},
default_lang: :ruby
},
).to_html
redcarpet = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
redcarpet.render(text.to_s.lines.map{|l| l.gsub(/^ /, "\t")}.join)
end

# @param code [String]
Expand Down
16 changes: 4 additions & 12 deletions lib/solargraph/pin/documenting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,19 @@

require 'rdoc'
require 'reverse_markdown'
require 'kramdown'
begin
require 'kramdown-parser-gfm'
rescue LoadError
Solargraph.logger.info "Using legacy kramdown #{Kramdown::VERSION}"
end
require 'redcarpet'

module Solargraph
module Pin
# A module to add the Pin::Base#documentation method.
#
module Documenting
[].join
# @return [String]
def documentation
@documentation ||= begin
html = Kramdown::Document.new(
normalize_indentation(docstring.to_s),
input: 'GFM',
entity_output: :symbolic,
syntax_highlighter: nil
).to_html
redcarpet = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
html = redcarpet.render(normalize_indentation(docstring.to_s))
ReverseMarkdown.convert(html, github_flavored: true).lines.map(&:rstrip).join("\n")
end
end
Expand Down
4 changes: 2 additions & 2 deletions solargraph.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ Gem::Specification.new do |s|
end
s.homepage = 'http://solargraph.org'
s.license = 'MIT'
s.executables = ['solargraph', 'solargraph-runtime']
s.executables = ['solargraph']

s.required_ruby_version = '>= 2.1'

s.add_runtime_dependency 'backport', '~> 1.1'
s.add_runtime_dependency 'bundler', '>= 1.17.2'
s.add_runtime_dependency 'htmlentities', '~> 4.3', '>= 4.3.4'
s.add_runtime_dependency 'jaro_winkler', '~> 1.5'
s.add_runtime_dependency 'kramdown', '>= 1.16'
s.add_runtime_dependency 'nokogiri', '>= 1.9.1'
s.add_runtime_dependency 'parser', '~> 2.3'
s.add_runtime_dependency 'redcarpet', '~> 3.4'
s.add_runtime_dependency 'reverse_markdown', '~> 1.0', '>= 1.0.5'
s.add_runtime_dependency 'rubocop', '~> 0.52'
s.add_runtime_dependency 'thor', '~> 0.19', '>= 0.19.4'
Expand Down

0 comments on commit 697bca9

Please sign in to comment.