Class: Gitt::Sanitizers::Paragraphs

Inherits:
Object
  • Object
show all
Defined in:
lib/gitt/sanitizers/paragraphs.rb

Overview

Detects and parses paragraphs (including code blocks).

Constant Summary collapse

PATTERN =
/
  (              # Condition start.
  (?:\..*?\n)?   # Optional ASCII Doc label.
  (?:\[.*\]\n)?  # Optional ASCII Doc directive.
  [-_=+\.\*]{4}  # ASCII Doc block start.
  [\s\S]*?       # Lazy block content of any character.
  [-_=+\.\*]{4}  # ASCII Doc block end.
  |              # Or.
  ```            # Markdown start.
  [\s\S]*?       # Lazy block content of any character.
  ```            # Markdown end.
  )              # Condition end.
/mx

Instance Method Summary collapse

Constructor Details

#initialize(pattern: PATTERN, client: StringScanner) ⇒ Paragraphs

Returns a new instance of Paragraphs.



27
28
29
30
# File 'lib/gitt/sanitizers/paragraphs.rb', line 27

def initialize pattern: PATTERN, client: StringScanner
  @pattern = pattern
  @client = client
end

Instance Method Details

#call(text) ⇒ Object



32
# File 'lib/gitt/sanitizers/paragraphs.rb', line 32

def call(text) = scan(client.new(text.to_s))