Loading gitlabFilter/grid_table_filter.rb +22 −3 Changes for gitlabFilter/grid_table_filter.rb: 22 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -34,6 +34,9 @@ module Banzai }mx # rubocop:enable Lint/MixedRegexpCaptureTypes # Fenced code blocks are left unchanged, including any grid table copied inside them. MARKDOWN_FENCED_CODE_BLOCK_REGEX = /^([`~]{3,})[^\n]*\n.*?^\1[ \t]*$\n?/m require 'logger' # Add these regex constants at the top of the file, after the require statement Loading Loading @@ -723,12 +726,12 @@ module Banzai # rubocop:enable Metrics/AbcSize def call current_text = text regex = MARKDOWN_GRID_TABLE_BLOCK_REGEX return current_text unless regex.match?(current_text) updated_text = current_text.gsub(regex) do convert_grid_tables = lambda do |segment| segment.gsub(regex) do match = Regexp.last_match # Extract the grid table content from the match grid_table = match[:code] Loading @@ -740,7 +743,23 @@ module Banzai match.to_s end end updated_text end return convert_grid_tables.call(current_text) unless MARKDOWN_FENCED_CODE_BLOCK_REGEX.match?(current_text) output = +"" cursor = 0 current_text.to_enum(:scan, MARKDOWN_FENCED_CODE_BLOCK_REGEX).each do code_block_match = Regexp.last_match non_code_segment = current_text[cursor...code_block_match.begin(0)] output << convert_grid_tables.call(non_code_segment) if non_code_segment output << code_block_match[0] cursor = code_block_match.end(0) end trailing_segment = current_text[cursor..] output << convert_grid_tables.call(trailing_segment) if trailing_segment output end end end Loading Loading
gitlabFilter/grid_table_filter.rb +22 −3 Changes for gitlabFilter/grid_table_filter.rb: 22 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -34,6 +34,9 @@ module Banzai }mx # rubocop:enable Lint/MixedRegexpCaptureTypes # Fenced code blocks are left unchanged, including any grid table copied inside them. MARKDOWN_FENCED_CODE_BLOCK_REGEX = /^([`~]{3,})[^\n]*\n.*?^\1[ \t]*$\n?/m require 'logger' # Add these regex constants at the top of the file, after the require statement Loading Loading @@ -723,12 +726,12 @@ module Banzai # rubocop:enable Metrics/AbcSize def call current_text = text regex = MARKDOWN_GRID_TABLE_BLOCK_REGEX return current_text unless regex.match?(current_text) updated_text = current_text.gsub(regex) do convert_grid_tables = lambda do |segment| segment.gsub(regex) do match = Regexp.last_match # Extract the grid table content from the match grid_table = match[:code] Loading @@ -740,7 +743,23 @@ module Banzai match.to_s end end updated_text end return convert_grid_tables.call(current_text) unless MARKDOWN_FENCED_CODE_BLOCK_REGEX.match?(current_text) output = +"" cursor = 0 current_text.to_enum(:scan, MARKDOWN_FENCED_CODE_BLOCK_REGEX).each do code_block_match = Regexp.last_match non_code_segment = current_text[cursor...code_block_match.begin(0)] output << convert_grid_tables.call(non_code_segment) if non_code_segment output << code_block_match[0] cursor = code_block_match.end(0) end trailing_segment = current_text[cursor..] output << convert_grid_tables.call(trailing_segment) if trailing_segment output end end end Loading