Adding grid table filter for Gitlab

Merge request reports

Loading
+27
Changes for gitlabFilter/README.md: 27 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Grid Table filter

The grid_table_filter.rb file is a Ruby script that defines a filter for converting Pandoc-style grid tables into HTML tables with support for rowspan and colspan. Here is a summary of the key components and functionality.

## Module and Class Definitions

The script is encapsulated within the Banzai::Filter module.
The main class is GridTableFilter, which inherits from HTML::Pipeline::TextFilter.

- Regex Constants: Several regex constants are defined to match different parts of the grid table structure, such as separators and body lines.

- Helper Classes:
  - Cell: Represents a cell in the table with attributes like content, rowspan, colspan, alignment, etc.
  - Row: Represents a row in the table, containing an array of Cell objects.
  - RowTracker: Tracks the number of rows for each column to manage rowspan.

- Helper Methods:
  - separator?: Checks if a line is a separator.
  - handling_content: Processes the content of a cell, handling lists and newlines.
  - adjust_colspan: Adjusts the colspan of cells based on the delimiter positions.

- Main Methods:
  - parse_pandoc_table_with_spans: Parses the Pandoc table, identifies headers, and processes rows to create a structured representation of the table.
  - generate_html_table_with_spans: Converts the parsed table structure into an HTML table.
  - call: The main entry point for the filter, which applies the regex to find grid tables and converts them to HTML.

- Error Handling: The script includes error handling to manage invalid table formats and log errors.
+661

File added.

Preview size limit exceeded, changes collapsed.

+21
Changes for gitlabFilter/plain_markdown_pipeline.rb: 21 added lines, 0 removed lines.
Original line number Diff line number Diff line
# frozen_string_literal: true

module Banzai
    module Pipeline
      class PlainMarkdownPipeline < BasePipeline
        def self.filters
          FilterArray[
            Filter::IncludeFilter,
            Filter::GridTableFilter,
            Filter::MarkdownPreEscapeLegacyFilter,
            Filter::DollarMathPreLegacyFilter,
            Filter::BlockquoteFenceLegacyFilter,
            Filter::MarkdownFilter,
            Filter::ConvertTextToDocFilter,
            Filter::DollarMathPostLegacyFilter,
            Filter::MarkdownPostEscapeLegacyFilter
          ]
        end
      end
    end
  end
 No newline at end of file
Loading