Sphinx code block renders strangely in HTML












0















I am trying to use Sphinx code blocks and I am getting strange rendering in HTML. My source is:



The following image shows both the source code used and how it was rendered in HTML



Here is the source rst for the page



************
Testing Page
************

Used for testing Sphinx constructs

Why does the role get rendered in HTML?

..code-block:: python

This is a code line
and so is this.

It is very confused because it emits the following error::
D:SharedWiseOldbirdProjectsPlatform IndependentApplicationControllerdocssourceTest.rst:12: WARNING: Block quote ends without a blank line; unexpected unindent

If I try it like this without the language specification it renders the role and displays the code block correctly -
note that it strips a single colon from the role directive

..code-block::

This is a code line
and so is this.

If I use a literal block.::

I get a colon in the text that introduces the literal block

Heading
-------


What do I need to do to use Sphinx code blocks correctly?










share|improve this question

























  • Please show us code and markup as text, not as an image.

    – mzjn
    Jan 2 at 19:13











  • I have no idea how to show the markup as text on Stackoverflow

    – Jonathan
    Jan 2 at 19:18











  • I am attempting to show the rendered HTML output.

    – Jonathan
    Jan 2 at 19:24











  • Yes that's fine. But please provide RST markup as plain text.

    – mzjn
    Jan 2 at 19:26













  • A space is missing. Change ..code-block:: python to .. code-block:: python.

    – mzjn
    Jan 2 at 19:32
















0















I am trying to use Sphinx code blocks and I am getting strange rendering in HTML. My source is:



The following image shows both the source code used and how it was rendered in HTML



Here is the source rst for the page



************
Testing Page
************

Used for testing Sphinx constructs

Why does the role get rendered in HTML?

..code-block:: python

This is a code line
and so is this.

It is very confused because it emits the following error::
D:SharedWiseOldbirdProjectsPlatform IndependentApplicationControllerdocssourceTest.rst:12: WARNING: Block quote ends without a blank line; unexpected unindent

If I try it like this without the language specification it renders the role and displays the code block correctly -
note that it strips a single colon from the role directive

..code-block::

This is a code line
and so is this.

If I use a literal block.::

I get a colon in the text that introduces the literal block

Heading
-------


What do I need to do to use Sphinx code blocks correctly?










share|improve this question

























  • Please show us code and markup as text, not as an image.

    – mzjn
    Jan 2 at 19:13











  • I have no idea how to show the markup as text on Stackoverflow

    – Jonathan
    Jan 2 at 19:18











  • I am attempting to show the rendered HTML output.

    – Jonathan
    Jan 2 at 19:24











  • Yes that's fine. But please provide RST markup as plain text.

    – mzjn
    Jan 2 at 19:26













  • A space is missing. Change ..code-block:: python to .. code-block:: python.

    – mzjn
    Jan 2 at 19:32














0












0








0








I am trying to use Sphinx code blocks and I am getting strange rendering in HTML. My source is:



The following image shows both the source code used and how it was rendered in HTML



Here is the source rst for the page



************
Testing Page
************

Used for testing Sphinx constructs

Why does the role get rendered in HTML?

..code-block:: python

This is a code line
and so is this.

It is very confused because it emits the following error::
D:SharedWiseOldbirdProjectsPlatform IndependentApplicationControllerdocssourceTest.rst:12: WARNING: Block quote ends without a blank line; unexpected unindent

If I try it like this without the language specification it renders the role and displays the code block correctly -
note that it strips a single colon from the role directive

..code-block::

This is a code line
and so is this.

If I use a literal block.::

I get a colon in the text that introduces the literal block

Heading
-------


What do I need to do to use Sphinx code blocks correctly?










share|improve this question
















I am trying to use Sphinx code blocks and I am getting strange rendering in HTML. My source is:



The following image shows both the source code used and how it was rendered in HTML



Here is the source rst for the page



************
Testing Page
************

Used for testing Sphinx constructs

Why does the role get rendered in HTML?

..code-block:: python

This is a code line
and so is this.

It is very confused because it emits the following error::
D:SharedWiseOldbirdProjectsPlatform IndependentApplicationControllerdocssourceTest.rst:12: WARNING: Block quote ends without a blank line; unexpected unindent

If I try it like this without the language specification it renders the role and displays the code block correctly -
note that it strips a single colon from the role directive

..code-block::

This is a code line
and so is this.

If I use a literal block.::

I get a colon in the text that introduces the literal block

Heading
-------


What do I need to do to use Sphinx code blocks correctly?







python-sphinx restructuredtext






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 19:30







Jonathan

















asked Jan 2 at 19:07









