Content-Length: 288912 | pFad | http://github.com/sphinx-doc/sphinx/issues/747

84 Allow for more pygments.formatters.html.HTMLFormatters options · Issue #747 · sphinx-doc/sphinx · GitHub
Skip to content

Allow for more pygments.formatters.html.HTMLFormatters options #747

Open
@shimizukawa

Description

@shimizukawa

When using long code blocks, say the source code of a full source file which is referenced, it is useful to not only display the line numbers ( which is possible via the :linenos: role ) but also to reference individual lines marked as anchors. This is enabled by pygments in the HTMLFormatter using the lineanchors option. However this and other options of the same class are not supported by Sphinx.

It is possible to hack this into Sphinx easily adjusting the PygmentsBridge class:

if dest == 'html':
      self.fmter = {False: self.html_formatter(style=style)              
                        True: self.html_formatter(style=style, 
                                linenos=True,
                                lineanchors = 'L')}

It would be preferable to specify this in the code-block directive instead:

.. code-block:: c
    :linenos:
    :lineanchors:`L`

This together with appropriate semantic markup to reference the location. When missing one can fall back to the .. raw:: directive though, so providing a :lineanchors: attribute is of greater importance.


Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: http://github.com/sphinx-doc/sphinx/issues/747

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy