From: Guenter M. <mi...@us...> - 2016-02-16 11:38:07
|
On 2016-02-15, Oleksandr Gavenko wrote: > How can I highlight interactive REPL sessions? Like: > bash# cd ~/sql > bash# mysql > Password: > [mariadb]> select 1; > Among: > http://pygments.org/docs/lexers/ > I see possibility to use various: > .. code:: bash > .. code:: console > .. code:: pycon > .. code:: postgresql-console The last one seems quite near to me... > but even with Bash it only highlight "$" sign and think my "bash#" prompt as > output... > I see a way to add to "code" additional parameter (prompt regex): > http://docutils.sourceforge.net/docs/ref/rst/directives.html#code > and implement parser in pygments This should work - maybe postgresql-console is a good starting point. Look/ask the Pygments community for details. With a new parser/lexer "repl-console", the rst syntax would be:: .. code:: postgresql-console bash# cd ~/sql As docutils calls the external Pygments for syntax highlight, this should be available to Docutils if it works with Pygments. There is no need to > make own directive Günter |