I found line numbers on code blocks in rmarkdown::html_document is possible by
giving YAML front matter with highlight: pygment and chunk options with class.source = "numberLines" (https://blog.atusy.net/submodules/rmd-line-num/index.html)
However, this is not the case for bookdown::html_document2 and because bookdown:::clean_pandoc2_highlight_tags removes tags required for numbering.
Does anybody know why this process is required?
Example
A following screenshot is created by html code below.

<div class="sourceCode" id="cb15"><pre class="sourceCode numberSource r numberLines"><code class="sourceCode r"><a class="sourceLine" id="cb15-1" title="1">x <-<span class="st"> </span><span class="kw">seq</span>(<span class="dv">10</span>)</a>
<a class="sourceLine" id="cb15-2" title="2"><span class="kw">mean</span>(x)</a></code></pre></div>
Embedding the above html code directory in .Rmd file and kniting as bookdown:::html_document2 results in
<div id="cb15" class="sourceCode">
<pre class="sourceCode numberSource r numberLines"><code class="sourceCode r">x <-<span class="st"> </span><span class="kw">seq</span>(<span class="dv">10</span>)
<span class="kw">mean</span>(x)</code></pre>
</div>
which is rendered on browser as
