Пример #1
0
def test_numbering_latex():
    verify_conversion(
        '''
Exercise (Equation $a=b$) #
        ''', '''
\\phantomsection\\addcontentsline{exercise}{exercise}{\\protect\\numberline {1}{\\ignorespaces {Equation \(a=b\)}}}[\\label{exercise:1}**Exercise 1** *(Equation $a=b$)*]{#exercise:1 .pandoc-numbering-text .exercise}
        ''', 'latex')
Пример #2
0
    def test_numbering_text(self):
        verify_conversion(
            self,
            r"""
---
pandoc-numbering:
  exercise:
    standard:
      format-text-classic: '**%D %d %n/%c**'
      format-text-title: '**%D %d %n/%c: %T %t**'
---

Exercise #

Exercise (Title) #
            """,
            r"""
---
pandoc-numbering:
  exercise:
    standard:
      format-text-classic: "**%D %d %n/%c**"
      format-text-title: "**%D %d %n/%c: %T %t**"
---

[]{#exercise:1}[**Exercise exercise 1/2**]{#exercise:1 .pandoc-numbering-text .exercise}

[]{#exercise:title}[**Exercise exercise 2/2: Title title**]{#exercise:2 .pandoc-numbering-text .exercise}
            """,
        )
Пример #3
0
    def test_numbering_classes(self):
        verify_conversion(
            self,
            r"""
---
pandoc-numbering:
  exercise:
    general:
      classes:
      - myclass
---

Exercise #

Exercise (Title) #
            """,
            r"""
---
pandoc-numbering:
  exercise:
    general:
      classes:
      - myclass
---

[]{#exercise:1}[**Exercise 1**]{#exercise:1 .pandoc-numbering-text .myclass}

[]{#exercise:title}[**Exercise 2** *(Title)*]{#exercise:2 .pandoc-numbering-text .myclass}
            """,
        )
Пример #4
0
def test_numbering_classes():
    verify_conversion(
        '''
---
pandoc-numbering:
  exercise:
    general:
      classes:
      - myclass
---

Exercise #

Exercise (Title) #
        ''', '''
---
pandoc-numbering:
  exercise:
    general:
      classes:
      - myclass
---

[**Exercise 1**]{#exercise:1 .pandoc-numbering-text .myclass}

[**Exercise 2** *(Title)*]{#exercise:2 .pandoc-numbering-text .myclass}
        ''')
Пример #5
0
def test_listing_classic():
    verify_conversion(
        '''
---
pandoc-numbering:
  exercise:
    general:
      listing-title: List of exercises
---

Exercise #

Exercise (Title) #
        ''',
        '''
---
pandoc-numbering:
  exercise:
    general:
      listing-title: List of exercises
---

List of exercises {.pandoc-numbering-listing .exercise .unnumbered .unlisted}
=================

-   [[Exercise 1]{.pandoc-numbering-entry .exercise}](#exercise:1)
-   [[Title]{.pandoc-numbering-entry .exercise}](#exercise:2)

[**Exercise 1**]{#exercise:1 .pandoc-numbering-text .exercise}

[**Exercise 2** *(Title)*]{#exercise:2 .pandoc-numbering-text .exercise}
        '''
    )
Пример #6
0
def test_numbering_text():
    verify_conversion(
        '''
---
pandoc-numbering:
  exercise:
    standard:
      format-text-classic: '**%D %d %n/%c**'
      format-text-title: '**%D %d %n/%c: %T %t**'
---

Exercise #

Exercise (Title) #
        ''', '''
---
pandoc-numbering:
  exercise:
    standard:
      format-text-classic: '**%D %d %n/%c**'
      format-text-title: '**%D %d %n/%c: %T %t**'
---

[**Exercise exercise 1/2**]{#exercise:1 .pandoc-numbering-text .exercise}

[**Exercise exercise 2/2: Title title**]{#exercise:2 .pandoc-numbering-text .exercise}
        ''')
