module Webgen::ContentProcessor::Xmllint
Uses the external xmllint program to check if the content is valid (X)HTML.
Public Class Methods
call(context)
click to toggle source
Checks the content of context with the xmllint program for validness.
# File lib/webgen/content_processor/xmllint.rb 12 def self.call(context) 13 Webgen::Utils::ExternalCommand.ensure_available!('xmllint', '--version') 14 15 cmd = "xmllint #{context.website.config['content_processor.xmllint.options']} -" 16 status, _stdout, stderr = systemu(cmd, 'stdin' => context.content) 17 if status.exitstatus != 0 18 stderr.scan(/^-:(\d+):(.*?\n)(.*?\n)/).each do |line, error_msg, line_context| 19 context.website.logger.warn do 20 "xmllint reported problems for <#{context.dest_node.alcn}:~#{line}>: #{error_msg.strip} (context: #{line_context.strip})" 21 end 22 end 23 end 24 context 25 end