Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ vendor/
.DS_Store
.venv
venv
coverage/
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ GEM
crass (1.0.6)
creole (0.5.0)
date (3.5.1)
docile (1.4.1)
drb (2.2.3)
erb (6.0.4)
expression_parser (0.9.0)
Expand Down Expand Up @@ -98,6 +99,12 @@ GEM
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
securerandom (0.4.1)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.13.2)
simplecov_json_formatter (0.1.4)
stringio (3.2.0)
tdiff (0.4.0)
tsort (0.2.0)
Expand Down Expand Up @@ -143,6 +150,7 @@ DEPENDENCIES
redcarpet
rexml
sanitize (>= 4.6.3)
simplecov (~> 0.22)
twitter-text (~> 1.14)
wikicloth (= 0.8.3)

Expand Down
8 changes: 6 additions & 2 deletions github-markup.gemspec
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
require File.expand_path("../lib/github-markup", __FILE__)
version_file = File.expand_path("../lib/github-markup.rb", __FILE__)
version_match = File.read(version_file).match(/VERSION = ['"]([^'"]+)['"]/)
raise "Could not find VERSION in #{version_file}" unless version_match
version = version_match[1]

Gem::Specification.new do |s|
s.name = "github-markup"
s.version = GitHub::Markup::VERSION
s.version = version
s.summary = "The code GitHub uses to render README.markup"
s.description = <<~DESC
This gem is used by GitHub to render any fancy markup such as Markdown,
Expand All @@ -28,4 +31,5 @@ Gem::Specification.new do |s|
s.add_development_dependency 'nokogiri', '~> 1.19.2'
s.add_development_dependency 'nokogiri-diff', '~> 0.3.0'
s.add_development_dependency "github-linguist", ">= 7.1.3"
s.add_development_dependency 'simplecov', '~> 0.22'
end
3 changes: 1 addition & 2 deletions lib/github/markup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def language(filename, content, symlink: false)
end

# Define markups
markups_rb = File.dirname(__FILE__) + '/markups.rb'
instance_eval File.read(markups_rb), markups_rb
require_relative 'markups'
end
end
2 changes: 2 additions & 0 deletions lib/github/markup/rdoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ def render(filename, content, options: {})
if ::RDoc::VERSION.to_i >= 4
h = ::RDoc::Markup::ToHtml.new(::RDoc::Options.new)
else
# :nocov: RDoc < 4 has been unsupported since Ruby 2.4 (2016); modern RDoc requires Options.
h = ::RDoc::Markup::ToHtml.new
# :nocov:
end
h.convert(content)
end
Expand Down
20 changes: 10 additions & 10 deletions lib/github/markups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@
require "github/markup/rdoc"
require "shellwords"

markup_impl(::GitHub::Markups::MARKUP_MARKDOWN, ::GitHub::Markup::Markdown.new)
GitHub::Markup.markup_impl(::GitHub::Markups::MARKUP_MARKDOWN, ::GitHub::Markup::Markdown.new)

markup(::GitHub::Markups::MARKUP_TEXTILE, :redcloth, /textile/, ["Textile"]) do |filename, content, options: {}|
GitHub::Markup.markup(::GitHub::Markups::MARKUP_TEXTILE, :redcloth, /textile/, ["Textile"]) do |filename, content, options: {}|
RedCloth.new(content).to_html
end

markup_impl(::GitHub::Markups::MARKUP_RDOC, GitHub::Markup::RDoc.new)
GitHub::Markup.markup_impl(::GitHub::Markups::MARKUP_RDOC, GitHub::Markup::RDoc.new)

markup(::GitHub::Markups::MARKUP_ORG, 'org-ruby', /org/, ["Org"]) do |filename, content, options: {}|
GitHub::Markup.markup(::GitHub::Markups::MARKUP_ORG, 'org-ruby', /org/, ["Org"]) do |filename, content, options: {}|
Orgmode::Parser.new(content, {
:allow_include_files => false,
:skip_syntax_highlight => true
}).to_html
end

markup(::GitHub::Markups::MARKUP_CREOLE, :creole, /creole/, ["Creole"]) do |filename, content, options: {}|
GitHub::Markup.markup(::GitHub::Markups::MARKUP_CREOLE, :creole, /creole/, ["Creole"]) do |filename, content, options: {}|
Creole.creolize(content)
end

markup(::GitHub::Markups::MARKUP_MEDIAWIKI, :wikicloth, /mediawiki|wiki/, ["MediaWiki"]) do |filename, content, options: {}|
GitHub::Markup.markup(::GitHub::Markups::MARKUP_MEDIAWIKI, :wikicloth, /mediawiki|wiki/, ["MediaWiki"]) do |filename, content, options: {}|
wikicloth = WikiCloth::WikiCloth.new(:data => content)
WikiCloth::WikiBuffer::HTMLElement::ESCAPED_TAGS << 'tt' unless WikiCloth::WikiBuffer::HTMLElement::ESCAPED_TAGS.include?('tt')
wikicloth.to_html(:noedit => true)
end

markup(::GitHub::Markups::MARKUP_ASCIIDOC, :asciidoctor, /adoc|asc(iidoc)?/, ["AsciiDoc"]) do |filename, content, options: {}|
GitHub::Markup.markup(::GitHub::Markups::MARKUP_ASCIIDOC, :asciidoctor, /adoc|asc(iidoc)?/, ["AsciiDoc"]) do |filename, content, options: {}|
attributes = {
'showtitle' => '@',
'idprefix' => '',
Expand All @@ -47,13 +47,13 @@
Asciidoctor.convert(content, :safe => :secure, :attributes => attributes)
end

command(
GitHub::Markup.command(
::GitHub::Markups::MARKUP_RST,
"python3 #{Shellwords.escape(File.dirname(__FILE__))}/commands/rest2html",
/re?st(\.txt)?/,
["reStructuredText"],
"restructuredtext"
)

command(::GitHub::Markups::MARKUP_POD6, :pod62html, /pod6/, ["Pod 6"], "pod6")
command(::GitHub::Markups::MARKUP_POD, :pod2html, /pod/, ["Pod"], "pod")
GitHub::Markup.command(::GitHub::Markups::MARKUP_POD6, :pod62html, /pod6/, ["Pod 6"], "pod6")
GitHub::Markup.command(::GitHub::Markups::MARKUP_POD, :pod2html, /pod/, ["Pod"], "pod")
Loading