--[[TeXworksScript Title: Parse LaTeX Log (Example) Description: Gives examples of how to modify the output log of a LaTeX run Author: Alain Delmotte Version: 0.1 Date: 2009-06-07 Script-Type: hook Hook: AfterTypeset ]] local errors = "" local badboxes = "" local warnings = "" local place = 1 local chaine = "" local log function TrouverLigne () local suite = "" repeat suite = suite .. string.sub(log,place,place) place = place + 1 until string.byte(string.sub(log,place,place)) == 10 return suite end if type(output) == "string" then do log = output chaine = TrouverLigne() while place < string.len(log) do if (string.find(chaine,"Overfull") ~= nil) or (string.find(chaine,"Underfull") ~= nil) then badboxes = badboxes .. chaine elseif string.find(chaine,"LaTeX Warning") ~= nil then warnings = warnings .. chaine elseif string.find(chaine,"! ") ~= nil then errors = errors .. chaine end chaine = TrouverLigne() end output = {} output[1] = { ["label"] = "Errors"; ["type"] = 1; ["data"] = errors } output[2] = { ["label"] = "Warnings"; ["type"] = 1; ["data"] = warnings } output[3] = { ["label"] = "Bad boxes"; ["type"] = 1; ["data"] = badboxes } end end