Discussion:
[Docutils-users] Highlighting interactive REPL sessions.
Oleksandr Gavenko
2016-02-15 22:58:08 UTC
Permalink
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

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 or make own directive:

.. repl::
:prompt1: "^bash# "
:prompt2: "^$ "
:prompt3: "^mysql> "

Does anyone work on this?
--
http://defun.work/


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.
Guenter Milde
2016-02-16 11:37:51 UTC
Permalink
Post by Oleksandr Gavenko
bash# cd ~/sql
bash# mysql
[mariadb]> select 1;
http://pygments.org/docs/lexers/
.. code:: bash
.. code:: console
.. code:: pycon
.. code:: postgresql-console
The last one seems quite near to me...
Post by Oleksandr Gavenko
but even with Bash it only highlight "$" sign and think my "bash#" prompt as
output...
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
Post by Oleksandr Gavenko
make own directive
Günter


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.

Loading...