Пример #7
0
def test_meta_multiple():
    verify_conversion(
        '''
---
pandoc-latex-unlisted: [[myclass1, myclass2]]
---

Header {.myclass1 .myclass2}
======
        ''', '''
---
header-includes:
- '\\let\\oldaddcontentsline\\addcontentsline'
pandoc-latex-unlisted:
- - myclass1
  - myclass2
---

\\let\\oldaddcontentsline\\addcontentsline

\\renewcommand{\\addcontentsline}[3]{}
Header {#header .myclass1 .myclass2}
======

\\renewcommand{\\addcontentsline}[3]{\\oldaddcontentsline{#1}{#2}{#3}}
        ''', 'latex')
Пример #8
0
def test_listing_latex():
    verify_conversion(
        '''
---
pandoc-numbering:
  exercise:
    general:
      listing-title: List of exercises
---

Exercise #

Exercise (Title) #
        ''',
        '''
---
pandoc-numbering:
  exercise:
    general:
      listing-title: List of exercises
---

List of exercises {.pandoc-numbering-listing .exercise .unnumbered .unlisted}
=================

\\hypersetup{linkcolor=black}\\makeatletter\\newcommand*\\l@exercise{\\@dottedtocline{1}{1.5em}{2.3em}}\\@starttoc{exercise}\\makeatother
\\phantomsection\\addcontentsline{exercise}{exercise}{\\protect\\numberline {1}{\\ignorespaces {Exercise}}}[\\label{exercise:1}**Exercise 1**]{#exercise:1 .pandoc-numbering-text .exercise}

\\phantomsection\\addcontentsline{exercise}{exercise}{\\protect\\numberline {2}{\\ignorespaces {Title}}}[\\label{exercise:2}**Exercise 2** *(Title)*]{#exercise:2 .pandoc-numbering-text .exercise}
        ''',
        'latex'
    )
Пример #9
0
def test_header_includes1():
    verify_conversion(
        '''
---
header-includes: \\usepackage{fancyhdr}
---
Header {.unlisted}
======
        ''', '''
---
header-includes:
- '\\usepackage{fancyhdr}'
- '\\let\\oldaddcontentsline\\addcontentsline'
---

\\usepackage{fancyhdr}

\\let\\oldaddcontentsline\\addcontentsline

\\renewcommand{\\addcontentsline}[3]{}
Header {#header .unlisted}
======

\\renewcommand{\\addcontentsline}[3]{\\oldaddcontentsline{#1}{#2}{#3}}
        ''', 'latex')
    def test_referencing_standard(self):
        verify_conversion(
            self,
            r"""
Header
======

Section
-------

Exercise (First title) -.+.#exercise:first

Exercise (Second title) -.+.#exercise:second

See [%D %d %T %t %g %s %n # %c](#exercise:first)

See [%D %d %T %t %g %s %n # %c](#exercise:second)
            """,
            r"""
Header
======

Section
-------

[**Exercise 1.1** *(First title)*]{#exercise:first .pandoc-numbering-text .exercise}

[**Exercise 1.2** *(Second title)*]{#exercise:second .pandoc-numbering-text .exercise}

See [Exercise exercise First title first title 1.1.1 1.1 1.1 1.1 2](#exercise:first)

See [Exercise exercise Second title second title 1.1.2 1.1 1.2 1.2 2](#exercise:second)
            """,
        )
Пример #11
0
    def test_para_sectioning(self):
        verify_conversion(
            self,
            r"""
First chapter
=============

Second chapter
==============

First section
-------------

Second section
--------------

Exercise -.+.#
            """,
            r"""
First chapter
=============

Second chapter
==============

First section
-------------

Second section
--------------

[**Exercise 2.1**]{#exercise:2.2.1 .pandoc-numbering-text .exercise}
            """,
        )
