Nokogiri语法错误翻译
Nokogiri syntax errors translation
我对数据库中的 html_document
列进行了自定义验证:
def html_format
bad_doc = Nokogiri::HTML(html_document) { |config| config.strict }
bad_doc.errors.each do |e|
errors.add(:html_document, [e.message,e.line].join(' at line: '))
end if bad_doc.errors.present?
end
我想翻译多种语言的返回错误。
从 Nokogiri 返回的错误如下所示:
Unexpected end tag : p
我通过浏览 Nokogiri 文档发现我可以检查返回错误的数量:
[1] pry(#<Model>)> errors.first.code
=> 76
我有一个想法,可以根据给定的代码进行翻译。
问题是,我在哪里可以找到完整的 table 错误代码和消息?
您需要查看 libxml2 源代码。
我对数据库中的 html_document
列进行了自定义验证:
def html_format
bad_doc = Nokogiri::HTML(html_document) { |config| config.strict }
bad_doc.errors.each do |e|
errors.add(:html_document, [e.message,e.line].join(' at line: '))
end if bad_doc.errors.present?
end
我想翻译多种语言的返回错误。
从 Nokogiri 返回的错误如下所示:
Unexpected end tag : p
我通过浏览 Nokogiri 文档发现我可以检查返回错误的数量:
[1] pry(#<Model>)> errors.first.code
=> 76
我有一个想法,可以根据给定的代码进行翻译。
问题是,我在哪里可以找到完整的 table 错误代码和消息?
您需要查看 libxml2 源代码。