class ThirdModifyKeForStudentWork < ActiveRecord::Migration[5.2]
  include ActionView::Helpers::SanitizeHelper
  def change
    # def ke_transform_to_md content
    #   return content if content.blank?
    #   s_contents = sanitize(content, tags: %w(img a span table td tr tbody pre), attributes: %w(src href target style))
    #   s_contents.gsub(">\n<", "><").gsub(/^\n/, "").gsub(" ", "&nbsp;").gsub(/(\n)+/, "<br />")
    #       .gsub("\t", "&nbsp;&nbsp;&nbsp;&nbsp;").gsub("\n", "").gsub(" ", "&nbsp;").gsub(/(<br\s?\/?>)+/, "<br />")
    # end
    #
    # # 学生的作品 过滤掉一些描述的ke图片的作品
    # StudentWork.where("description is not null and LENGTH(description) < 1000000").find_each do |sw|
    #     description  = ke_transform_to_md sw.description
    #     sw.update_column(:description, description)
    # end
  end
end