JonathanJonathan

976819




976819













  • Please show us code and markup as text, not as an image.

    – mzjn
    Jan 2 at 19:13











  • I have no idea how to show the markup as text on Stackoverflow

    – Jonathan
    Jan 2 at 19:18











  • I am attempting to show the rendered HTML output.

    – Jonathan
    Jan 2 at 19:24











  • Yes that's fine. But please provide RST markup as plain text.

    – mzjn
    Jan 2 at 19:26













  • A space is missing. Change ..code-block:: python to .. code-block:: python.

    – mzjn
    Jan 2 at 19:32



















  • Please show us code and markup as text, not as an image.

    – mzjn
    Jan 2 at 19:13











  • I have no idea how to show the markup as text on Stackoverflow

    – Jonathan
    Jan 2 at 19:18











  • I am attempting to show the rendered HTML output.

    – Jonathan
    Jan 2 at 19:24











  • Yes that's fine. But please provide RST markup as plain text.

    – mzjn
    Jan 2 at 19:26













  • A space is missing. Change ..code-block:: python to .. code-block:: python.

    – mzjn
    Jan 2 at 19:32

















Please show us code and markup as text, not as an image.

– mzjn
Jan 2 at 19:13





Please show us code and markup as text, not as an image.

– mzjn
Jan 2 at 19:13













I have no idea how to show the markup as text on Stackoverflow

– Jonathan
Jan 2 at 19:18





I have no idea how to show the markup as text on Stackoverflow

– Jonathan
Jan 2 at 19:18













I am attempting to show the rendered HTML output.

– Jonathan
Jan 2 at 19:24





I am attempting to show the rendered HTML output.

– Jonathan
Jan 2 at 19:24













Yes that's fine. But please provide RST markup as plain text.

– mzjn
Jan 2 at 19:26







Yes that's fine. But please provide RST markup as plain text.

– mzjn
Jan 2 at 19:26















A space is missing. Change ..code-block:: python to .. code-block:: python.

– mzjn
Jan 2 at 19:32





A space is missing. Change ..code-block:: python to .. code-block:: python.

– mzjn
Jan 2 at 19:32












1 Answer
1






active

oldest

votes


















1
















  • A space is missing in the code-block.



    Change ..code-block:: python to .. code-block:: python.




  • A code-block directive must have an argument specifying the language.



    See http://www.sphinx-doc.org/en/stable/usage/restructuredtext/directives.html#directive-code-block.




  • A space is also missing before the colons in the paragraph before the literal block.



    Change literal block.:: to literal block. :: to remove the colon in the rendered text.








share|improve this answer


























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54011861%2fsphinx-code-block-renders-strangely-in-html%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1
















    • A space is missing in the code-block.



      Change ..code-block:: python to .. code-block:: python.




    • A code-block directive must have an argument specifying the language.



      See http://www.sphinx-doc.org/en/stable/usage/restructuredtext/directives.html#directive-code-block.




    • A space is also missing before the colons in the paragraph before the literal block.



      Change literal block.:: to literal block. :: to remove the colon in the rendered text.








    share|improve this answer






























      1
















      • A space is missing in the code-block.



        Change ..code-block:: python to .. code-block:: python.




      • A code-block directive must have an argument specifying the language.



        See http://www.sphinx-doc.org/en/stable/usage/restructuredtext/directives.html#directive-code-block.




      • A space is also missing before the colons in the paragraph before the literal block.



        Change literal block.:: to literal block. :: to remove the colon in the rendered text.








      share|improve this answer




























        1












        1








        1









        • A space is missing in the code-block.



          Change ..code-block:: python to .. code-block:: python.




        • A code-block directive must have an argument specifying the language.



          See http://www.sphinx-doc.org/en/stable/usage/restructuredtext/directives.html#directive-code-block.




        • A space is also missing before the colons in the paragraph before the literal block.



          Change literal block.:: to literal block. :: to remove the colon in the rendered text.








        share|improve this answer

















        • A space is missing in the code-block.



          Change ..code-block:: python to .. code-block:: python.




        • A code-block directive must have an argument specifying the language.



          See http://www.sphinx-doc.org/en/stable/usage/restructuredtext/directives.html#directive-code-block.




        • A space is also missing before the colons in the paragraph before the literal block.



          Change literal block.:: to literal block. :: to remove the colon in the rendered text.









        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 2 at 20:01

























        answered Jan 2 at 19:52









        mzjnmzjn

        32.4k670159




        32.4k670159
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54011861%2fsphinx-code-block-renders-strangely-in-html%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            Npm cannot find a required file even through it is in the searched directory