File manager - Edit - /usr/share/doc/python3-pygments/html/docs/plugins.html
Back
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Register Plugins — Pygments 2.2.0 documentation</title> <link rel="stylesheet" href="../_static/pygments14.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <link rel="shortcut icon" href="../_static/favicon.ico"/> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="next" title="Using Pygments in ReST documents" href="rstdirective.html" /> <link rel="prev" title="Write your own filter" href="filterdevelopment.html" /> <link href='http://fonts.googleapis.com/css?family=PT+Sans:300,400,700' rel='stylesheet' type='text/css'> <style type="text/css"> table.right { float: right; margin-left: 20px; } table.right td { border: 1px solid #ccc; } </style> <script type="text/javascript"> // intelligent scrolling of the sidebar content $(window).scroll(function() { var sb = $('.sphinxsidebarwrapper'); var win = $(window); var sbh = sb.height(); var offset = $('.sphinxsidebar').position()['top']; var wintop = win.scrollTop(); var winbot = wintop + win.innerHeight(); var curtop = sb.position()['top']; var curbot = curtop + sbh; // does sidebar fit in window? if (sbh < win.innerHeight()) { // yes: easy case -- always keep at the top sb.css('top', $u.min([$u.max([0, wintop - offset - 10]), $(document).height() - sbh - 200])); } else { // no: only scroll if top/bottom edge of sidebar is at // top/bottom edge of window if (curtop > wintop && curbot > winbot) { sb.css('top', $u.max([wintop - offset - 10, 0])); } else if (curtop < wintop && curbot < winbot) { sb.css('top', $u.min([winbot - sbh - offset - 20, $(document).height() - sbh - 200])); } } }); </script> </head><body> <div class="outerwrapper"> <div class="pageheader"> <ul> <li><a href="../index.html">Home</a></li> <li><a href="../languages.html">Languages</a></li> <li><a href="../faq.html">FAQ</a></li> <li><a href="../download.html">Get it</a></li> <li><a href="index.html">Docs</a></li> </ul> <div> <a href="../index.html"> <img src="../_static/logo.png" alt="Pygments logo" /> </a> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h3><a href="../index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Register Plugins</a><ul> <li><a class="reference internal" href="#entrypoints">Entrypoints</a></li> <li><a class="reference internal" href="#how-to-use-entrypoints">How To Use Entrypoints</a></li> <li><a class="reference internal" href="#extending-the-core">Extending The Core</a></li> </ul> </li> </ul> <strong>« <a href="index.html">Back to docs index</a></strong> <div id="searchbox" style="display: none" role="search"> <h3>Quick search</h3> <div class="searchformwrapper"> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="register-plugins"> <h1>Register Plugins<a class="headerlink" href="#register-plugins" title="Permalink to this headline">¶</a></h1> <p>If you want to extend Pygments without hacking the sources, but want to use the lexer/formatter/style/filter lookup functions (<cite>lexers.get_lexer_by_name</cite> et al.), you can use <a class="reference external" href="http://peak.telecommunity.com/DevCenter/setuptools">setuptools</a> entrypoints to add new lexers, formatters or styles as if they were in the Pygments core.</p> <p>That means you can use your highlighter modules with the <cite>pygmentize</cite> script, which relies on the mentioned functions.</p> <div class="section" id="entrypoints"> <h2>Entrypoints<a class="headerlink" href="#entrypoints" title="Permalink to this headline">¶</a></h2> <p>Here is a list of setuptools entrypoints that Pygments understands:</p> <p><cite>pygments.lexers</cite></p> <blockquote> <div><p>This entrypoint is used for adding new lexers to the Pygments core. The name of the entrypoint values doesn’t really matter, Pygments extracts required metadata from the class definition:</p> <div class="highlight-ini notranslate"><div class="highlight"><pre><span></span><span class="k">[pygments.lexers]</span> <span class="na">yourlexer</span> <span class="o">=</span> <span class="s">yourmodule:YourLexer</span> </pre></div> </div> <p>Note that you have to define <code class="docutils literal notranslate"><span class="pre">name</span></code>, <code class="docutils literal notranslate"><span class="pre">aliases</span></code> and <code class="docutils literal notranslate"><span class="pre">filename</span></code> attributes so that you can use the highlighter from the command line:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">YourLexer</span><span class="p">(</span><span class="o">...</span><span class="p">):</span> <span class="n">name</span> <span class="o">=</span> <span class="s1">'Name Of Your Lexer'</span> <span class="n">aliases</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'alias'</span><span class="p">]</span> <span class="n">filenames</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'*.ext'</span><span class="p">]</span> </pre></div> </div> </div></blockquote> <p><cite>pygments.formatters</cite></p> <blockquote> <div><p>You can use this entrypoint to add new formatters to Pygments. The name of an entrypoint item is the name of the formatter. If you prefix the name with a slash it’s used as a filename pattern:</p> <div class="highlight-ini notranslate"><div class="highlight"><pre><span></span><span class="k">[pygments.formatters]</span> <span class="na">yourformatter</span> <span class="o">=</span> <span class="s">yourmodule:YourFormatter</span> <span class="na">/.ext</span> <span class="o">=</span> <span class="s">yourmodule:YourFormatter</span> </pre></div> </div> </div></blockquote> <p><cite>pygments.styles</cite></p> <blockquote> <div><p>To add a new style you can use this entrypoint. The name of the entrypoint is the name of the style:</p> <div class="highlight-ini notranslate"><div class="highlight"><pre><span></span><span class="k">[pygments.styles]</span> <span class="na">yourstyle</span> <span class="o">=</span> <span class="s">yourmodule:YourStyle</span> </pre></div> </div> </div></blockquote> <p><cite>pygments.filters</cite></p> <blockquote> <div><p>Use this entrypoint to register a new filter. The name of the entrypoint is the name of the filter:</p> <div class="highlight-ini notranslate"><div class="highlight"><pre><span></span><span class="k">[pygments.filters]</span> <span class="na">yourfilter</span> <span class="o">=</span> <span class="s">yourmodule:YourFilter</span> </pre></div> </div> </div></blockquote> </div> <div class="section" id="how-to-use-entrypoints"> <h2>How To Use Entrypoints<a class="headerlink" href="#how-to-use-entrypoints" title="Permalink to this headline">¶</a></h2> <p>This documentation doesn’t explain how to use those entrypoints because this is covered in the <a class="reference external" href="http://peak.telecommunity.com/DevCenter/setuptools">setuptools documentation</a>. That page should cover everything you need to write a plugin.</p> </div> <div class="section" id="extending-the-core"> <h2>Extending The Core<a class="headerlink" href="#extending-the-core" title="Permalink to this headline">¶</a></h2> <p>If you have written a Pygments plugin that is open source, please inform us about that. There is a high chance that we’ll add it to the Pygments distribution.</p> </div> </div> </div> </div> </div> <div class="clearer"></div> </div> <div class="footer" role="contentinfo"> © Copyright 2006-2017, Georg Brandl and Pygments contributors. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.6. <br/> Pygments logo created by <a href="http://joelunger.com">Joel Unger</a>. Backgrounds from <a href="http://subtlepatterns.com">subtlepatterns.com</a>. </div> </div> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 8.2.30 | Generation time: 0 |
proxy
|
phpinfo
|
Settings