Пример #12
0
    def test_listing_classic(self):
        verify_conversion(
            self,
            r"""
---
pandoc-numbering:
  exercise:
    general:
      listing-title: List of exercises
---

Exercise #

Exercise (Title) #
            """,
            r"""
---
pandoc-numbering:
  exercise:
    general:
      listing-title: List of exercises
---

# List of exercises {#list-of-exercises .pandoc-numbering-listing .exercise .unnumbered .unlisted}

-   [[Exercise 1]{.pandoc-numbering-entry .exercise}](#exercise:1)
-   [[Title]{.pandoc-numbering-entry .exercise}](#exercise:2)

[]{#exercise:1}[**Exercise 1**]{#exercise:1 .pandoc-numbering-text .exercise}

[]{#exercise:title}[**Exercise 2** *(Title)*]{#exercise:2 .pandoc-numbering-text .exercise}
            """,
        )
Пример #13
0
    def test_listing_identifier_false(self):
        verify_conversion(
            self,
            r"""
---
pandoc-numbering:
  exercise:
    general:
      listing-identifier: False
      listing-title: List of exercises
---

Exercise #

Exercise (Title) #
            """,
            r"""
---
pandoc-numbering:
  exercise:
    general:
      listing-title: List of exercises
---

List of exercises {.pandoc-numbering-listing .exercise .unnumbered .unlisted}
=================

-   [[Exercise 1]{.pandoc-numbering-entry .exercise}](#exercise:1)
-   [[Title]{.pandoc-numbering-entry .exercise}](#exercise:2)

[**Exercise 1**]{#exercise:1 .pandoc-numbering-text .exercise}

[**Exercise 2** *(Title)*]{#exercise:2 .pandoc-numbering-text .exercise}
            """,
        )
Пример #14
0
def test_para_numbering_hidden():
    verify_conversion(
        '''
First chapter
=============

Exercise -.#exercise:one

Exercise -.#

Second chapter
==============

Exercise -.#

Exercise -.#

Exercice #
        ''', '''
First chapter
=============

[**Exercise 1**]{#exercise:one .pandoc-numbering-text .exercise}

[**Exercise 2**]{#exercise:1.2 .pandoc-numbering-text .exercise}

Second chapter
==============

[**Exercise 1**]{#exercise:2.1 .pandoc-numbering-text .exercise}

[**Exercise 2**]{#exercise:2.2 .pandoc-numbering-text .exercise}

[**Exercice 1**]{#exercice:1 .pandoc-numbering-text .exercice}
        ''')
Пример #15
0
def test_para_sectioning():
    verify_conversion(
        '''
First chapter
=============

Second chapter
==============

First section
-------------

Second section
--------------

Exercise -.+.#
        ''', '''
First chapter
=============

Second chapter
==============

First section
-------------

Second section
--------------

[**Exercise 2.1**]{#exercise:2.2.1 .pandoc-numbering-text .exercise}
        ''')
Пример #16
0
def test_referencing_latex():
    verify_conversion(
        '''
Title
=====

Exercise -.#first

Exercise (Title) -.#second

See [%D %d %T %t %g %s %n # %c %p](#exercise:first)

See [%D %d %T %t %g %s %n # %c %p](#exercise:second)
        ''', '''
Title
=====

\\phantomsection\\addcontentsline{exercise}{exercise}{\\protect\\numberline {1.1}{\\ignorespaces {Exercise}}}[\\label{exercise:first}**Exercise 1**]{#exercise:first .pandoc-numbering-text .exercise}

\\phantomsection\\addcontentsline{exercise}{exercise}{\\protect\\numberline {1.2}{\\ignorespaces {Title}}}[\\label{exercise:second}**Exercise 2** *(Title)*]{#exercise:second .pandoc-numbering-text .exercise}

See [Exercise exercise 1.1 1 1 1 2 \pageref{exercise:first}](#exercise:first)

See [Exercise exercise Title title 1.2 1 2 2 2 \pageref{exercise:second}](#exercise:second)
        ''', 'latex')
    def test_referencing_link_latex(self):
        verify_conversion(
            self,
            r"""
---
pandoc-numbering:
  exercise:
    general:
      cite-shortcut: True
    latex:
      format-link-classic: '**%D %d %g %s %n %p**'
      format-link-title: '**%D %d %T %t %g %s %n %p**'
---

Title
=====

Exercise -.#first

Exercise (Title) -.#second

See @exercise:first

See @exercise:second
            """,
            r"""
---
header-includes:
- '`\usepackage{tocloft}`{=tex}'
- '`\ifdef{\mainmatter}{\let\oldmainmatter\mainmatter\renewcommand{\mainmatter}[0]{\oldmainmatter}}{}`{=tex}'
pandoc-numbering:
  exercise:
    general:
      cite-shortcut: true
    latex:
      format-link-classic: '**%D %d %g %s %n %p**'
      format-link-title: '**%D %d %T %t %g %s %n %p**'
---

`\usepackage{tocloft}`{=tex}

`\ifdef{\mainmatter}{\let\oldmainmatter\mainmatter\renewcommand{\mainmatter}[0]{\oldmainmatter}}{}`{=tex}

```{=tex}
\ifdef{\mainmatter}{}{}
```
Title
=====

`\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {1.1}{\ignorespaces {Exercise}}}`{=tex}[`\label{exercise:first}`{=tex}**Exercise 1**]{#exercise:first .pandoc-numbering-text .exercise}

`\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {1.2}{\ignorespaces {Title}}}`{=tex}[`\label{exercise:second}`{=tex}**Exercise 2** *(Title)*]{#exercise:second .pandoc-numbering-text .exercise}

See [[**Exercise exercise 1.1 1 1 `\pageref{exercise:first}`{=tex}**]{.pandoc-numbering-link .exercise}](#exercise:first "Exercise 1")

See [[**Exercise exercise Title title 1.2 1 2 `\pageref{exercise:second}`{=tex}**]{.pandoc-numbering-link .exercise}](#exercise:second "Exercise 2 (Title)")
            """,
            "latex",
        )
