sed multiline pygmentize
Posted
by
dasickis
on Stack Overflow
See other posts from Stack Overflow
or by dasickis
Published on 2012-03-26T22:42:58Z
Indexed on
2012/03/26
23:28 UTC
Read the original article
Hit count: 191
I would like to take the html piece and pass it to pygmentize to colorize it accordingly. I'm wondering how I could use sed or some other cli tool to get that accomplished.
I tried a bunch of sed one-liners and tried to use the following SO questions:
- Sed multiline replacement question
- Using or in multiline sed replacement
- sed or awk multiline replace
I have the following log:
2012-03-26 18:04:27,385 9372 [main] ERROR web.commons.exception.ServiceInvocationException -
Response from server cannot be decoded to JSON, responsePayload = <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing jetty-url. Reason:
<pre> Not Found</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</body>
</html>
org.codehaus.jackson.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: java.io.StringReader@369133f6; line: 1, column: 2]
UPDATE I'm adding this to a longer command:
mvn -U test | (while read line; do echo ${line} | sed -e "s/.*ERROR.*/`echo -e '\e[91m&\e[0m'`/g" -e "s/.*\(WARN|INFO\).*/`echo -e '\e[93m&\e[0m'`/g"; done)
© Stack Overflow or respective owner