def convert_text_content(document)
      document.children.each do |element|
        if element.is_a?(Nokogiri::XML::Text)
          unless element.parent.node_name == 'textarea'
            # textarea 以外のテキストなら content を変換
            element.content = filter(:hankaku, element.content)
          end
        elsif (element.node_name == 'input') && %w[submit reset button].include?(element['type'])
          # テキスト以外でもボタンの value は変換
          element['value'] = filter(:hankaku, element['value'])
        elsif element.children.any?
          # 子要素があれば再帰的に変換
          element = convert_text_content(element)
        end
        element
      end

      document
    end
def convert_text_content(document)
      document.children.each do |element|
        if element.is_a?(Nokogiri::XML::Text)
          unless element.parent.node_name == 'textarea'
            # textarea 以外のテキストなら content を変換
            element.content = filter(:hankaku, element.content)
          end
        elsif (element.node_name == 'input') && %w[submit reset button].include?(element['type'])
          # テキスト以外でもボタンの value は変換
          element['value'] = filter(:hankaku, element['value'])
        elsif element.children.any?
          # 子要素があれば再帰的に変換
          element = convert_text_content(element)
        end
        element
      end

      document
    end
再帰的に探す