Пример #18
0
def test_term_title():
    verify_conversion(
        '''
Definition (This is the title) #
:   This is the definition
''', '''
[**Definition 1** *(This is the title)*]{#definition:1 .pandoc-numbering-text .definition}
:   This is the definition
''')
Пример #19
0
def test_term():
    verify_conversion(
        '''
Definition #
:   This is the definition
''', '''
[**Definition 1**]{#definition:1 .pandoc-numbering-text .definition}
:   This is the definition
''')
Пример #20
0
    def test_listing_latex_format(self):
        verify_conversion(
            self,
            r"""
---
pandoc-numbering:
  exercise:
    general:
      listing-title: List of exercises
    latex:
      entry-space: 3
      entry-tab: 2
      format-entry-classic: '%D'
      format-entry-title: '%D (%T)'
toccolor: blue
---

Exercise #

Exercise (Title) #
            """,
            r"""
---
header-includes:
- "`\\usepackage{tocloft}`{=tex}"
- "`\\usepackage{etoolbox}`{=tex}"
- "`\\newlistof{exercise}{exercise}{List of exercises}\\renewcommand{\\cftexercisetitlefont}{\\cfttoctitlefont}\\setlength{\\cftexercisenumwidth}{\\cftfignumwidth}\\setlength{\\cftexerciseindent}{\\cftfigindent}`{=tex}"
- "`\\ifdef{\\mainmatter}{\\let\\oldmainmatter\\mainmatter\\renewcommand{\\mainmatter}[0]{\\listofexercise\\oldmainmatter}}{}`{=tex}"
pandoc-numbering:
  exercise:
    general:
      listing-title: List of exercises
    latex:
      entry-space: 3
      entry-tab: 2
      format-entry-classic: "%D"
      format-entry-title: %D (%T)
toccolor: blue
---

`\usepackage{tocloft}`{=tex}

`\usepackage{etoolbox}`{=tex}

`\newlistof{exercise}{exercise}{List of exercises}\renewcommand{\cftexercisetitlefont}{\cfttoctitlefont}\setlength{\cftexercisenumwidth}{\cftfignumwidth}\setlength{\cftexerciseindent}{\cftfigindent}`{=tex}

`\ifdef{\mainmatter}{\let\oldmainmatter\mainmatter\renewcommand{\mainmatter}[0]{\listofexercise\oldmainmatter}}{}`{=tex}

```{=tex}
\ifdef{\mainmatter}{}{\listofexercise}
```
`\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {1}{\ignorespaces {Exercise}}}`{=tex}[]{#exercise:1}[`\label{exercise:1}`{=tex}`\label{exercise:1}`{=tex}**Exercise 1**]{#exercise:1 .pandoc-numbering-text .exercise}

`\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {2}{\ignorespaces {Exercise (Title)}}}`{=tex}[]{#exercise:title}[`\label{exercise:2}`{=tex}`\label{exercise:title}`{=tex}**Exercise 2** *(Title)*]{#exercise:2 .pandoc-numbering-text .exercise}
            """,
            "latex",
        )
