Class: Cooklang::Processors::TokenProcessor
- Inherits:
-
Object
- Object
- Cooklang::Processors::TokenProcessor
- Defined in:
- lib/cooklang/processors/token_processor.rb
Class Method Summary collapse
Class Method Details
.extract_notes(tokens) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cooklang/processors/token_processor.rb', line 28 def extract_notes(tokens) notes = [] content_tokens = [] i = 0 while i < tokens.length if tokens[i].type == :note_marker note_content, i = extract_single_note(tokens, i) notes << Note.new(content: note_content) unless note_content.empty? else content_tokens << tokens[i] i += 1 end end [notes, content_tokens] end |
.strip_comments(tokens) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cooklang/processors/token_processor.rb', line 7 def strip_comments(tokens) result = [] i = 0 while i < tokens.length token = tokens[i] case token.type when :comment_line i = handle_comment_line(tokens, i, result) when :comment_block_start i = skip_comment_block(tokens, i) else result << token i += 1 end end result end |