Skip to content

Commit 41eee72

Browse files
committed
lint
1 parent 897e8ed commit 41eee72

32 files changed

+465
-474
lines changed

Gemfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# frozen_string_literal: true
22

3-
source 'https://rubygems.org/'
3+
source "https://rubygems.org/"
44

55
gemspec
66

77
group :benchmark do
8-
gem 'benchmark-ips'
9-
gem 'kramdown'
10-
gem 'redcarpet'
8+
gem "benchmark-ips"
9+
gem "kramdown"
10+
gem "redcarpet"
1111
end

Rakefile

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,109 @@
11
# frozen_string_literal: true
22

3-
require 'date'
4-
require 'rake/clean'
5-
require 'rake/extensiontask'
6-
require 'digest/md5'
3+
require "date"
4+
require "rake/clean"
5+
require "rake/extensiontask"
6+
require "digest/md5"
77

8-
host_os = RbConfig::CONFIG['host_os']
9-
require 'devkit' if host_os == 'mingw32'
8+
host_os = RbConfig::CONFIG["host_os"]
9+
require "devkit" if host_os == "mingw32"
1010

1111
task default: [:test]
1212

1313
# Gem Spec
14-
gem_spec = Gem::Specification.load('commonmarker.gemspec')
14+
gem_spec = Gem::Specification.load("commonmarker.gemspec")
1515

1616
# Ruby Extension
17-
Rake::ExtensionTask.new('commonmarker', gem_spec) do |ext|
18-
ext.lib_dir = File.join('lib', 'commonmarker')
17+
Rake::ExtensionTask.new("commonmarker", gem_spec) do |ext|
18+
ext.lib_dir = File.join("lib", "commonmarker")
1919
end
2020

2121
# Packaging
22-
require 'bundler/gem_tasks'
22+
require "bundler/gem_tasks"
2323

2424
# Testing
25-
require 'rake/testtask'
25+
require "rake/testtask"
2626

27-
Rake::TestTask.new('test:unit') do |t|
28-
t.libs << 'lib'
29-
t.libs << 'test'
30-
t.pattern = 'test/test_*.rb'
27+
Rake::TestTask.new("test:unit") do |t|
28+
t.libs << "lib"
29+
t.libs << "test"
30+
t.pattern = "test/test_*.rb"
3131
t.verbose = true
3232
t.warning = false
3333
end
3434

35-
task 'test:unit' => :compile
35+
desc "Run unit tests"
36+
task "test:unit" => :compile
3637

37-
desc 'Run unit and conformance tests'
38-
task test: %w[test:unit]
38+
desc "Run unit and conformance tests"
39+
task test: ["test:unit"]
3940

40-
require 'rubocop/rake_task'
41+
require "rubocop/rake_task"
4142

4243
RuboCop::RakeTask.new(:rubocop)
4344

