'How to display code blocks with word wrap and line number with jekyll markdown on github-pages

I am using github pages to host my blog. It uses GitHub Flaword Markdown. Here is part of _config.yml:

markdown: kramdown
# Use Github Flavored Markdown
kramdown:
  input: GFM

My articles often contain long lines of code, and I would like to display it with word wrap(so it can be all seen without scrolling) and with line numbers(that allow to distinguish new line from word warp).

I found, that I can enable word wrap, if I use this css property for <pre> tag: white-space: pre-wrap. But how can I display line numbers? I am looking for solution that will allow me to continue using github-pages built-in jekyll, that generates blog pages for me automatically.



Solution 1:[1]

Code::Blocks version 20.03 for wrap code line settings<Editor<General Settings<Other Editor Settings<Word Wrap

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sanjida Kabir