From aba8be4f048cb44f3439aabda5aac3ed8908ed47 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 15 Apr 2017 17:57:13 +0200 Subject: [PATCH 1/2] Added diff lexer that disables copying +/- --- _build/_theme/_exts/symfonycom/sphinx/lexer.py | 17 +++++++++++++++++ _build/conf.py | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/_build/_theme/_exts/symfonycom/sphinx/lexer.py b/_build/_theme/_exts/symfonycom/sphinx/lexer.py index 4100b66d283..c3f1d3d4917 100644 --- a/_build/_theme/_exts/symfonycom/sphinx/lexer.py +++ b/_build/_theme/_exts/symfonycom/sphinx/lexer.py @@ -21,3 +21,20 @@ class TerminalLexer(RegexLexer): ('(.+)$', bygroups(using(BatchLexer)), '#pop') ], } + + +class NonCopyDiffLexer(RegexLexer): + name = 'NonCopyDiff' + aliases = ['non-copy-diff'] + filenames = [] + + tokens = { + 'root': [ + ('^\+ ', Generic.DiffIndicator, 'inserted'), + ('^- ', Generic.DiffIndicator, 'deleted'), + ('^ ', Generic.DiffIndicator, 'text') + ], + 'inserted': [('.+$', Generic.Inserted)], + 'deleted': [('.+$', Generic.Deleted)], + 'text': [('.+$', Text)] + } diff --git a/_build/conf.py b/_build/conf.py index 44303b18dbe..e2d8784ce7f 100644 --- a/_build/conf.py +++ b/_build/conf.py @@ -24,7 +24,7 @@ from pygments.lexers.special import TextLexer from pygments.lexers.text import RstLexer from pygments.lexers.web import PhpLexer -from symfonycom.sphinx.lexer import TerminalLexer +from symfonycom.sphinx.lexer import TerminalLexer, NonCopyDiffLexer # -- General configuration ----------------------------------------------------- @@ -110,6 +110,7 @@ lexers['varnish3'] = CLexer() lexers['varnish4'] = CLexer() lexers['terminal'] = TerminalLexer() +lexers['diff'] = NonCopyDiffLexer() config_block = { 'markdown': 'Markdown', From 789dc98730782dcfec405a01dc85d18f6cbc546d Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 15 Apr 2017 17:57:26 +0200 Subject: [PATCH 2/2] Added example of new diff lexer --- page_creation.rst | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/page_creation.rst b/page_creation.rst index 91c3ce72400..07c685b57b5 100644 --- a/page_creation.rst +++ b/page_creation.rst @@ -114,25 +114,27 @@ First, make sure that ``LuckyController`` extends Symfony's base } Now, use the handy ``render()`` function to render a template. Pass it our ``number`` -variable so we can render that:: - - // src/AppBundle/Controller/LuckyController.php - // ... - - class LuckyController extends Controller - { - /** - * @Route("/lucky/number") - */ - public function numberAction() - { - $number = mt_rand(0, 100); - - return $this->render('lucky/number.html.twig', array( - 'number' => $number, - )); - } - } +variable so we can render that: + +.. code-block:: diff + + // src/AppBundle/Controller/LuckyController.php + // ... + + class LuckyController extends Controller + { + /** + * @Route("/lucky/number") + */ + public function numberAction() + { + + $number = mt_rand(0, 100); + + + return $this->render('lucky/number.html.twig', array( + + 'number' => $number, + + )); + } + } Finally, template files should live in the ``app/Resources/views`` directory. Create a new ``app/Resources/views/lucky`` directory with a new ``number.html.twig`` file