Re: Is there a plan to integrate fenced code blocks in rst?

Guenter Milde via Docutils-users <[email protected]> Mon, 7 Dec 2020 07:20:26 -0000 (UTC)
Newsgroups gmane.text.docutils.user
Message-ID <[email protected]>
On 2020-12-06, Gökçe Aydos wrote:

> [-- Type: text/plain, Encoding: quoted-printable --]

> On 06/12/2020 20:34, Alan G. Isaac wrote:
>> Why copy/paste at all when you can just ``include`` code?

> Thanks, that is a good idea for longer code Alan!

> My case is different. For example in one document I have about 50 code 
> blocks, which are about 2 to 8 lines long. Creating 50 files for this 
> purpose would be very inconvenient.


> When I copy code from the rendered version then it's no problem, but 
> copying from the rst source is very error-prone due to the indentation, 
> e.g.,:

> code:: sh

>    cat > file <<EOF
>      4spaces here instead of 2
>    and EOF does not work
>    EOF

When working with reStructuredText, I find myself using the "rectangualar
blocks" feature of my text editor a lot.

However, your example looks a lot like a use case for `PyLit`_, where you
can convert easily in both directions between a "text" and "code" version
of a document, e.g.,

text::

  # Options for HTML output
  # -----------------------
  #
  # The style sheet to use for HTML and HTML Help pages. A file of that name
  # must exist either in Sphinx' static/ path, or in one of the custom paths
  # given in html_static_path::
  
  html_style = 'pylit-sphinx.css'
  # html_style = 'sphinxdoc.css'
  
  # Options to the theme, like a sidebar that is visible even when
  # scrolling (TODO: how to get this to work (maybe just update Spinx)?)::
  
  #html_theme_options = {'stickysidebar': 'true'}
  
  # The name for this set of Sphinx documents.  If None, it defaults to
  # "<project> v<release> documentation". ::
  
  html_title = "PyLit"
  
  # A shorter title for the navigation bar.  Default is the same as html_title.
  # ::
  
  html_short_title = "Home"

code::
  
  Options for HTML output
  -----------------------
  
  The style sheet to use for HTML and HTML Help pages. A file of that name
  must exist either in Sphinx' static/ path, or in one of the custom paths
  given in html_static_path::
  
    html_style = 'pylit-sphinx.css'
    # html_style = 'sphinxdoc.css'
    
  Options to the theme, like a sidebar that is visible even when
  scrolling (TODO: how to get this to work (maybe just update Spinx)?)::
  
    #html_theme_options = {'stickysidebar': 'true'}
    
  The name for this set of Sphinx documents.  If None, it defaults to
  "<project> v<release> documentation". ::
  
    html_title = "PyLit"
    
  A shorter title for the navigation bar.  Default is the same as html_title.
  ::
  
    html_short_title = "Home"


Günter


.. _Pylit: https://pypi.org/project/pylit/



_______________________________________________
Docutils-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/docutils-users

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