<jupyter_start><jupyter_text>Alternating text and codeSphinx-Gallery is capable of transforming Python files into rST fileswith a notebook structure. For this to be used you need to respect some syntaxrules. This example demonstrates how to alternate text and code blocks and someedge cases. It was designed to be compared with the:download:`source Python script `. This is the first text block and directly follows the header docstring above.<jupyter_code>import numpy as np
# You can separate code blocks using either a single line of ``#``'s
# (>=20 columns), ``#%%``, or ``# %%``. For consistency, it is recommend that
# you use only one of the above three 'block splitter' options in your project.
A = 1

import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Block splitters allow you alternate between code and text blocks **and**separate sequential blocks of code (above) and text (below). A line of ````'s also works for separating blocks. The above line of ````'sseparates the text block above from this text block. Notice however, thatseparated text blocks only shows as a new lines between text, in the renderedoutput.<jupyter_code>def dummy():
    """This should not be part of a 'text' block'"""

    # %%
    # This comment inside a code block will remain in the code block
    pass

# this line should not be part of a 'text' block<jupyter_output><empty_output><jupyter_text>The above syntax makes a line cut in Sphinx. Note the space between the first```` and the line of ````'s. WarningThe next kind of comments are not supported (notice the line of ````'s    and the `` %%`` start at the margin instead of being indented like    above) and become too hard to escape so just don't use code like this::        def dummy2():            """Function docstring"""                 This comment         %%         and this comment inside python indentation         breaks the block structure and is not         supported            dummy2<jupyter_code>"""Free strings are not supported. They will be rendered as a code block"""<jupyter_output><empty_output><jupyter_text>New lines can be included in your text block and the parseris capable of retaining this important whitespace to work with Sphinx.Everything after a block splitter and starting with ```` then one space,is interpreted by Sphinx-Gallery to be a rST text block. Keep your textblock together using ```` and a space at the beginning of each line. rST header within text block<jupyter_code>print('one')
# another way to separate code blocks shown above
B = 1<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07239643825009678, 'fraction_numerical': 0.0023228803716608595, 'mean_word_length': 4.209677419354839, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '351615', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 674, 'n_tokens_neox': 654, 'n_words': 355, 'path': 'resources/plot_parse.ipynb', 'repo_name': 'sharkevolution/requirements', 'size': '2583'}