fork download
  1. # your code goes here
  2. text = STDIN.read
  3.  
  4. puts text.gsub(/\{\\defun\s+([^\}]*)\}/, "{\\defun{\\1}}")
Success #stdin #stdout 0.01s 7416KB
stdin
\documentclass{article}
\newcommand{\defun}{\tt}

\begin{document}
\section{\defun SomeFunctionName arg1 arg2}
Call {\defun SomeFunctionName} to foo the bar.
\end{document}
stdout
\documentclass{article}
\newcommand{\defun}{\tt}

\begin{document}
\section{\defun{SomeFunctionName arg1 arg2}}
Call {\defun{SomeFunctionName}} to foo the bar.
\end{document}