Skip to content

Instantly share code, notes, and snippets.

@nashid
Created December 7, 2021 03:10
Show Gist options
  • Select an option

  • Save nashid/b64518f4b4402d991efec72edd6303ee to your computer and use it in GitHub Desktop.

Select an option

Save nashid/b64518f4b4402d991efec72edd6303ee to your computer and use it in GitHub Desktop.
Code listing with highlighting in latex
\definecolor{ashgrey}{rgb}{0.7, 0.75, 0.71}
\begin{lstlisting}[firstnumber=1]
'use strict';
const common = require('../common');
...
\end{lstlisting}
\vspace{-\baselineskip}
\begin{lstlisting}[firstnumber=10, backgroundcolor=\color{ashgrey}]
function main({ len, n }) {
const { internalBinding } = require('internal/test/binding');
const { HTTPParser } = internalBinding('http_parser');
const REQUEST = HTTPParser.REQUEST;
\end{lstlisting}
\vspace{-\baselineskip}
\begin{lstlisting}[firstnumber=20]
const kOnHeaders = HTTPParser.kOnHeaders | 0;
...
\end{lstlisting}
\vspace{-\baselineskip}
\begin{lstlisting}[firstnumber=50,backgroundcolor=\color{ashgrey}]
function processHeader(header, n) {
const parser = newParser(REQUEST);
for (var i = 0; i < n; i++) {
- parser.reinitialize(REQUEST);
+ parser.reinitialize(REQUEST, i > 0);
}
}
\end{lstlisting}
\vspace{-\baselineskip}
\begin{lstlisting} [firstnumber=80, caption={Sliced program with missing argument},captionpos=b]
...
processHeader(Buffer.from(header), n);
}
\end{lstlisting}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment