Class: Source2MD::Scanner
- Inherits:
-
Object
- Object
- Source2MD::Scanner
- Defined in:
- lib/source2md/scanner.rb
Constant Summary collapse
- SEPARATOR =
"\\R{2,}"- SRC_BEGIN_KEY =
"BEGIN_SRC"- SRC_END_KEY =
"END_SRC"- SRC_BLOCK_RE =
/^#\+#{SRC_BEGIN_KEY}.*?^#\+#{SRC_END_KEY}/m- NORMAL_BLOCK_RE =
/.*?#{SEPARATOR}/m- PARAGRAPH_RE =
Regexp.union [ SRC_BLOCK_RE, NORMAL_BLOCK_RE, ]
Instance Method Summary collapse
-
#initialize(content) ⇒ Scanner
constructor
A new instance of Scanner.
- #to_a ⇒ Object
Constructor Details
#initialize(content) ⇒ Scanner
Returns a new instance of Scanner.
16 17 18 |
# File 'lib/source2md/scanner.rb', line 16 def initialize(content) @content = content end |
Instance Method Details
#to_a ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/source2md/scanner.rb', line 20 def to_a v = @content if Source2MD.xmp_out_exclude v = v.remove(/^# >>.*$/) end v = v + "\n\n" v = v.scan(PARAGRAPH_RE) v = v.collect(&:rstrip) v = v.find_all(&:present?) end |