Module: ImmosquareCleaner::Markdown
- Defined in:
- lib/immosquare-cleaner/markdown.rb
Class Method Summary collapse
-
.clean(file_path) ⇒ Object
## we want to clean the markdown files to have a uniform style for the tables.
Class Method Details
.clean(file_path) ⇒ Object
##
we want to clean the markdown files to have a uniform style for the tables.
##
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/immosquare-cleaner/markdown.rb', line 10 def clean(file_path) results = [] array_to_parse = [] prev_line_special = false ##============================================================## ## We parse each line of the file ##============================================================## File.foreach(file_path) do |line| if line.lstrip.start_with?("|") array_to_parse << line else if !array_to_parse.empty? results << cleaned_array(array_to_parse) array_to_parse = [] end new_line, prev_line_special = cleaned_line(line, prev_line_special) results << new_line end end ##============================================================## ## Handle the case where the file ends with a table ##============================================================## results << cleaned_array(array_to_parse) if !array_to_parse.empty? results.join end |