awk '
/^\\end{verbatim}/ { verbatim = 0 }
verbatim { print }
!verbatim {
# this retains the original line numbers
print ""
}
/^\\begin{verbatim}/ { verbatim = 1 }
' <<'EOF'
\documentclass{article}
\begin{document}
Let's start with boilerplate:
\begin{verbatim}
module Main where
import Control.Monad.Eff.Console (log)
\end{verbatim}
Let's have fun:
\begin{verbatim}
main = log "Hello, world!"
\end{verbatim}
\end{document}
EOF