\documentclass{book}
\usepackage{lipsum}
\usepackage{listings}
\usepackage[extrafootnotefeatures]{bidi}

\paragraphfootnotes

\begin{document}
\lipsum[1-2]
{\scshape some text some text some text some text some text}\footnote{my footnote!}.
    
    \begin{lstlisting}[frame=single,numbers=left,]
\documentclass[11pt]{article}
\usepackage{fullpage}
\usepackage{url}
\usepackage{lipsum}

\title{Parsi\LaTeX}
\author{Razavian}

\begin{document}

\maketitle
\tableofcontents

\section{section}
\lipsum[2]
\subsection{subsection}
text \textbf{bold text} text. 
Some math: $2+2=5$
\subsection{subsection}
text \emph{emphasized text} citation.

A table:
\begin{table}[!th]
\centering
\begin{tabular}{|l|c|r|}
\hline
first  &  row  & data \\
second &  row  &  data \\
\hline
\end{tabular}
\caption{This is the caption}
\label{tab:test}
\end{table}

The table is numbered \ref{tab:test}.

\end{document}
    \end{lstlisting}
    
\end{document}    
