<commit_before># -*- coding: utf-8 -*-
from testfixtures import compare
from nbformat.v4.nbbase import new_notebook, new_markdown_cell
from jupytext.compare import compare_notebooks
import jupytext
from .utils import requires_pandoc


@requires_pandoc
def test_pandoc_implicit(markdown='''# Lorem ipsum

**Lorem ipsum** dolor sit amet, consectetur adipiscing elit. Nunc luctus
bibendum felis dictum sodales.

``` code
print("hello")
```
'''):
    nb = jupytext.reads(markdown, 'md:pandoc')
    markdown2 = jupytext.writes(nb, 'md')

    nb2 = jupytext.reads(markdown2, 'md')
    compare_notebooks(nb, nb2)

    markdown3 = jupytext.writes(nb2, 'md')
    compare(markdown2, markdown3)


@requires_pandoc
def test_pandoc_explicit(markdown='''::: {.cell .markdown}
# Lorem

**Lorem ipsum** dolor sit amet, consectetur adipiscing elit. Nunc luctus
bibendum felis dictum sodales.
:::'''):
    nb = jupytext.reads(markdown, 'md')

    markdown2 = jupytext.writes(nb, 'md')
    compare(markdown, '\n'.join(markdown2.splitlines()[12:]))


@requires_pandoc
def test_pandoc_utf8_in_md(markdown='''::: {.cell .markdown}
# Utf-8 support

This is the greek letter $\pi$: π
:::'''):
    nb = jupytext.reads(markdown, 'md')

    markdown2 = jupytext.writes(nb, 'md')
    compare(markdown, '\n'.join(markdown2.splitlines()[12:]))


@requires_pandoc
def test_pandoc_utf8_in_nb(nb=new_notebook(cells=[new_markdown_cell('''# Utf-8 support

This is the greek letter $\pi$: π''')])):
    markdown = jupytext.writes(nb, 'md:pandoc')
    nb2 = jupytext.reads(markdown, 'md:pandoc')
    nb2.metadata.pop('jupytext')
    compare_notebooks(nb2, nb, 'md:pandoc')<commit_msg>Python-latex repr for pi is $\\pi$<commit_after># -*- coding: utf-8 -*-
from testfixtures import compare
from nbformat.v4.nbbase import new_notebook, new_markdown_cell
from jupytext.compare import compare_notebooks
import jupytext
from .utils import requires_pandoc


@requires_pandoc
def test_pandoc_implicit(markdown='''# Lorem ipsum

**Lorem ipsum** dolor sit amet, consectetur adipiscing elit. Nunc luctus
bibendum felis dictum sodales.

``` code
print("hello")
```
'''):
    nb = jupytext.reads(markdown, 'md:pandoc')
    markdown2 = jupytext.writes(nb, 'md')

    nb2 = jupytext.reads(markdown2, 'md')
    compare_notebooks(nb, nb2)

    markdown3 = jupytext.writes(nb2, 'md')
    compare(markdown2, markdown3)


@requires_pandoc
def test_pandoc_explicit(markdown='''::: {.cell .markdown}
# Lorem

**Lorem ipsum** dolor sit amet, consectetur adipiscing elit. Nunc luctus
bibendum felis dictum sodales.
:::'''):
    nb = jupytext.reads(markdown, 'md')

    markdown2 = jupytext.writes(nb, 'md')
    compare(markdown, '\n'.join(markdown2.splitlines()[12:]))


@requires_pandoc
def test_pandoc_utf8_in_md(markdown='''::: {.cell .markdown}
# Utf-8 support

This is the greek letter $\\pi$: π
:::'''):
    nb = jupytext.reads(markdown, 'md')

    markdown2 = jupytext.writes(nb, 'md')
    compare(markdown, '\n'.join(markdown2.splitlines()[12:]))


@requires_pandoc
def test_pandoc_utf8_in_nb(nb=new_notebook(cells=[new_markdown_cell('''# Utf-8 support

This is the greek letter $\\pi$: π''')])):
    markdown = jupytext.writes(nb, 'md:pandoc')
    nb2 = jupytext.reads(markdown, 'md:pandoc')
    nb2.metadata.pop('jupytext')
    compare_notebooks(nb2, nb, 'md:pandoc')
{'fraction_non_alphanumeric': 0.1516430509496533, 'fraction_numerical': 0.015073861923424782, 'mean_word_length': 5.043715846994536, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4802080', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1293, 'n_words': 266}