# frozen_string_literal: true

require 'pathname'
require 'fileutils'
root_path = `pwd`.strip
math_files = '/docs/en/**/*.md'
path_arr = Dir[root_path + math_files]
path_arr.each do |file_path|
  flag = false
  File.open("#{file_path}.new", 'w') do |out_file|
    File.foreach(file_path) do |line|
      if line.match(/^#/)
        line.gsub!('[]()', '')
        flag = true
      end

      if line.match(/^---/)
        flag = false
      end

      out_file.puts line if flag
    end

  end

  FileUtils.mv("#{file_path}.new", file_path)

end
