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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/banzai/filter/math_filter.rb')
-rw-r--r--lib/banzai/filter/math_filter.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/banzai/filter/math_filter.rb b/lib/banzai/filter/math_filter.rb
index ca13a8d6474..ac009008040 100644
--- a/lib/banzai/filter/math_filter.rb
+++ b/lib/banzai/filter/math_filter.rb
@@ -10,7 +10,7 @@ module Banzai
# HTML filter that implements our math syntax, adding class="code math"
#
class MathFilter < HTML::Pipeline::Filter
- CSS_MATH = 'pre.code.language-math'
+ CSS_MATH = 'pre[lang="math"] > code'
XPATH_MATH = Gitlab::Utils::Nokogiri.css_to_xpath(CSS_MATH).freeze
CSS_CODE = 'code'
XPATH_CODE = Gitlab::Utils::Nokogiri.css_to_xpath(CSS_CODE).freeze
@@ -125,9 +125,10 @@ module Banzai
# corresponds to the "```math...```" syntax
def process_math_codeblock
- doc.xpath(XPATH_MATH).each do |el|
- el[STYLE_ATTRIBUTE] = 'display'
- el[:class] += " #{TAG_CLASS}"
+ doc.xpath(XPATH_MATH).each do |node|
+ pre_node = node.parent
+ pre_node[STYLE_ATTRIBUTE] = 'display'
+ pre_node[:class] = TAG_CLASS
end
end