Пример #21
0
def test_para_double():
    verify_conversion(
        '''
Example #

Example #
        ''', '''
[**Example 1**]{#example:1 .pandoc-numbering-text .example}

[**Example 2**]{#example:2 .pandoc-numbering-text .example}
        ''')
Пример #22
0
def test_para_title():
    verify_conversion(
        '''
Example (This is the first title) #

Example (This is the second title) #
        ''', '''
[**Example 1** *(This is the first title)*]{#example:1 .pandoc-numbering-text .example}

[**Example 2** *(This is the second title)*]{#example:2 .pandoc-numbering-text .example}
        ''')
    def test_numbering_levels(self):
        verify_conversion(
            self,
            r"""
---
pandoc-numbering: 
  exercise:
    general:
      first-section-level: 2
      last-section-level: 2
---

First chapter
=============

Second chapter
==============

First section
-------------

Second section
--------------

Exercise #

Exercise (Title) #
            """,
            r"""
---
pandoc-numbering:
  exercise:
    general:
      first-section-level: 2
      last-section-level: 2
---

First chapter
=============

Second chapter
==============

First section
-------------

Second section
--------------

[**Exercise 2.1**]{#exercise:2.2.1 .pandoc-numbering-text .exercise}

[**Exercise 2.2** *(Title)*]{#exercise:2.2.2 .pandoc-numbering-text .exercise}
            """,
        )
def test_include_end_at():
    verify_conversion(
        '''
``` {include="tests/lorem" endAt="2"}
```
        ''', '''
``` {include="tests/lorem" endAt="2"}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Duis pretium rutrum dignissim.
```
        ''')
Пример #25
0
    def test_term_title(self):
        verify_conversion(
            self,
            r"""
Definition (This is the title) #
:   This is the definition
            """,
            r"""
[]{#definition:this-is-the-title}[**Definition 1** *(This is the title)*]{#definition:1 .pandoc-numbering-text .definition}
:   This is the definition
            """,
        )
Пример #26
0
    def test_term(self):
        verify_conversion(
            self,
            r"""
Definition #
:   This is the definition
            """,
            r"""
[]{#definition:1}[**Definition 1**]{#definition:1 .pandoc-numbering-text .definition}
:   This is the definition
            """,
        )
Пример #27
0
def test_newpage():
    verify_conversion('''
Example

-------------

Example
        ''', '''
Example

\\cleardoublepage
Example
        ''', 'latex')
def test_include_start_from():
    verify_conversion(
        '''
``` {include="tests/lorem" startFrom="2"}
```
        ''', '''
``` {include="tests/lorem" startFrom="2"}
Duis pretium rutrum dignissim.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Interdum et malesuada fames ac ante ipsum primis in faucibus.
Ut iaculis arcu sed dui ornare pretium.
```
        ''')
Пример #29
0
def test_para_sectioning_unnumbered():
    verify_conversion(
        '''
Unnumbered chapter {#unnumbered-chapter .unnumbered}
==================

Exercise +.#
        ''', '''
Unnumbered chapter {#unnumbered-chapter .unnumbered}
==================

[**Exercise 0.1**]{#exercise:0.1 .pandoc-numbering-text .exercise}
        ''')
def test_include():
    verify_conversion(
        '''
``` {include="tests/lorem"}
```
        ''', '''
``` {include="tests/lorem"}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Duis pretium rutrum dignissim.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Interdum et malesuada fames ac ante ipsum primis in faucibus.
Ut iaculis arcu sed dui ornare pretium.
```
        ''')