44-
desc 'Run benchmarks'
45+
desc "Run benchmarks"
4546
task :benchmark do
46-
if ENV['FETCH_PROGIT']
47-
`rm -rf test/progit`
48-
`git clone https://github.com/progit/progit.git test/progit`
49-
langs = %w[ar az be ca cs de en eo es es-ni fa fi fr hi hu id it ja ko mk nl no-nb pl pt-br ro ru sr th tr uk vi zh zh-tw]
47+
if ENV["FETCH_PROGIT"]
48+
%x(rm -rf test/progit)
49+
%x(git clone https://github.com/progit/progit.git test/progit)
50+
langs = ["ar", "az", "be", "ca", "cs", "de", "en", "eo", "es", "es-ni", "fa", "fi", "fr", "hi", "hu", "id", "it", "ja", "ko", "mk", "nl", "no-nb", "pl", "pt-br", "ro", "ru", "sr", "th", "tr", "uk", "vi", "zh", "zh-tw"]
5051
langs.each do |lang|
51-
`cat test/progit/#{lang}/*/*.markdown >> test/benchinput.md`
52+
%x(cat test/progit/#{lang}/*/*.markdown >> test/benchinput.md)
5253
end
5354
end
54-
$LOAD_PATH.unshift 'lib'
55-
load 'test/benchmark.rb'
55+
$LOAD_PATH.unshift("lib")
56+
load "test/benchmark.rb"
5657
end
5758

58-
desc 'Match C style of cmark'
59+
desc "Match C style of cmark"
5960
task :format do
60-
sh 'clang-format -style llvm -i ext/commonmarker/*.c ext/commonmarker/*.h'
61+
sh "clang-format -style llvm -i ext/commonmarker/*.c ext/commonmarker/*.h"
6162
end
6263

6364
# Documentation
64-
require 'rdoc/task'
65+
require "rdoc/task"
6566

66-
desc 'Generate API documentation'
67+
desc "Generate API documentation"
6768
RDoc::Task.new do |rd|
68-
rd.rdoc_dir = 'docs'
69-
rd.main = 'README.md'
70-
rd.rdoc_files.include 'README.md', 'lib/**/*.rb', 'ext/commonmarker/commonmarker.c'
71-
72-
rd.options << '--markup tomdoc'
73-
rd.options << '--inline-source'
74-
rd.options << '--line-numbers'
75-
rd.options << '--all'
76-
rd.options << '--fileboxes'
69+
rd.rdoc_dir = "docs"
70+
rd.main = "README.md"
71+
rd.rdoc_files.include("README.md", "lib/**/*.rb", "ext/commonmarker/commonmarker.c")
72+
73+
rd.options << "--markup tomdoc"
74+
rd.options << "--inline-source"
75+
rd.options << "--line-numbers"
76+
rd.options << "--all"
77+
rd.options << "--fileboxes"
7778
end
7879

79-
desc 'Generate the documentation and run a web server'
80+
desc "Generate the documentation and run a web server"
8081
task serve: [:rdoc] do
81-
require 'webrick'
82+
require "webrick"
8283

83-
puts 'Navigate to http://localhost:3000 to see the docs'
84+
puts "Navigate to http://localhost:3000 to see the docs"
8485

85-
server = WEBrick::HTTPServer.new Port: 3000
86-
server.mount '/', WEBrick::HTTPServlet::FileHandler, 'docs'
87-
trap('INT') { server.stop }
86+
server = WEBrick::HTTPServer.new(Port: 3000)
87+
server.mount("/", WEBrick::HTTPServlet::FileHandler, "docs")
88+
trap("INT") { server.stop }
8889
server.start
8990
end
9091

91-
desc 'Generate and publish docs to gh-pages'
92+
desc "Generate and publish docs to gh-pages"
9293
task publish: [:rdoc] do
93-
require 'tmpdir'
94-
require 'shellwords'
94+
require "tmpdir"
95+
require "shellwords"
9596

9697
Dir.mktmpdir do |tmp|
9798
system "mv docs/* #{tmp}"
98-
system 'git checkout origin/gh-pages'
99-
system 'rm -rf *'
99+
system "git checkout origin/gh-pages"
100+
system "rm -rf *"
100101
system "mv #{tmp}/* ."
101102
message = Shellwords.escape("Site updated at #{Time.now.utc}")
102-
system 'git add .'
103+
system "git add ."
103104
system "git commit -am #{message}"
104-
system 'git push origin gh-pages --force'
105-
system 'git checkout master'
106-
system 'echo yolo'
105+
system "git push origin gh-pages --force"
106+
system "git checkout master"
107+
system "echo yolo"
107108
end
108109
end

commonmarker.gemspec

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
11
# frozen_string_literal: true
22

3-
lib = File.expand_path('lib', __dir__)
3+
lib = File.expand_path("lib", __dir__)
44
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5-
require 'commonmarker/version'
5+
require "commonmarker/version"
66

77
Gem::Specification.new do |s|
8-
s.name = 'commonmarker'
8+
s.name = "commonmarker"
99
s.version = CommonMarker::VERSION
10-
s.summary = 'CommonMark parser and renderer. Written in C, wrapped in Ruby.'
11-
s.description = 'A fast, safe, extensible parser for CommonMark. This wraps the official libcmark library.'
12-
s.authors = ['Garen Torikian', 'Ashe Connor']
13-
s.homepage = 'https://github.com/gjtorikian/commonmarker'
14-
s.license = 'MIT'
10+
s.summary = "CommonMark parser and renderer. Written in C, wrapped in Ruby."
11+
s.description = "A fast, safe, extensible parser for CommonMark. This wraps the official libcmark library."
12+
s.authors = ["Garen Torikian", "Ashe Connor"]
13+
s.homepage = "https://github.com/gjtorikian/commonmarker"
14+
s.license = "MIT"
1515

16-
s.files = %w[LICENSE.txt README.md Rakefile commonmarker.gemspec bin/commonmarker]
17-
s.files += Dir.glob('lib/**/*.rb')
18-
s.files += Dir.glob('ext/commonmarker/*.*')
19-
s.test_files = Dir.glob('test/**/*').reject { |f| f == 'test/benchinput.md' || f.start_with?('test/progit/') }
20-
s.extensions = ['ext/commonmarker/extconf.rb']
16+
s.files = ["LICENSE.txt", "README.md", "Rakefile", "commonmarker.gemspec", "bin/commonmarker"]
17+
s.files += Dir.glob("lib/**/*.rb")
18+
s.files += Dir.glob("ext/commonmarker/*.*")
19+
s.extensions = ["ext/commonmarker/extconf.rb"]
2120

22-
s.executables = ['commonmarker']
23-
s.require_paths = %w[lib ext]
24-
s.required_ruby_version = ['>= 2.6', '< 4.0']
21+
s.executables = ["commonmarker"]
22+
s.require_paths = ["lib", "ext"]
23+
s.required_ruby_version = [">= 2.6", "< 4.0"]
2524

26-
s.metadata['rubygems_mfa_required'] = 'true'
25+
s.metadata["rubygems_mfa_required"] = "true"
2726

28-
s.rdoc_options += ['-x', 'ext/commonmarker/cmark/.*']
27+
s.rdoc_options += ["-x", "ext/commonmarker/cmark/.*"]
2928

30-
s.add_development_dependency 'awesome_print'
31-
s.add_development_dependency 'json', '~> 2.3'
32-
s.add_development_dependency 'minitest', '~> 5.6'
33-
s.add_development_dependency 'minitest-focus', '~> 1.1'
34-
s.add_development_dependency 'rake'
35-
s.add_development_dependency 'rake-compiler', '~> 0.9'
36-
s.add_development_dependency 'rdoc', '~> 6.2'
37-
s.add_development_dependency 'rubocop'
38-
s.add_development_dependency 'rubocop-standard'
29+
s.add_development_dependency("awesome_print")
30+
s.add_development_dependency("json", "~> 2.3")
31+
s.add_development_dependency("minitest", "~> 5.6")
32+
s.add_development_dependency("minitest-focus", "~> 1.1")
33+
s.add_development_dependency("rake")
34+
s.add_development_dependency("rake-compiler", "~> 0.9")
35+
s.add_development_dependency("rdoc", "~> 6.2")
36+
s.add_development_dependency("rubocop")
37+
s.add_development_dependency("rubocop-standard")
3938
end

lib/commonmarker.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/env ruby
22
# frozen_string_literal: true
33

4-
require 'commonmarker/commonmarker'
5-
require 'commonmarker/config'
6-
require 'commonmarker/node'
7-
require 'commonmarker/renderer'
8-
require 'commonmarker/renderer/html_renderer'
9-
require 'commonmarker/version'
4+
require "commonmarker/commonmarker"
5+
require "commonmarker/config"
6+
require "commonmarker/node"
7+
require "commonmarker/renderer"
8+
require "commonmarker/renderer/html_renderer"
9+
require "commonmarker/version"
1010

1111
begin
12-
require 'awesome_print'
12+
require "awesome_print"
1313
rescue LoadError; end # rubocop:disable Lint/SuppressedException
1414
module CommonMarker
1515
# Public: Parses a Markdown string into an HTML string.
@@ -23,7 +23,7 @@ def self.render_html(text, options = :DEFAULT, extensions = [])
2323
raise TypeError, "text must be a String; got a #{text.class}!" unless text.is_a?(String)
2424

2525
opts = Config.process_options(options, :render)
26-
Node.markdown_to_html(text.encode('UTF-8'), opts, extensions)
26+
Node.markdown_to_html(text.encode("UTF-8"), opts, extensions)
2727
end
2828

2929
# Public: Parses a Markdown string into a `document` node.
@@ -37,7 +37,7 @@ def self.render_doc(text, options = :DEFAULT, extensions = [])
3737
raise TypeError, "text must be a String; got a #{text.class}!" unless text.is_a?(String)
3838

3939
opts = Config.process_options(options, :parse)
40-
text = text.encode('UTF-8')
40+
text = text.encode("UTF-8")
4141
Node.parse_document(text, text.bytesize, opts, extensions)
4242
end
4343
end

lib/commonmarker/config.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module Config
1313
SMART: (1 << 10),
1414
LIBERAL_HTML_TAG: (1 << 12),
1515
FOOTNOTES: (1 << 13),
16-
STRIKETHROUGH_DOUBLE_TILDE: (1 << 14)
16+
STRIKETHROUGH_DOUBLE_TILDE: (1 << 14),
1717
}.freeze,
1818
render: {
1919
DEFAULT: 0,
@@ -28,9 +28,9 @@ module Config
2828
FOOTNOTES: (1 << 13),
2929
STRIKETHROUGH_DOUBLE_TILDE: (1 << 14),
3030
TABLE_PREFER_STYLE_ATTRIBUTES: (1 << 15),
31-
FULL_INFO_STRING: (1 << 16)
31+
FULL_INFO_STRING: (1 << 16),
3232
}.freeze,
33-
format: %i[html xml commonmark plaintext].freeze
33+
format: [:html, :xml, :commonmark, :plaintext].freeze,
3434
}.freeze
3535

