programming code in tex

After adding a piece of code in text, I wish it could look like this: .

Now I used \verb@@ to insert command, but it does not handle line break and indentation.

• Welcome to TeX.SX! What have you done so far? Could you please add some working code? – Bobyandbob Apr 25 '18 at 9:00
• @Bobyandbob Usually program developers use markdown to write document, but I would like to use tex to achieve the same effect. – Tiina Apr 26 '18 at 2:12

Here is a solution for your black box.

\documentclass{article}
\usepackage{tcolorbox}
\usepackage{fancyvrb}
\usepackage{xcolor}

\begin{document}
\begin{tcolorbox}[colframe=black,colback=black,coltext=white]
\begin{Verbatim}[commandchars=\\\{\}]
$svn log --xml | grep P \textcolor{yellow}{"^<author"} | sort u | \textbackslash perl -pe \textcolor{yellow}{'s/<author>(.*?)<\textbackslash/author>/$1 = /'} > users.txt
\end{Verbatim}
\end{tcolorbox}
\end{document}


• perfect, the solution is very inspiring. – Tiina Apr 26 '18 at 2:28