Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axil@gitlab.com>2017-09-29 17:45:06 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2017-09-29 17:45:06 +0300
commit9a6f57eb2fddb8b8781885250919c00d577b1872 (patch)
tree503ab1b3504b6019d9abac90003fd5f83c8af504 /lib/helpers_.rb
parentb05f96107bc713c7d701f0d7f57e93a0f7d0dc1f (diff)
Move redcarpet renderer to its own lib helper file
Diffstat (limited to 'lib/helpers_.rb')
-rw-r--r--lib/helpers_.rb25
1 files changed, 1 insertions, 24 deletions
diff --git a/lib/helpers_.rb b/lib/helpers_.rb
index e23e00da..de9ec533 100644
--- a/lib/helpers_.rb
+++ b/lib/helpers_.rb
@@ -3,27 +3,4 @@ include Nanoc::Helpers::XMLSitemap
include Nanoc::Helpers::Rendering
include Nanoc::Helpers::ChildParentBetter
include Nanoc::Helpers::EditOnGitLab
-
-require 'redcarpet'
-require 'rouge'
-require 'rouge/plugins/redcarpet'
-
-class HTML < Redcarpet::Render::HTML
- include Rouge::Plugins::Redcarpet
-
-
- def header(text, header_level)
- # https://github.com/cookpad/garage/blob/c817733e382c734eedba743e9103cd8a124f24eb/lib/garage/docs/anchor_building.rb#L24
- anchor = text.gsub(/\s+/, '-').gsub(/<\/?[^>]*>/, '').downcase
- # https://github.com/rails/rails/blob/e491b2c06329afb3c989261a2865d2a93c8b84b8/activesupport/lib/active_support/inflector/transliterate.rb#L86
- anchor.gsub!(/[^a-z0-9\-_]+/i, '-')
- anchor.squeeze!('-') # replace multiple dashes with one
- anchor.gsub!(/^-|-$/, '') # remove any first or last dashes
-
- %(<h#{header_level} id='#{anchor}'>#{text} <a class='anchor' href='##{anchor}' title='Permalink'></a></h#{header_level}>)
- end
-
- def image(link, title, alt_text)
- %(<a target="_blank" href="#{link}"><img src="#{link}" title="#{title}" alt="#{alt_text}"/></a>)
- end
-end
+include Nanoc::Helpers::RedcarpetRender