3636
def self.process_options(option, type)

lib/commonmarker/node.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require 'commonmarker/node/inspect'
3+
require "commonmarker/node/inspect"
44

55
module CommonMarker
66
class Node
@@ -27,7 +27,7 @@ def walk(&block)
2727
# Returns a {String}.
2828
def to_html(options = :DEFAULT, extensions = [])
2929
opts = Config.process_options(options, :render)
30-
_render_html(opts, extensions).force_encoding('utf-8')
30+
_render_html(opts, extensions).force_encoding("utf-8")
3131
end
3232

3333
# Public: Convert the node to an XML string.
@@ -37,7 +37,7 @@ def to_html(options = :DEFAULT, extensions = [])
3737
# Returns a {String}.
3838
def to_xml(options = :DEFAULT)
3939
opts = Config.process_options(options, :render)
40-
_render_xml(opts).force_encoding('utf-8')
40+
_render_xml(opts).force_encoding("utf-8")
4141
end
4242

4343
# Public: Convert the node to a CommonMark string.
@@ -48,7 +48,7 @@ def to_xml(options = :DEFAULT)
4848
# Returns a {String}.
4949
def to_commonmark(options = :DEFAULT, width = 120)
5050
opts = Config.process_options(options, :render)
51-
_render_commonmark(opts, width).force_encoding('utf-8')
51+
_render_commonmark(opts, width).force_encoding("utf-8")
5252
end
5353

5454
# Public: Convert the node to a plain text string.
@@ -59,7 +59,7 @@ def to_commonmark(options = :DEFAULT, width = 120)
5959
# Returns a {String}.
6060
def to_plaintext(options = :DEFAULT, width = 120)
6161
opts = Config.process_options(options, :render)
62-
_render_plaintext(opts, width).force_encoding('utf-8')
62+
_render_plaintext(opts, width).force_encoding("utf-8")
6363
end
6464

6565
# Public: Iterate over the children (if any) of the current pointer.
@@ -76,7 +76,7 @@ def each
7676

7777
# Deprecated: Please use `each` instead
7878
def each_child(&block)
79-
warn '[DEPRECATION] `each_child` is deprecated. Please use `each` instead.'
79+
warn("[DEPRECATION] `each_child` is deprecated. Please use `each` instead.")
8080
each(&block)
8181
end
8282
end

0 commit comments

Comments
 (0)