Commit 3913f247 authored by Sacred Seven's avatar Sacred Seven

Better fix for #4

parent a133cf3b
......@@ -50,7 +50,7 @@ module GitlabMarkdownHelper
end
html_doc = Nokogiri::HTML(@markdown.render(text))
html_doc.css(':not(li)').each { |dom| dom[:dir] = :auto }
html_doc.to_html.gsub(%r{\{anchor=([\w-]+)\}}m) { |match| "<a name=\'#{$1}\'></a>" }.html_safe
html_doc.to_html.html_safe
end
# Return the first line of +text+, up to +max_chars+, after parsing the line
......
......@@ -49,7 +49,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
"<h#{level}>#{text}</h#{level}>"
else
id = ActionController::Base.helpers.strip_tags(h.gfm(text)).downcase() \
.gsub(/[^a-z0-9_-]/, '-').gsub(/-+/, '-').gsub(/^-/, '').gsub(/-$/, '')
.gsub(/[^\p{Word}-]/, '-').gsub(/-+/, '-').gsub(/^-/, '').gsub(/-$/, '')
"<h#{level} id=\"#{id}\">#{text}<a href=\"\##{id}\"></a></h#{level}>"
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment