From 435017e1bcc2cf8bc5243de20ce8f098414dde04 Mon Sep 17 00:00:00 2001 From: Leo Torres Date: Thu, 9 May 2024 20:42:09 +0200 Subject: [PATCH 01/11] silence annoying warning from pyfs --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 2e984a1..1895bbd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -88,6 +88,9 @@ markers = [ 'slow: marks tests as slow (deselect with "-m \"not slow\"")', "serial", ] +filterwarnings = [ + "ignore:.*pkg_resources.*:DeprecationWarning", +] # Poe the poet From 8378a10c4b882ffcc2ab2ba4f4c45458bd377881 Mon Sep 17 00:00:00 2001 From: Leo Torres Date: Thu, 9 May 2024 20:42:34 +0200 Subject: [PATCH 02/11] make the --watch flag also execute once at first --- rsm/cli.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rsm/cli.py b/rsm/cli.py index 6f2a8da..f3a68df 100644 --- a/rsm/cli.py +++ b/rsm/cli.py @@ -127,6 +127,7 @@ def make() -> int: cmd = " ".join(other_args) server = livereload.Server() server.watch(args.src, livereload.shell(cmd)) + main(parser, app.make, args) server.serve(root=".") else: main(parser, app.make, args) From c1255b9c45c2e76f7764af25a8c62f65cb9db523 Mon Sep 17 00:00:00 2001 From: Leo Torres Date: Thu, 9 May 2024 20:46:04 +0200 Subject: [PATCH 03/11] update tests --- tests/conftest.py | 2 +- tests/test_abstract.py | 14 +- tests/test_algorithm.py | 4 +- tests/test_appendix.py | 36 ++-- tests/test_author.py | 10 +- tests/test_autonumber.py | 24 +-- tests/test_bibliography.py | 36 ++-- tests/test_claim.py | 24 +-- tests/test_code.py | 96 ++++----- tests/test_comments.py | 16 +- tests/test_construct.py | 393 ++++++++++++++++++------------------ tests/test_escapedstring.py | 24 +-- tests/test_figure.py | 10 +- tests/test_handrails.py | 226 ++++++++++----------- tests/test_lists.py | 24 +-- tests/test_math.py | 56 ++--- tests/test_meta.py | 36 ++-- tests/test_paragraph.py | 28 +-- tests/test_previous.py | 64 +++--- tests/test_proof.py | 60 +++--- tests/test_references.py | 20 +- tests/test_reftext.py | 6 +- tests/test_regions.py | 18 +- tests/test_render.py | 8 +- tests/test_section.py | 20 +- tests/test_shortcuts.py | 194 +++++++++--------- tests/test_simple.py | 18 +- tests/test_sketch.py | 28 +-- tests/test_span.py | 28 +-- tests/test_table.py | 351 ++++++++++++++++---------------- tests/test_theorem.py | 26 +-- tests/test_transformer.py | 58 +++--- tests/test_url.py | 16 +- tests/test_whitespace.py | 130 ++++++------ 34 files changed, 1052 insertions(+), 1052 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index a14a49c..13be7cd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -23,7 +23,7 @@
-
+
diff --git a/tests/test_abstract.py b/tests/test_abstract.py index 480a9c2..f216d96 100644 --- a/tests/test_abstract.py +++ b/tests/test_abstract.py @@ -44,13 +44,13 @@ def test_simple():
-
+

The Perron non-backtracking eigenvalue after node addition

-
+

Leo Torres

@@ -60,13 +60,13 @@ def test_simple():
-
+

Abstract

-

first second third

+

first second third

-

fourth fifth

+

fourth fifth

Keywords: spectral graph theory, non-backtracking, interlacing

@@ -74,11 +74,11 @@ def test_simple():
-
+

1. Introduction

-

Lorem ipsum.

+

Lorem ipsum.

diff --git a/tests/test_algorithm.py b/tests/test_algorithm.py index 661302b..60d0be9 100644 --- a/tests/test_algorithm.py +++ b/tests/test_algorithm.py @@ -40,7 +40,7 @@ def test_real_life_example():
-
+
@@ -107,7 +107,7 @@ def test_label():
-
+
diff --git a/tests/test_appendix.py b/tests/test_appendix.py index fe03074..54d2687 100644 --- a/tests/test_appendix.py +++ b/tests/test_appendix.py @@ -21,17 +21,17 @@ def test_simple():
-
+
-
+

1. Foo

-
+

A. Bar

@@ -72,15 +72,15 @@ def test_subsection():
-
+
-
+

1. Foo

-
+

1.1. Sub Foo

@@ -88,11 +88,11 @@ def test_subsection():
-
+

A. Bar

-
+

A.1. Sub Bar

@@ -140,19 +140,19 @@ def test_theorem():
-
+
-
+

1. Foo

-
+

1.1. Sub Foo

-
+
@@ -166,15 +166,15 @@ def test_theorem():
-
+

A. Bar

-
+

A.1. Sub Bar

-
+
@@ -219,13 +219,13 @@ def test_section_reftext():
-
+
-

Appendix A

+

Appendix A

-
+

A. Foo bar

diff --git a/tests/test_author.py b/tests/test_author.py index 6eaadb2..d5b45db 100644 --- a/tests/test_author.py +++ b/tests/test_author.py @@ -22,13 +22,13 @@ def test_simple():
-
+

My Title

-
+

Leo Torres

@@ -68,17 +68,17 @@ def test_empty_author():
-
+

The Perron non-backtracking eigenvalue after node addition

-
+
-

Lorem ipsum.

+

Lorem ipsum.

diff --git a/tests/test_autonumber.py b/tests/test_autonumber.py index bec361b..4a418ba 100644 --- a/tests/test_autonumber.py +++ b/tests/test_autonumber.py @@ -29,23 +29,23 @@ def test_numbered_sections():
-
+
-
+

1. First

-

Content of first.

+

Content of first.

-
+

2. Second

-

Content of second.

+

Content of second.

@@ -94,31 +94,31 @@ def test_nonum():
-
+
-
+

1. First

-

Content of first.

+

Content of first.

-
+

Second

-

Content of second.

+

Content of second.

-
+

2. Third

-

Content of third.

+

Content of third.

diff --git a/tests/test_bibliography.py b/tests/test_bibliography.py index 233123b..1d0632c 100644 --- a/tests/test_bibliography.py +++ b/tests/test_bibliography.py @@ -31,21 +31,21 @@ def test_single():
-
+

My Title

-

This has a citation at the end. [1]

+

This has a citation at the end. [1]

References

-
    +
      -
    1. +
    2. Knuth, Donald E. "Art of computer programming, volume 2, Seminumerical algorithms". Addison-Wesley Professional. 2014.
      [^1]
    3. @@ -93,21 +93,21 @@ def test_with_shortcuts():
      -
      +

      My Title

      -

      This has a citation at the end. [1]

      +

      This has a citation at the end. [1]

      References

      -
        +
          -
        1. +
        2. Knuth, Donald E. "Art of computer programming, volume 2: Seminumerical algorithms". Addison-Wesley Professional. 2014.
          [^1]
        3. @@ -164,25 +164,25 @@ def test_many():
          -
          +

          My Title

          -

          This has a citation at the end. [1, 2]

          +

          This has a citation at the end. [1, 2]

          References

          -
            +
              -
            1. +
            2. Torres, Leo and Chan, Kevin S and Tong, Hanghang and Eliassi-Rad, Tina. "Nonbacktracking eigenvalues under node removal: X-centrality and targeted immunization". SIAM Journal on Mathematics of Data Science. 2021.
              [^1]
            3. -
            4. +
            5. Knuth, Donald E. "Art of computer programming, volume 2: Seminumerical algorithms". Addison-Wesley Professional. 2014.
              [^1]
            6. @@ -239,25 +239,25 @@ def test_order():
              -
              +

              My Title

              -

              This has a citation at the end. [2, 1]

              +

              This has a citation at the end. [2, 1]

              References

              -
                +
                  -
                1. +
                2. Torres, Leo and Chan, Kevin S and Tong, Hanghang and Eliassi-Rad, Tina. "Nonbacktracking eigenvalues under node removal: X-centrality and targeted immunization". SIAM Journal on Mathematics of Data Science. 2021.
                  [^1]
                3. -
                4. +
                5. Knuth, Donald E. "Art of computer programming, volume 2: Seminumerical algorithms". Addison-Wesley Professional. 2014.
                  [^1]
                6. diff --git a/tests/test_claim.py b/tests/test_claim.py index 1961d4a..bd15753 100644 --- a/tests/test_claim.py +++ b/tests/test_claim.py @@ -20,15 +20,15 @@ def test_simple():
                  -
                  +
                  -
                  +

                  1. Section

                  -

                  This paragraph contains a claim all \(X\) are \(Y\).

                  +

                  This paragraph contains a claim all \(X\) are \(Y\).

                  @@ -57,11 +57,11 @@ def test_with_math():
                  -
                  +
                  -

                  This paragraph has math inside a claim \(2+2=4\).

                  +

                  This paragraph has math inside a claim \(2+2=4\).

                  @@ -95,20 +95,20 @@ def test_claim_within_list():
                  -
                  +
                  -

                  We now make a bunch of claims.

                  +

                  We now make a bunch of claims.

                  -
                    +
                      -
                    1. - \(2+2=4\). +
                    2. + \(2+2=4\).
                    3. -
                    4. - \(3+3=6\). +
                    5. + \(3+3=6\).
                    diff --git a/tests/test_code.py b/tests/test_code.py index 738e953..3f6bbbf 100644 --- a/tests/test_code.py +++ b/tests/test_code.py @@ -15,12 +15,12 @@ def test_code():
                    -
                    +
                    -

                    - comp = [abs(x) for x in range(10)] +

                    + comp = [abs(x) for x in range(10)]

                    @@ -48,12 +48,12 @@ def test_code_with_shorthand():
                    -
                    +
                    -

                    - comp = [abs(x) for x in range(10)] +

                    + comp = [abs(x) for x in range(10)]

                    @@ -83,12 +83,12 @@ def test_code_with_lang():
                    -
                    +
                    -

                    - comp = [abs(x) for x in range(10)] +

                    + comp = [abs(x) for x in range(10)]

                    @@ -117,12 +117,12 @@ def test_code_with_shorthand_and_lang():
                    -
                    +
                    -

                    - comp = [abs(x) for x in range(10)] +

                    + comp = [abs(x) for x in range(10)]

                    @@ -155,11 +155,11 @@ def test_codeblock():
                    -
                    +
                    -
                    +
                             comp = [abs(x) for x in range(10)]
                    @@ -197,11 +197,11 @@ def test_codeblock_with_lang():
                     
                             
                    -
                    +
                    -
                    +
                             comp = [abs(x) for x in range(10)]
                    @@ -237,11 +237,11 @@ def test_codeblock_with_shorthand():
                     
                             
                    -
                    +
                    -
                    +
                             comp = [abs(x) for x in range(10)]
                    @@ -279,11 +279,11 @@ def test_codeblock_with_shorthand_and_lang():
                     
                             
                    -
                    +
                    -
                    +
                             comp = [abs(x) for x in range(10)]
                    @@ -329,19 +329,19 @@ def test_meta():
                     
                             
                    -
                    +
                    -

                    - k=v +

                    + k=v

                    -

                    - k=v +

                    + k=v

                    -
                    +
                             k = v
                    @@ -349,7 +349,7 @@ def test_meta():
                     
                             
                    -
                    +
                             k = v
                    @@ -396,21 +396,21 @@ def test_meta_and_lang():
                     
                             
                    -
                    +
                    -

                    - k=v +

                    + k=v

                    -

                    - k=v +

                    + k=v

                    -
                    +
                             k = v
                    @@ -419,7 +419,7 @@ def test_meta_and_lang():
                     
                             
                    -
                    +
                             k = v
                    @@ -458,11 +458,11 @@ def test_multiline_codeblock():
                     
                             
                    -
                    +
                    -
                    +
                             import sys
                    @@ -502,11 +502,11 @@ def test_multiline_codeblock_with_lang():
                     
                             
                    -
                    +
                    -
                    +
                             import sys
                    @@ -544,11 +544,11 @@ def test_multiline_codeblock_with_shorthand():
                     
                             
                    -
                    +
                    -
                    +
                             import sys
                    @@ -588,11 +588,11 @@ def test_multiline_codeblock_with_shorthand_and_lang():
                     
                             
                    -
                    +
                    -
                    +
                             import sys
                    @@ -637,11 +637,11 @@ def test_multiline_meta():
                     
                             
                    -
                    +
                    -
                    +
                             k = v
                    @@ -650,7 +650,7 @@ def test_multiline_meta():
                     
                             
                    -
                    +
                             k = v
                    @@ -702,11 +702,11 @@ def test_multiline_meta_and_lang():
                     
                             
                    -
                    +
                    -
                    +
                             (defun forall (list func)
                    @@ -719,7 +719,7 @@ def test_multiline_meta_and_lang():
                     
                             
                    -
                    +
                             (defun forall (list func)
                    diff --git a/tests/test_comments.py b/tests/test_comments.py
                    index 5ef1290..225136e 100644
                    --- a/tests/test_comments.py
                    +++ b/tests/test_comments.py
                    @@ -43,11 +43,11 @@ def test_escape_comment_delimiter():
                     
                             
                    -
                    +
                    -

                    % This is not a comment.

                    +

                    % This is not a comment.

                    @@ -74,11 +74,11 @@ def test_end_of_line_comment():
                    -
                    +
                    -

                    Foo.

                    +

                    Foo.

                    @@ -103,11 +103,11 @@ def test_percent_within_math_is_not_a_comment():
                    -
                    +
                    -

                    \(10\%\) this is not a comment

                    +

                    \(10\%\) this is not a comment

                    @@ -136,11 +136,11 @@ def test_broken_paragraph():
                    -
                    +
                    -

                    This is a paragraph in the middle

                    +

                    This is a paragraph in the middle

                    diff --git a/tests/test_construct.py b/tests/test_construct.py index fadb109..e2af879 100644 --- a/tests/test_construct.py +++ b/tests/test_construct.py @@ -113,203 +113,204 @@ def test_real_life_example(): :: """, - want=r""" - + want=r""" + +
                    - -
                    - + +
                    +
                    - +

                    A simple proof

                    - -

                    LET \(G\) be a simple graph. We will prove a fundamental fact about its structure. DEFINE \(L(G) := |E(G)|\), where \(E(G)\) is the set of edges of \(G\) and WRITE \(\deg(u)\) for the degree of a node \(u \in V(G)\).

                    - -
                    - + +

                    LET \(G\) be a simple graph. We will prove a fundamental fact about its structure. DEFINE \(L(G) := |E(G)|\), where \(E(G)\) is the set of edges of \(G\) and WRITE \(\deg(u)\) for the degree of a node \(u \in V(G)\).

                    + +
                    +
                    - +

                    Theorem 1.

                    - -
                    - -
                    + +
                    + +
                    $$ \sum_{u \in V(G)} \deg(u) = 2L(G). $$
                    (1)
                    - +
                    - +
                    - +
                    - +
                    - -
                    - + +
                    +

                    Proof.

                    - +
                    - -
                    - -
                    - -

                    DEFINE \(n = |V(G)|\).

                    - -
                    - -
                    - -
                    - -
                    - -

                    CASE \(n = 1\).

                    - -
                    - -
                    - + +
                    + +
                    + +

                    DEFINE \(n = |V(G)|\).

                    + +
                    + +
                    + +
                    + +
                    + +

                    CASE \(n = 1\).

                    + +
                    + +
                    +
                    - -
                    - -
                    - -

                    \(L(G) = 0\).

                    - -
                    - -
                    - + +
                    + +
                    + +

                    \(L(G) = 0\).

                    + +
                    + +
                    +
                    - -

                    \(G\) has no self-loops by assumption.

                    - + +

                    \(G\) has no self-loops by assumption.

                    +
                    - +
                    - +
                    - -
                    - -
                    - -

                    LET \(u \in V(G)\), THEN \(\deg(u) = 0\).

                    - + +
                    + +
                    + +

                    LET \(u \in V(G)\), THEN \(\deg(u) = 0\).

                    +
                    - -
                    - + +
                    +
                    - -

                    Since \(G\) has only one node, and it has no self-loops.

                    - + +

                    Since \(G\) has only one node, and it has no self-loops.

                    +
                    - +
                    - +
                    - -
                    - -
                    - -

                    QED

                    - + +
                    + +
                    + +

                    QED

                    +
                    - +
                    - +
                    - +
                    - +
                    - -
                    - -
                    - -

                    LET \(v \notin V(G)\). WRITE \(H\) for the graph resulting from adding \(v\) to \(G\). SUFFICES ASSUME the theorem is true for \(G\), PROVE the theorem is true for \(H\).

                    - + +
                    + +
                    + +

                    LET \(v \notin V(G)\). WRITE \(H\) for the graph resulting from adding \(v\) to \(G\). SUFFICES ASSUME the theorem is true for \(G\), PROVE the theorem is true for \(H\).

                    +
                    - -
                    - + +
                    +
                    - -

                    By induction.

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

                    DEFINE \(\deg_G(u), \deg_H(u)\) as the degree of node \(u\) in \(G\) and \(H\) respectively. Note \(\deg_G(v) = 0\).

                    - -
                    - -
                    - -
                    - -
                    - -

                    \(L(H) = L(G) + \deg_H(v)\).

                    - -
                    - -
                    - + +

                    By induction.

                    + +
                    + +
                    + +
                    + +
                    + +
                    + +

                    DEFINE \(\deg_G(u), \deg_H(u)\) as the degree of node \(u\) in \(G\) and \(H\) respectively. Note \(\deg_G(v) = 0\).

                    + +
                    + +
                    + +
                    + +
                    + +

                    \(L(H) = L(G) + \deg_H(v)\).

                    + +
                    + +
                    +
                    - -

                    Because the only added edges are those incident to \(v\).

                    - + +

                    Because the only added edges are those incident to \(v\).

                    +
                    - +
                    - +
                    - -
                    - -
                    - -

                    \(\sum_{u \in V(H)} \deg_H(u) = 2\deg_H(v) + \sum_{u \in V(G)} \deg_G(u)\).

                    - + +
                    + +
                    + +

                    \(\sum_{u \in V(H)} \deg_H(u) = 2\deg_H(v) + \sum_{u \in V(G)} \deg_G(u)\).

                    +
                    - -
                    - + +
                    +
                    - -
                    - -
                    - -

                    WRITE \(W \subset V(G)\) for the set of neighbors of \(v\).

                    - -
                    - -
                    - -
                    - -
                    - -
                    - -
                    + +
                    + +
                    + +

                    WRITE \(W \subset V(G)\) for the set of neighbors of \(v\).

                    + +
                    + +
                    + +
                    + +
                    + +
                    + +
                    $$ \begin{align} \sum_{u \in V(H)} \deg_H(u) &= \phantom{2} \deg_H(v) + \sum_{u \in V(H)\setminus\{v\}} \deg_H(u) \\ @@ -320,38 +321,38 @@ def test_real_life_example(): \end{align} $$
                    (2)
                    - +
                    - +
                    - -

                    where in the right-most term in third equation we have used the fact that for every node \(u\) in \(V(G) \setminus W \setminus v\) we have \(\deg_H(u) = \deg_G(u)\).

                    - + +

                    where in the right-most term in third equation we have used the fact that for every node \(u\) in \(V(G) \setminus W \setminus v\) we have \(\deg_H(u) = \deg_G(u)\).

                    +
                    - +
                    - +
                    - +
                    - +
                    - -
                    - -
                    - -

                    QED

                    - + +
                    + +
                    + +

                    QED

                    +
                    - -
                    - + +
                    +
                    - -
                    - -
                    + +
                    + +
                    $$ \begin{align} 2 L(G) &= \sum_{u \in V(G)} \deg_G(u) \\ @@ -360,31 +361,31 @@ def test_real_life_example(): \end{align} $$
                    (3)
                    - +
                    - +
                    - -

                    where the first equation is true by induction hypothesis, and the last equation is due to Step 5 and Step 6.

                    - + +

                    where the first equation is true by induction hypothesis, and the last equation is due to Step 5 and Step 6.

                    +
                    - +
                    - +
                    - +
                    - +
                    - +
                    - +
                    - +
                    - +
                    - + """, ) diff --git a/tests/test_escapedstring.py b/tests/test_escapedstring.py index 4eef6ab..4178bc8 100644 --- a/tests/test_escapedstring.py +++ b/tests/test_escapedstring.py @@ -24,11 +24,11 @@ def test_simple_not_escaped():
                    -
                    +
                    -

                    Warning [CST error at (2, 7) - (2, 8)] this is a warning.

                    +

                    Warning [CST error at (2, 7) - (2, 8)] this is a warning.

                    @@ -55,11 +55,11 @@ def test_simple():
                    -
                    +
                    -

                    Warning: this is a warning.

                    +

                    Warning: this is a warning.

                    @@ -86,11 +86,11 @@ def test_colon_inside_bold():
                    -
                    +
                    -

                    Warning: this is a warning.

                    +

                    Warning: this is a warning.

                    @@ -117,11 +117,11 @@ def test_colon_inside_bold_no_space():
                    -
                    +
                    -

                    Warning: this is a warning.

                    +

                    Warning: this is a warning.

                    @@ -148,11 +148,11 @@ def test_colon_inside_bold_with_shortcut():
                    -
                    +
                    -

                    Warning:this is a warning.

                    +

                    Warning:this is a warning.

                    @@ -177,11 +177,11 @@ def test_backslash_brace_within_math():
                    -
                    +
                    -

                    \([k]:= \{1,\ldots,k\}\)

                    +

                    \([k]:= \{1,\ldots,k\}\)

                    diff --git a/tests/test_figure.py b/tests/test_figure.py index dd0159c..e83fb7e 100644 --- a/tests/test_figure.py +++ b/tests/test_figure.py @@ -6,11 +6,11 @@
                    -
                    +
                    -
                    +
                    Figure 1.
                    Figure 1. This is the figure caption. @@ -108,14 +108,14 @@ def test_caption_with_inline_tags():
                    -
                    +
                    -
                    +
                    Figure 1.
                    - Figure 1. This is the figure caption. + Figure 1. This is the figure caption.
                    diff --git a/tests/test_handrails.py b/tests/test_handrails.py index e4bc69d..12fb6a5 100644 --- a/tests/test_handrails.py +++ b/tests/test_handrails.py @@ -17,7 +17,7 @@ def test_manuscript():
                    -
                    +
                    @@ -73,7 +73,7 @@ def test_manuscript():
                    -

                    Hello.

                    +

                    Hello.

                    @@ -105,7 +105,7 @@ def test_section():
                    -
                    +
                    @@ -161,7 +161,7 @@ def test_section():
                    -
                    +
                    @@ -215,7 +215,7 @@ def test_section():
                    -

                    Hello.

                    +

                    Hello.

                    @@ -251,7 +251,7 @@ def test_abstract():
                    -
                    +
                    @@ -307,7 +307,7 @@ def test_abstract():
                    -
                    +
                    @@ -361,11 +361,11 @@ def test_abstract():
                    -

                    This is the abstract.

                    +

                    This is the abstract.

                    -

                    Hello.

                    +

                    Hello.

                    @@ -397,7 +397,7 @@ def test_theorem():
                    -
                    +
                    @@ -453,7 +453,7 @@ def test_theorem():
                    -
                    +
                    @@ -507,7 +507,7 @@ def test_theorem():

                    Theorem 1.

                    -

                    All \(X\) are \(Y\).

                    +

                    All \(X\) are \(Y\).

                    @@ -545,7 +545,7 @@ def test_proof():
                    -
                    +
                    @@ -601,7 +601,7 @@ def test_proof():
                    -
                    +
                    @@ -707,11 +707,11 @@ def test_proof():
                    (1)
                    -
                    +
                    -
                    +
                    -

                    Bar.

                    +

                    Bar.

                    @@ -761,7 +761,7 @@ def test_proof_with_sketch():
                    -
                    +
                    @@ -817,7 +817,7 @@ def test_proof_with_sketch():
                    -
                    +
                    @@ -883,9 +883,9 @@ def test_proof_with_sketch():
                    -
                    +
                    -

                    Foo.

                    +

                    Foo.

                    @@ -937,11 +937,11 @@ def test_proof_with_sketch():
                    (1)
                    -
                    +
                    -
                    +
                    -

                    Bar.

                    +

                    Bar.

                    @@ -996,7 +996,7 @@ def test_sub_step():
                    -
                    +
                    @@ -1052,7 +1052,7 @@ def test_sub_step():
                    -
                    +
                    @@ -1158,15 +1158,15 @@ def test_sub_step():
                    (1)
                    -
                    +
                    -
                    +
                    -

                    Top level step.

                    +

                    Top level step.

                    -
                    +
                    @@ -1218,19 +1218,19 @@ def test_sub_step():
                    (1.1)
                    -
                    +
                    -
                    +
                    -

                    Sub-step.

                    +

                    Sub-step.

                    -
                    +
                    -

                    Sub-proof.

                    +

                    Sub-proof.

                    @@ -1289,22 +1289,22 @@ def test_two_steps(): """, want=""" - +
                    - -
                    - + +
                    +
                    - +
                    - +
                    - +
                    - +
                    @@ -1312,13 +1312,13 @@ def test_two_steps():
                    - + - + @@ -1331,34 +1331,34 @@ def test_two_steps(): - + - +
                    - +
                    - +

                    Some Title

                    - +
                    - -
                    - + +
                    +
                    - +
                    - +
                    - +
                    @@ -1366,13 +1366,13 @@ def test_two_steps():
                    - + - + @@ -1385,36 +1385,36 @@ def test_two_steps(): - + - +
                    - +
                    - +
                    - +

                    Proof.

                    - +
                    - +
                    - +
                    - +
                    - +
                    - +
                    @@ -1422,13 +1422,13 @@ def test_two_steps():
                    - + - + @@ -1441,42 +1441,42 @@ def test_two_steps(): - + - +
                    - +
                    (1)
                    -
                    - -
                    - -

                    First step.

                    - +
                    + +
                    + +

                    First step.

                    +
                    - +
                    - +
                    - +
                    - +
                    - +
                    - +
                    - +
                    @@ -1484,13 +1484,13 @@ def test_two_steps():
                    - + - + @@ -1503,47 +1503,47 @@ def test_two_steps(): - + - +
                    - +
                    (2)
                    -
                    - -
                    - -

                    Secon step.

                    - +
                    + +
                    + +

                    Secon step.

                    +
                    - +
                    - +
                    - +
                    - +
                    - +
                    - +
                    - +
                    - +
                    - +
                    - +
                    - + """, ) @@ -1566,11 +1566,11 @@ def test_unnumbered_mathblock_no_phantom_number():
                    -
                    +
                    -
                    +
                    $$ 3 + 3 = 6 $$ @@ -1603,11 +1603,11 @@ def test_mathblock_phantom_number():
                    -
                    +
                    -
                    +
                    (1)
                    $$ diff --git a/tests/test_lists.py b/tests/test_lists.py index f4c46a9..c8b7ee3 100644 --- a/tests/test_lists.py +++ b/tests/test_lists.py @@ -45,39 +45,39 @@ def test_simple():
                    -
                    +

                    My Title

                    -
                      +
                        -
                      1. +
                      2. Foo bar.
                      3. -
                      4. +
                      5. Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet.
                      6. -
                      7. +
                      8. Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet.
                      -
                        +
                          -
                        • +
                        • Foo bar.
                        • -
                        • +
                        • Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet.
                        • -
                        • +
                        • Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet.
                        • @@ -136,15 +136,15 @@ def test_item_with_wrong_parent():
                          -
                          +
                          -
                          +

                          1. Some section

                          -

                          Lorem ipsum [CST error at (4, 12) - (4, 18)] Foo bar.

                          +

                          Lorem ipsum [CST error at (4, 12) - (4, 18)] Foo bar.

                          diff --git a/tests/test_math.py b/tests/test_math.py index f056656..a3fb342 100644 --- a/tests/test_math.py +++ b/tests/test_math.py @@ -23,11 +23,11 @@ def test_display_alone():
                          -
                          +
                          -
                          +
                          $$ 2 + 2 = 4 $$ @@ -59,11 +59,11 @@ def test_inline_no_meta():
                          -
                          +
                          -

                          This paragraph contains inline math \(2 + 2 = 4\).

                          +

                          This paragraph contains inline math \(2 + 2 = 4\).

                          @@ -90,11 +90,11 @@ def test_inline_with_meta():
                          -
                          +
                          -

                          This paragraph contains inline math \(2 + 2 +

                          This paragraph contains inline math \(2 + 2 = 4\).

                          @@ -126,17 +126,17 @@ def test_math_with_shortcuts():
                          -
                          +
                          -
                          +

                          1. My Section

                          -

                          When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are

                          +

                          When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are

                          -
                          +
                          $$ x = {-b \pm \sqrt{b^2-4ac} \over 2a}. $$ @@ -180,17 +180,17 @@ def test_math_ref():
                          -
                          +
                          -
                          +

                          1. My Section

                          -

                          This is some inline \(2+2=4\) math. And then some display math.

                          +

                          This is some inline \(2+2=4\) math. And then some display math.

                          -
                          +
                          $$ 2+2=4 $$ @@ -198,7 +198,7 @@ def test_math_ref():
                          -

                          And now we refer to (1.1).

                          +

                          And now we refer to (1.1).

                          @@ -228,11 +228,11 @@ def test_mathblock_nonum():
                          -
                          +
                          -
                          +
                          $$ 2+2=4 $$ @@ -264,11 +264,11 @@ def test_mathblock_nonum_with_shortcut():
                          -
                          +
                          -
                          +
                          $$ 2+2=4 $$ @@ -297,11 +297,11 @@ def test_unclosed_dollar_sign():
                          -
                          +
                          -

                          There are three dollar signs here \(2+2\)= 0 [CST error at (2, 43) - (2, 44)] .

                          +

                          There are three dollar signs here \(2+2\)= 0 [CST error at (2, 43) - (2, 44)] .

                          @@ -336,13 +336,13 @@ def test_mathblock_isclaim():
                          -
                          +
                          -
                          - -
                          +
                          + +
                          $$ 2+2 = 4 $$ @@ -352,9 +352,9 @@ def test_mathblock_isclaim():
                          -
                          - -
                          +
                          + +
                          $$ 2+2 = 4 $$ diff --git a/tests/test_meta.py b/tests/test_meta.py index 086a2ab..727542d 100644 --- a/tests/test_meta.py +++ b/tests/test_meta.py @@ -19,13 +19,13 @@ def test_list_with_only_one_element():
                          -
                          +

                          My Title

                          -

                          This paragraph has only one type

                          +

                          This paragraph has only one type

                          @@ -54,13 +54,13 @@ def test_list_with_one_element_before_key():
                          -
                          +

                          My Title

                          -

                          This paragraph has only one type, that appears before another key.

                          +

                          This paragraph has only one type, that appears before another key.

                          @@ -88,13 +88,13 @@ def test_list_no_braces():
                          -
                          +

                          My Title

                          - [CST error at (3, 0) - (3, 28)] -

                          This paragraph has only one type

                          + [CST error at (3, 0) - (3, 28)] +

                          This paragraph has only one type

                          @@ -124,13 +124,13 @@ def test_inline_no_meta_start_with_tag():
                          -
                          +
                          -

                          Foo bar.

                          +

                          Foo bar.

                          -

                          This span starts with a tag that is not a meta key, some paragraph, instead it starts with a ref.

                          +

                          This span starts with a tag that is not a meta key, some paragraph, instead it starts with a ref.

                          @@ -157,11 +157,11 @@ def test_list_within_inline():
                          -
                          +
                          -

                          Foo bar baz.

                          +

                          Foo bar baz.

                          @@ -186,11 +186,11 @@ def test_inline_start_with_brace():
                          -
                          +
                          -

                          This span starts with a brace {.

                          +

                          This span starts with a brace {.

                          @@ -217,11 +217,11 @@ def test_inline_meta_with_no_space():
                          -
                          +
                          -

                          Foo bar.

                          +

                          Foo bar.

                          @@ -248,11 +248,11 @@ def test_inline_meta_with_space_in_between_braces():
                          -
                          +
                          -

                          Foo bar.

                          +

                          Foo bar.

                          diff --git a/tests/test_paragraph.py b/tests/test_paragraph.py index c1506f0..8443c2c 100644 --- a/tests/test_paragraph.py +++ b/tests/test_paragraph.py @@ -16,11 +16,11 @@ def test_succeeding_blankline():
                          -
                          +
                          -

                          Foo.

                          +

                          Foo.

                          @@ -46,11 +46,11 @@ def test_succeeding_blankline_with_tag():
                          -
                          +
                          -

                          This is a paragraph.

                          +

                          This is a paragraph.

                          @@ -77,11 +77,11 @@ def test_start_with_tag():
                          -
                          +
                          -

                          this tag starts the paragraph.

                          +

                          this tag starts the paragraph.

                          @@ -108,11 +108,11 @@ def test_start_with_shortcut():
                          -
                          +
                          -

                          A claim.

                          +

                          A claim.

                          @@ -163,23 +163,23 @@ def test_simple():
                          -
                          +

                          The Perron non-backtracking eigenvalue after node addition

                          -
                          +

                          1. Introduction

                          -

                          Lorem ipsum.

                          +

                          Lorem ipsum.

                          -

                          This is a paragraph with meta data. It has several lines of text. It has several lines of text. It has several lines of text. It has several lines of text. It has several lines of text.

                          +

                          This is a paragraph with meta data. It has several lines of text. It has several lines of text. It has several lines of text. It has several lines of text. It has several lines of text.

                          -

                          This is a paragraph with meta data. It has several lines of text. It has several lines of text. It has several lines of text. It has several lines of text. It has several lines of text.

                          +

                          This is a paragraph with meta data. It has several lines of text. It has several lines of text. It has several lines of text. It has several lines of text. It has several lines of text.

                          -

                          This is a paragraph with meta data. It has several lines of text. It has several lines of text. It has several lines of text. It has several lines of text. It has several lines of text.

                          +

                          This is a paragraph with meta data. It has several lines of text. It has several lines of text. It has several lines of text. It has several lines of text. It has several lines of text.

                          diff --git a/tests/test_previous.py b/tests/test_previous.py index 967f0f9..7facbde 100644 --- a/tests/test_previous.py +++ b/tests/test_previous.py @@ -26,31 +26,31 @@ def test_works_with_no_reftext_and_label():
                          -
                          +
                          -
                          +

                          Proof.

                          -
                          +
                          -
                          +
                          -

                          Foo.

                          +

                          Foo.

                          -
                          +
                          -
                          +
                          -

                          Bar Step 1.

                          +

                          Bar Step 1.

                          @@ -93,31 +93,31 @@ def test_works_with_no_reftext_and_no_label():
                          -
                          +
                          -
                          +

                          Proof.

                          -
                          +
                          -
                          +
                          -

                          Foo.

                          +

                          Foo.

                          -
                          +
                          -
                          +
                          -

                          Bar Step 1.

                          +

                          Bar Step 1.

                          @@ -162,31 +162,31 @@ def test_works_with_reftext_and_label():
                          -
                          +
                          -
                          +

                          Proof.

                          -
                          +
                          -
                          +
                          -

                          Foo.

                          +

                          Foo.

                          -
                          +
                          -
                          +
                          -

                          Bar bar.

                          +

                          Bar bar.

                          @@ -229,31 +229,31 @@ def test_works_with_reftext_and_no_label():
                          -
                          +
                          -
                          +

                          Proof.

                          -
                          +
                          -
                          +
                          -

                          Foo.

                          +

                          Foo.

                          -
                          +
                          -
                          +
                          -

                          Bar bar.

                          +

                          Bar bar.

                          diff --git a/tests/test_proof.py b/tests/test_proof.py index 4022102..ba627d3 100644 --- a/tests/test_proof.py +++ b/tests/test_proof.py @@ -24,33 +24,33 @@ def test_simple():
                          -
                          +
                          -
                          +

                          Theorem 1.

                          -

                          All \(X\) are \(Y\).

                          +

                          All \(X\) are \(Y\).

                          -
                          +

                          Proof.

                          -
                          +
                          -
                          +
                          -

                          Axiom.

                          +

                          Axiom.

                          @@ -96,23 +96,23 @@ def test_empty_proof():
                          -
                          +
                          -
                          +

                          Theorem 1.

                          -

                          Theorem contents.

                          +

                          Theorem contents.

                          -
                          +

                          Proof.

                          @@ -160,41 +160,41 @@ def test_sub_step():
                          -
                          +
                          -
                          +

                          Proof.

                          -
                          +
                          -
                          +
                          -

                          Top level step.

                          +

                          Top level step.

                          -
                          +
                          -
                          +
                          -
                          +
                          -

                          Sub-step.

                          +

                          Sub-step.

                          -
                          +
                          -

                          Sub-proof.

                          +

                          Sub-proof.

                          @@ -245,31 +245,31 @@ def test_two_steps():
                          -
                          +
                          -
                          +

                          Proof.

                          -
                          +
                          -
                          +
                          -

                          First step.

                          +

                          First step.

                          -
                          +
                          -
                          +
                          -

                          Secon step.

                          +

                          Secon step.

                          diff --git a/tests/test_references.py b/tests/test_references.py index 290b241..3d16576 100644 --- a/tests/test_references.py +++ b/tests/test_references.py @@ -25,19 +25,19 @@ def test_reftext():
                          -
                          +
                          -
                          +

                          1. First

                          -

                          Content of first.

                          +

                          Content of first.

                          -

                          This is a paragraph that refers to Section 1.

                          +

                          This is a paragraph that refers to Section 1.

                          @@ -72,19 +72,19 @@ def test_overwrite_reftext():
                          -
                          +
                          -
                          +

                          1. First

                          -

                          Content of first.

                          +

                          Content of first.

                          -

                          This is a paragraph that refers to The Section.

                          +

                          This is a paragraph that refers to The Section.

                          @@ -111,11 +111,11 @@ def test_ref_to_unknown_label(caplog):
                          -
                          +
                          -

                          [unknown label "foo"]

                          +

                          [unknown label "foo"]

                          diff --git a/tests/test_reftext.py b/tests/test_reftext.py index 71c72d8..56832f5 100644 --- a/tests/test_reftext.py +++ b/tests/test_reftext.py @@ -47,11 +47,11 @@ def test_simple():
                          -
                          +
                          -
                          +
                          $$ 2+2=4 $$ @@ -59,7 +59,7 @@ def test_simple():
                          -

                          Here we refer to the Important Equation.

                          +

                          Here we refer to the Important Equation.

                          diff --git a/tests/test_regions.py b/tests/test_regions.py index 13c6112..595a0c1 100644 --- a/tests/test_regions.py +++ b/tests/test_regions.py @@ -19,20 +19,20 @@ def test_inline_cannot_contain_block():
                          -
                          +

                          My Title

                          - [CST error at (3, 0) - (3, 42)] -
                          + [CST error at (3, 0) - (3, 42)] +

                          1.

                          -

                          with a block.

                          +

                          with a block.

                          - [CST error at (5, 0) - (5, 2)] + [CST error at (5, 0) - (5, 2)]
                          @@ -60,19 +60,19 @@ def test_paragraph_ends_at_block():
                          -
                          +

                          My Title

                          -

                          This paragraph will terminate before the section starts

                          +

                          This paragraph will terminate before the section starts

                          -
                          +

                          1.

                          -

                          And this is inside the section.

                          +

                          And this is inside the section.

                          diff --git a/tests/test_render.py b/tests/test_render.py index 6088d75..50dd77d 100644 --- a/tests/test_render.py +++ b/tests/test_render.py @@ -18,15 +18,15 @@ def test_render(tmp_path):
                          -
                          +
                          -

                          Foo.

                          +

                          Foo.

                          -

                          Bar.

                          +

                          Bar.

                          -

                          Baz.

                          +

                          Baz.

                          diff --git a/tests/test_section.py b/tests/test_section.py index 0b4d82c..8f74e83 100644 --- a/tests/test_section.py +++ b/tests/test_section.py @@ -20,15 +20,15 @@ def test_simple():
                          -
                          +
                          -
                          +

                          1. Section

                          -

                          Lorem ipsum.

                          +

                          Lorem ipsum.

                          @@ -76,27 +76,27 @@ def test_subsections():
                          -
                          +
                          -
                          +

                          1. Section

                          -

                          Lorem ipsum.

                          +

                          Lorem ipsum.

                          -
                          +

                          1.1. Sub section

                          -

                          Foo

                          +

                          Foo

                          -
                          +

                          1.1.1. Sub sub section

                          -

                          Bar

                          +

                          Bar

                          diff --git a/tests/test_shortcuts.py b/tests/test_shortcuts.py index 1b97660..d56ce33 100644 --- a/tests/test_shortcuts.py +++ b/tests/test_shortcuts.py @@ -17,13 +17,13 @@ def test_one_strong():
                          -
                          +

                          My Title

                          -

                          This paragraph has a shortcut for strong span.

                          +

                          This paragraph has a shortcut for strong span.

                          @@ -51,13 +51,13 @@ def test_two_strong():
                          -
                          +

                          My Title

                          -

                          This paragraph has two shortcuts for strong spans.

                          +

                          This paragraph has two shortcuts for strong spans.

                          @@ -85,13 +85,13 @@ def test_one_emphas():
                          -
                          +

                          My Title

                          -

                          This paragraph has a shortcut for emphasis span.

                          +

                          This paragraph has a shortcut for emphasis span.

                          @@ -118,13 +118,13 @@ def test_one_math():
                          -
                          +

                          My Title

                          -

                          This paragraph has some \(2+2=4\) awesome math.

                          +

                          This paragraph has some \(2+2=4\) awesome math.

                          @@ -152,13 +152,13 @@ def test_two_math():
                          -
                          +

                          My Title

                          -

                          This paragraph has some \(2+2=4\) awesome math and also some math that \(2 + 2 + 2 +

                          This paragraph has some \(2+2=4\) awesome math and also some math that \(2 + 2 + 2 + 2 + 2 = 10\) is broken down.

                          @@ -188,13 +188,13 @@ def test_mathblock():
                          -
                          +
                          -

                          This paragraph is followed by display math

                          +

                          This paragraph is followed by display math

                          -
                          +
                          $$ 2 + 2 = 4. $$ @@ -232,15 +232,15 @@ def test_section_shortcut():
                          -
                          +
                          -
                          +

                          1. My Section

                          -

                          This section contains a shortcut

                          +

                          This section contains a shortcut

                          @@ -285,27 +285,27 @@ def test_subsubsection_shortcut():
                          -
                          +
                          -
                          +

                          1. My Section

                          -

                          Foo.

                          +

                          Foo.

                          -
                          +

                          1.1. My Subsection

                          -

                          Bar.

                          +

                          Bar.

                          -
                          +

                          1.1.1. My Subsubsection

                          -

                          Baz.

                          +

                          Baz.

                          @@ -339,11 +339,11 @@ def test_claim_shortcut():
                          -
                          +
                          -

                          This paragraph contains a claim with a turnstile. And also another one but it takes multiple lines.

                          +

                          This paragraph contains a claim with a turnstile. And also another one but it takes multiple lines.

                          @@ -388,51 +388,51 @@ def test_prev_shortcut():
                          -
                          +
                          -
                          +

                          Theorem 1.

                          -

                          All \(X\) are \(Y\).

                          +

                          All \(X\) are \(Y\).

                          -
                          +

                          Proof.

                          -
                          +
                          -
                          +
                          -

                          All \(X\) are \(Z\) and all \(Z\) are \(Y\).

                          +

                          All \(X\) are \(Z\) and all \(Z\) are \(Y\).

                          -
                          +
                          -
                          +
                          -

                          QED .

                          +

                          QED .

                          -
                          +
                          -

                          Due to Step 1.

                          +

                          Due to Step 1.

                          @@ -494,61 +494,61 @@ def test_prev2_shortcut():
                          -
                          +
                          -
                          +

                          Theorem 1.

                          -

                          All \(X\) are \(Y\).

                          +

                          All \(X\) are \(Y\).

                          -
                          +

                          Proof.

                          -
                          +
                          -
                          +
                          -

                          All \(X\) are \(Z\) and all \(Z\) are \(Y\).

                          +

                          All \(X\) are \(Z\) and all \(Z\) are \(Y\).

                          -
                          +
                          -
                          +
                          -

                          Something inconsequential here.

                          +

                          Something inconsequential here.

                          -
                          +
                          -
                          +
                          -

                          QED .

                          +

                          QED .

                          -
                          +
                          -

                          Due to Step 1.

                          +

                          Due to Step 1.

                          @@ -610,61 +610,61 @@ def test_prev_and_prev2_shortcut():
                          -
                          +
                          -
                          +

                          Theorem 1.

                          -

                          All \(X\) are \(Y\).

                          +

                          All \(X\) are \(Y\).

                          -
                          +

                          Proof.

                          -
                          +
                          -
                          +
                          -

                          All \(X\) are \(Z\).

                          +

                          All \(X\) are \(Z\).

                          -
                          +
                          -
                          +
                          -

                          All \(Z\) are \(Y\).

                          +

                          All \(Z\) are \(Y\).

                          -
                          +
                          -
                          +
                          -

                          QED .

                          +

                          QED .

                          -
                          +
                          -

                          Due to Step 2 and Step 1.

                          +

                          Due to Step 2 and Step 1.

                          @@ -703,12 +703,12 @@ def test_code_shortcut():
                          -
                          +
                          -

                          This is inline code - comp = [abs(x) for x in range(10)] +

                          This is inline code + comp = [abs(x) for x in range(10)] .

                          @@ -738,11 +738,11 @@ def test_codeblock_shortcut():
                          -
                          +
                          -
                          +
                                   comp = [abs(x) for x in range(10)]
                          @@ -778,15 +778,15 @@ def test_hashtag_not_at_the_start_of_line():
                           
                                   
                          -
                          +
                          -
                          +

                          1. This is a section title

                          -

                          And # this is not!

                          +

                          And # this is not!

                          @@ -814,11 +814,11 @@ def test_escaped_colon_behind_halmos():
                          -
                          +
                          -

                          Shortcut right beside an escaped colon foo:

                          +

                          Shortcut right beside an escaped colon foo:

                          @@ -844,11 +844,11 @@ def test_escaped_colon_behind_halmos_after_shortcut():
                          -
                          +
                          -

                          Shortcut right beside an escaped colon foo:

                          +

                          Shortcut right beside an escaped colon foo:

                          @@ -875,11 +875,11 @@ def test_math_after_turnstile():
                          -
                          +
                          -

                          This paragraph has math inside a claim \(2+2=4\).

                          +

                          This paragraph has math inside a claim \(2+2=4\).

                          @@ -913,20 +913,20 @@ def test_turnstile_and_math_within_list():
                          -
                          +
                          -

                          We now make a bunch of claims

                          +

                          We now make a bunch of claims

                          -
                            +
                              -
                            1. - \(2+2=4\). +
                            2. + \(2+2=4\).
                            3. -
                            4. - \(3+3=6\). +
                            5. + \(3+3=6\).
                            @@ -955,11 +955,11 @@ def test_asterisk_inside_math():
                            -
                            +
                            -

                            \(2*2 = 4*1\)

                            +

                            \(2*2 = 4*1\)

                            @@ -985,12 +985,12 @@ def test_asterisk_inside_code():
                            -
                            +
                            -

                            - [x**2 for x in range(10)] +

                            + [x**2 for x in range(10)]

                            @@ -1019,11 +1019,11 @@ def test_asterisk_inside_mathblock():
                            -
                            +
                            -
                            +
                            $$ 2*2 = 4*1 $$ @@ -1057,11 +1057,11 @@ def test_asterisk_inside_codeblock():
                            -
                            +
                            -
                            +
                                     2*2 = 4*1
                            diff --git a/tests/test_simple.py b/tests/test_simple.py
                            index 9a5fac9..e1b7cc9 100644
                            --- a/tests/test_simple.py
                            +++ b/tests/test_simple.py
                            @@ -33,11 +33,11 @@ def test_no_manuscript_title():
                             
                                     
                            -
                            +
                            -

                            Lorem ipsum.

                            +

                            Lorem ipsum.

                            @@ -65,13 +65,13 @@ def test_manuscript_title():
                            -
                            +

                            My Title

                            -

                            Lorem ipsum.

                            +

                            Lorem ipsum.

                            @@ -98,7 +98,7 @@ def test_manuscript_meta():
                            -
                            +
                            @@ -144,17 +144,17 @@ def test_section_header():
                            -
                            +
                            -

                            Lorem ipsum.

                            +

                            Lorem ipsum.

                            -
                            +

                            1. section title

                            -

                            Lorem ipsum.

                            +

                            Lorem ipsum.

                            diff --git a/tests/test_sketch.py b/tests/test_sketch.py index 81a6ecc..d03f7bb 100644 --- a/tests/test_sketch.py +++ b/tests/test_sketch.py @@ -21,27 +21,27 @@ def test_simple_no_handrails():
                            -
                            +
                            -
                            +

                            Proof.

                            -
                            +
                            -

                            Foo.

                            +

                            Foo.

                            -
                            +
                            -
                            +
                            -

                            Bar.

                            +

                            Bar.

                            @@ -84,11 +84,11 @@ def test_simple_with_handrails():
                            -
                            +
                            -
                            +
                            @@ -154,9 +154,9 @@ def test_simple_with_handrails():
                            -
                            +
                            -

                            Foo.

                            +

                            Foo.

                            @@ -208,11 +208,11 @@ def test_simple_with_handrails():
                            (1)
                            -
                            +
                            -
                            +
                            -

                            Bar.

                            +

                            Bar.

                            diff --git a/tests/test_span.py b/tests/test_span.py index a2ac990..c984372 100644 --- a/tests/test_span.py +++ b/tests/test_span.py @@ -15,11 +15,11 @@ def test_one_span():
                            -
                            +
                            -

                            This is a boring paragraph.

                            +

                            This is a boring paragraph.

                            @@ -47,11 +47,11 @@ def test_two_spans():
                            -
                            +
                            -

                            This is a boring paragraph, though it has two spans so it's less boring.

                            +

                            This is a boring paragraph, though it has two spans so it's less boring.

                            @@ -80,11 +80,11 @@ def test_nested():
                            -
                            +
                            -

                            This is a paragraph with a span within a span so that makes it really cool. BTW it also has a Halmos at the start of a line!

                            +

                            This is a paragraph with a span within a span so that makes it really cool. BTW it also has a Halmos at the start of a line!

                            @@ -114,11 +114,11 @@ def test_span_with_multiline_meta():
                            -
                            +
                            -

                            This is a paragraph with a span and it is multi line.

                            +

                            This is a paragraph with a span and it is multi line.

                            @@ -145,11 +145,11 @@ def test_span_with_label():
                            -
                            +
                            -

                            This is a boring paragraph.

                            +

                            This is a boring paragraph.

                            @@ -176,11 +176,11 @@ def test_span_part_of_word():
                            -
                            +
                            -

                            This word is half bold boring.

                            +

                            This word is half bold boring.

                            @@ -207,11 +207,11 @@ def test_span_part_of_word_with_shortcut():
                            -
                            +
                            -

                            This word is half bold boring.

                            +

                            This word is half bold boring.

                            diff --git a/tests/test_table.py b/tests/test_table.py index 6a0472a..8f42e4c 100644 --- a/tests/test_table.py +++ b/tests/test_table.py @@ -17,11 +17,11 @@ def test_empty_table():
                            -
                            +
                            - +
                            @@ -58,19 +58,19 @@ def test_one_row_no_header():
                            -
                            +
                            - +
                            - + - + - + - + @@ -113,27 +113,27 @@ def test_two_rows_no_header():
                            -
                            +
                            -
                            foofoobarbar
                            +
                            - + - + - + - + - + - + - + @@ -182,39 +182,39 @@ def test_with_header():
                            -
                            +
                            -
                            oneonetwotwo
                            threethreefourfour
                            +
                            - + - + - + - + - + - + - + - + - + - + - + @@ -253,21 +253,21 @@ def test_math_in_header():
                            -
                            +
                            -
                            head1head1head2head2
                            oneonetwotwo
                            threethreefourfour
                            +
                            - + - + - + - + - + @@ -308,19 +308,19 @@ def test_shortcuts_in_header():
                            -
                            +
                            -
                            \(H^{\eta}\)\(H^{\eta}\)\(H^{*}\)\(H^{*}\)\(H^{c}\)\(H^{c}\)
                            +
                            - + - + - + - + @@ -364,19 +364,19 @@ def test_simple_caption():
                            -
                            +
                            -
                            foofoobarbar
                            +
                            - + - + - + - + @@ -423,26 +423,26 @@ def test_simple_caption_with_shortcuts():
                            -
                            +
                            -
                            foofoobarbar
                            +
                            - + - + - + - +
                            foofoobarbar
                            - Table 1. This is a caption with shortcuts \(2+2\). + Table 1. This is a caption with shortcuts \(2+2\).
                            @@ -483,19 +483,19 @@ def test_reference_to_table():
                            -
                            +
                            - +
                            - + - + - + - + @@ -503,7 +503,7 @@ def test_reference_to_table():
                            foofoobarbar
                            -

                            This Table 1 refers to the table.

                            +

                            This Table 1 refers to the table.

                            @@ -541,19 +541,19 @@ def test_reference_to_table_with_reftext():
                            -
                            +
                            - +
                            - + - + - + - + @@ -561,7 +561,7 @@ def test_reference_to_table_with_reftext():
                            foofoobarbar
                            -

                            This refers to the table.

                            +

                            This refers to the table.

                            @@ -599,19 +599,19 @@ def test_extra_space_within_tr():
                            -
                            +
                            - +
                            - + - + - + - + @@ -657,52 +657,52 @@ def test_real_life_example():
                            -
                            +
                            -
                            foofoobarbar
                            +
                            - + - + - + - + - + - + - + - + - + - + - + - + - + - +
                            \(H^{\tau}\)\(H^{\tau}\)\(H^{*}\)\(H^{*}\)\(H^{c}\)\(H^{c}\)
                            \(0.0001\)\(0.0001\)\(0.0146\)\(0.0146\)\(0.0549\)\(0.0549\)
                            \(0.1222\)\(0.1222\)\(0.0139\)\(0.0139\)\(0.0106\)\(0.0106\)
                            - Table 1. Values of \(\epsilon\) and \(\delta\) for select subgraphs of Gr-Qc. + Table 1. Values of \(\epsilon\) and \(\delta\) for select subgraphs of Gr-Qc.
                            @@ -754,52 +754,52 @@ def test_real_life_example_different_spacing():
                            -
                            +
                            - +
                            - + - + - + - + - + - + - + - + - + - + - + - + - + - +
                            \(H^{\tau}\)\(H^{\tau}\)\(H^{*}\)\(H^{*}\)\(H^{c}\)\(H^{c}\)
                            \(0.0001\)\(0.0001\)\(0.0146\)\(0.0146\)\(0.0549\)\(0.0549\)
                            \(0.1222\)\(0.1222\)\(0.0139\)\(0.0139\)\(0.0106\)\(0.0106\)
                            - Table 1. Values of \(\epsilon\) and \(\delta\) for select subgraphs of Gr-Qc. + Table 1. Values of \(\epsilon\) and \(\delta\) for select subgraphs of Gr-Qc.
                            @@ -839,45 +839,45 @@ def test_tr_shortcut():
                            -
                            +
                            - +
                            - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -918,45 +918,45 @@ def test_tr_shortcut_with_math():
                            -
                            +
                            -
                            foofoobarbarbazbaz
                            a1a1a2a2a3a3
                            b1b1b2b2b3b3
                            +
                            - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1000,50 +1000,49 @@ def test_tr_shortcut_with_newlines(): :: """, - want=""" - + want="""
                            -
                            +
                            -
                            \(H^{\tau}\)\(H^{\tau}\)\(H^{\top}\)\(H^{\top}\)\(H^{c}\)\(H^{c}\)
                            \(0.0001\)\(0.0001\)\(0.0146\)\(0.0146\)\(0.0549\)\(0.0549\)
                            \(0.1222\)\(0.1222\)\(0.0139\)\(0.0139\)\(0.0106\)\(0.0106\)
                            +
                            - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1085,45 +1084,45 @@ def test_tr_shortcut_with_escaped_colon():
                            -
                            +
                            -
                            foofoobarbarbazbaz
                            a1a1a2a2a3a3
                            b1b1b2b2b3b3
                            +
                            - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/tests/test_theorem.py b/tests/test_theorem.py index af0b001..f3e5abf 100644 --- a/tests/test_theorem.py +++ b/tests/test_theorem.py @@ -19,17 +19,17 @@ def test_simple():
                            -
                            +
                            -
                            +

                            Theorem 1.

                            -

                            Theorem contents.

                            +

                            Theorem contents.

                            @@ -65,7 +65,7 @@ def test_simple_with_handrails():
                            -
                            +
                            @@ -121,7 +121,7 @@ def test_simple_with_handrails():
                            -
                            +
                            @@ -175,7 +175,7 @@ def test_simple_with_handrails():

                            Theorem 1.

                            -

                            Theorem contents.

                            +

                            Theorem contents.

                            @@ -224,41 +224,41 @@ def test_multiple():
                            -
                            +
                            -
                            +

                            Theorem 1.

                            -

                            Theorem contents.

                            +

                            Theorem contents.

                            -
                            +

                            Lemma 2.

                            -

                            And a lemma.

                            +

                            And a lemma.

                            -
                            +

                            Theorem 3.

                            -

                            Another theorem.

                            +

                            Another theorem.

                            diff --git a/tests/test_transformer.py b/tests/test_transformer.py index bd2d952..730d89f 100644 --- a/tests/test_transformer.py +++ b/tests/test_transformer.py @@ -19,13 +19,13 @@ def test_duplicate_label_warning(caplog):
                            -
                            +

                            Title

                            -

                            There are two spans with the same label in this paragraph.

                            +

                            There are two spans with the same label in this paragraph.

                            @@ -72,7 +72,7 @@ def test_duplicate_bibtex_item_warning(caplog):
                            -
                            +
                            @@ -80,13 +80,13 @@ def test_duplicate_bibtex_item_warning(caplog):

                            References

                            -
                              +
                                -
                              1. +
                              2. Torres, Leo and Chan, Kevin S and Tong, Hanghang and Eliassi-Rad, Tina. "Nonbacktracking eigenvalues under node removal: X-centrality and targeted immunization". SIAM Journal on Mathematics of Data Science. 2021.
                              3. -
                              4. +
                              5. Bar. "Foo". Bug.
                              6. @@ -126,15 +126,15 @@ def test_theorem_within_section():
                                -
                                +
                                -
                                +

                                1. Section

                                -
                                +
                                @@ -181,15 +181,15 @@ def test_two_theorems_same_section():
                                -
                                +
                                -
                                +

                                1. Section

                                -
                                +
                                @@ -199,7 +199,7 @@ def test_two_theorems_same_section():
                                -
                                +
                                @@ -250,15 +250,15 @@ def test_two_theorems_different_sections():
                                -
                                +
                                -
                                +

                                1. Section 1

                                -
                                +
                                @@ -270,11 +270,11 @@ def test_two_theorems_different_sections():
                                -
                                +

                                2. Section 2

                                -
                                +
                                @@ -322,15 +322,15 @@ def test_two_theorems_same_section_nonum():
                                -
                                +
                                -
                                +

                                1. Section

                                -
                                +
                                @@ -340,7 +340,7 @@ def test_two_theorems_same_section_nonum():
                                -
                                +
                                @@ -384,15 +384,15 @@ def test_theorem_inside_section_with_nonum():
                                -
                                +
                                -
                                +

                                Section

                                -
                                +
                                @@ -439,19 +439,19 @@ def test_theorem_inside_subsection():
                                -
                                +
                                -
                                +

                                1. Section

                                -
                                +

                                1.1. Subsection

                                -
                                +
                                diff --git a/tests/test_url.py b/tests/test_url.py index 34ec8cd..a9526ad 100644 --- a/tests/test_url.py +++ b/tests/test_url.py @@ -18,11 +18,11 @@ def test_no_reftext():
                                -
                                +
                                -

                                This paragraph has a hyperlink https://www.apache.com.

                                +

                                This paragraph has a hyperlink https://www.apache.com.

                                @@ -49,11 +49,11 @@ def test_custom_reftext():
                                -
                                +
                                -

                                This is a link to Apache.

                                +

                                This is a link to Apache.

                                @@ -80,11 +80,11 @@ def test_no_target():
                                -
                                +
                                -

                                This is a malformed url [CST error at (2, 24) - (2, 31)] .

                                +

                                This is a malformed url [CST error at (2, 24) - (2, 31)] .

                                @@ -109,11 +109,11 @@ def test_no_target():
                                -
                                +
                                -

                                This is a malformed url with a space [CST error at (2, 37) - (2, 45)] .

                                +

                                This is a malformed url with a space [CST error at (2, 37) - (2, 45)] .

                                diff --git a/tests/test_whitespace.py b/tests/test_whitespace.py index fe1b88b..2086fe8 100644 --- a/tests/test_whitespace.py +++ b/tests/test_whitespace.py @@ -19,15 +19,15 @@ def test_one_word():
                                -
                                +
                                -

                                This should be a single word.

                                +

                                This should be a single word.

                                -

                                This should be a single word.

                                +

                                This should be a single word.

                                -

                                This should be a single word.

                                +

                                This should be a single word.

                                @@ -58,15 +58,15 @@ def test_one_word_with_shortcut():
                                -
                                +
                                -

                                This should be a single word.

                                +

                                This should be a single word.

                                -

                                This should be a single word.

                                +

                                This should be a single word.

                                -

                                This should be a single word.

                                +

                                This should be a single word.

                                @@ -96,17 +96,17 @@ def test_period_after():
                                -
                                +
                                -

                                Period after math \(2+2=4\).

                                +

                                Period after math \(2+2=4\).

                                -

                                Period after code - k=v +

                                Period after code + k=v .

                                -

                                Period after claim foo.

                                +

                                Period after claim foo.

                                @@ -136,17 +136,17 @@ def test_period_after_with_shortcut():
                                -
                                +
                                -

                                Period after math \(2+2=4\).

                                +

                                Period after math \(2+2=4\).

                                -

                                Period after code - k=v +

                                Period after code + k=v .

                                -

                                Period after claim foo.

                                +

                                Period after claim foo.

                                @@ -175,13 +175,13 @@ def test_separate_words():
                                -
                                +
                                -

                                Separate words.

                                +

                                Separate words.

                                -

                                Separate words.

                                +

                                Separate words.

                                @@ -210,13 +210,13 @@ def test_separate_words_with_shortcut():
                                -
                                +
                                -

                                Separate words.

                                +

                                Separate words.

                                -

                                Separate words.

                                +

                                Separate words.

                                @@ -245,11 +245,11 @@ def test_span_multiline_content_middle_of_line():
                                -
                                +
                                -

                                This is a paragraph with a span that takes multiple lines

                                +

                                This is a paragraph with a span that takes multiple lines

                                @@ -278,11 +278,11 @@ def test_span_multiline_content_beginning_of_line():
                                -
                                +
                                -

                                This is a paragraph with a span that takes multiple lines

                                +

                                This is a paragraph with a span that takes multiple lines

                                @@ -311,11 +311,11 @@ def test_span_multiline_content_beginning_of_line_with_shortcut():
                                -
                                +
                                -

                                This is a paragraph with a span that takes multiple lines

                                +

                                This is a paragraph with a span that takes multiple lines

                                @@ -344,11 +344,11 @@ def test_span_multiline_content_middle_of_line_with_shortcut():
                                -
                                +
                                -

                                This is a paragraph with a span that takes multiple lines

                                +

                                This is a paragraph with a span that takes multiple lines

                                @@ -375,11 +375,11 @@ def test_math_start_of_line():
                                -
                                +
                                -

                                This is a paragraph with \(2+2=4\) at the start of a line.

                                +

                                This is a paragraph with \(2+2=4\) at the start of a line.

                                @@ -406,11 +406,11 @@ def test_math_start_of_line_with_shortcut():
                                -
                                +
                                -

                                This is a paragraph with \(2+2=4\) at the start of a line.

                                +

                                This is a paragraph with \(2+2=4\) at the start of a line.

                                @@ -445,19 +445,19 @@ def test_table_tr():
                                -
                                +
                                -
                            foofoobarbarbazbaz
                            a:a:a2a2a3a3
                            b1b1b2b2b3b3
                            +
                            - + - + - + - + @@ -498,19 +498,19 @@ def test_table_trshort():
                            -
                            +
                            -
                            foofoobarbar
                            +
                            - + - + - + - + @@ -549,17 +549,17 @@ def test_ignore_space_within_inline():
                            -
                            +
                            -

                            Ignore space within inline.

                            +

                            Ignore space within inline.

                            -

                            Ignore space within inline.

                            +

                            Ignore space within inline.

                            -

                            Ignore space within inline.

                            +

                            Ignore space within inline.

                            -

                            Ignore space within inline.

                            +

                            Ignore space within inline.

                            @@ -592,17 +592,17 @@ def test_ignore_space_within_inline_with_shortcut():
                            -
                            +
                            -

                            Ignore space within inline.

                            +

                            Ignore space within inline.

                            -

                            Ignore space within inline.

                            +

                            Ignore space within inline.

                            -

                            Ignore space within. inline.

                            +

                            Ignore space within. inline.

                            -

                            Ignore space within. inline.

                            +

                            Ignore space within. inline.

                            @@ -645,21 +645,21 @@ def test_consecutive_lines_should_be_joined_by_spaces():
                            -
                            +
                            -

                            Consecutive lines should be joined by spaces.

                            +

                            Consecutive lines should be joined by spaces.

                            -

                            Consecutive lines should be joined by spaces.

                            +

                            Consecutive lines should be joined by spaces.

                            -

                            Consecutive lines should be joined by spaces.

                            +

                            Consecutive lines should be joined by spaces.

                            -

                            Consecutive lines should be joined by spaces.

                            +

                            Consecutive lines should be joined by spaces.

                            -

                            Consecutive lines should be joined by spaces.

                            +

                            Consecutive lines should be joined by spaces.

                            -

                            Consecutive lines should be joined by spaces.

                            +

                            Consecutive lines should be joined by spaces.

                            From 230b04a4c7831cfbcea804041299d45158960665 Mon Sep 17 00:00:00 2001 From: Leo Torres Date: Thu, 9 May 2024 20:49:01 +0200 Subject: [PATCH 04/11] add node id to each node in the tree at the end of the transform step --- rsm/nodes.py | 8 ++++++++ rsm/transformer.py | 7 +++++++ rsm/translator.py | 43 ++++++++++++++++++++++++++----------------- 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/rsm/nodes.py b/rsm/nodes.py index 2b39e9f..06ebbc4 100644 --- a/rsm/nodes.py +++ b/rsm/nodes.py @@ -168,6 +168,8 @@ def __init__( nonum: bool = False, reftext_template: str = "", ) -> None: + self.nodeid: str | None = None + """Node id - always exists (unlike label), automatically assigned, unique within the tree.""" self.label: str = label """Unique identifier.""" self.types: list[str] = types or [] @@ -726,6 +728,12 @@ def first_ancestor_of_type( ancestor = ancestor.parent return ancestor # the root node has parent None + def get_child_by_id(self, nodeid: int) -> Optional["Node"]: + for node in self.traverse(condition=lambda n: n.nodeid == nodeid): + return node + else: + return None + def replace_self(self, replacement: Union["Node", Iterable["Node"]]) -> None: """Replace this node in its parent's children. diff --git a/rsm/transformer.py b/rsm/transformer.py index 6e373b0..7ebe81f 100644 --- a/rsm/transformer.py +++ b/rsm/transformer.py @@ -142,6 +142,7 @@ def transform(self, tree: nodes.Manuscript) -> nodes.Manuscript: self.autonumber_nodes() self.make_toc() self.add_keywords_to_constructs() + self.assign_node_ids() return tree def collect_labels(self) -> None: @@ -340,3 +341,9 @@ def add_keywords_to_constructs(self) -> None: construct.types.append(kind) if kind not in {"then", "suffices", "claim", "claimblock", "qed"}: construct.types.append("assumption") + + def assign_node_ids(self) -> None: + nodeid = 0 + for node in self.tree.traverse(): + node.nodeid = nodeid + nodeid += 1 diff --git a/rsm/translator.py b/rsm/translator.py index cfa642b..f0a0705 100644 --- a/rsm/translator.py +++ b/rsm/translator.py @@ -127,21 +127,32 @@ class RSMTranslatorError(Exception): pass -def _make_tag(tag: str, id_: str, classes: Iterable, tabindex: int | None = None, **kwargs: Any) -> str: +def _make_tag( + tag: str, + id_: str, + classes: Iterable, + is_selectable: bool = False, + nodeid: int | None = None, + **kwargs: Any, +) -> str: text = f"<{tag}" if id_: text += f' id="{id_}"' if classes: classes = " ".join(classes) text += f' class="{classes}"' + tabindex = 0 if is_selectable else None + items = [] if kwargs or tabindex is not None: - text += " " - items = [] if kwargs: items += [f'{k}="{v}"' for k, v in kwargs.items() if v] if tabindex is not None: items += [f"tabindex={tabindex}"] - text += " ".join(items) + if nodeid is not None: + items += [f'data-nodeid="{nodeid}"'] + if items: + text += " " + text += " ".join(items) text += ">" return text @@ -225,6 +236,7 @@ def __init__( newline_inner: bool = True, newline_outer: bool = True, is_selectable: bool = False, + **kwargs, ): self.tag = tag self.content = content @@ -233,15 +245,13 @@ def __init__( self.newline_inner = newline_inner self.newline_outer = newline_outer self.is_selectable = is_selectable + self.custom_attrs = kwargs super().__init__() def make_text(self) -> str: outer = "\n" if self.newline_outer else "" inner = "\n" if self.newline_inner else "" - if self.is_selectable: - tag = _make_tag(self.tag, self.id, self.classes, tabindex=0) - else: - tag = _make_tag(self.tag, self.id, self.classes) + tag = _make_tag(self.tag, self.id, self.classes, self.is_selectable, **self.custom_attrs) return ( outer + tag + inner + self.content @@ -263,6 +273,7 @@ def __init__( newline_inner: bool = True, newline_outer: bool = True, is_selectable: bool = False, + **kwargs, ): self.tag = tag self.content = content @@ -271,15 +282,13 @@ def __init__( self.newline_inner = newline_inner self.newline_outer = newline_outer self.is_selectable = is_selectable + self.custom_attrs = kwargs super().__init__() def make_text(self) -> str: outer = "\n" if self.newline_outer else "" inner = "\n" if self.newline_inner else "" - if self.is_selectable: - tag = _make_tag(self.tag, self.id, self.classes, tabindex=0) - else: - tag = _make_tag(self.tag, self.id, self.classes) + tag = _make_tag(self.tag, self.id, self.classes, self.is_selectable, *self.custom_attrs) return outer + tag + inner + self.content def __repr__(self) -> str: @@ -299,10 +308,11 @@ def __init__( tag: str = "div", *, id: str = "", - classes: list = None, + classes: list | None = None, newline_inner: bool = True, newline_outer: bool = True, is_selectable: bool = False, + **kwargs, ): self.tag = tag self.id = id @@ -310,15 +320,13 @@ def __init__( self.newline_inner = newline_inner self.newline_outer = newline_outer self.is_selectable = is_selectable + self.custom_attrs = kwargs super().__init__() def make_text(self) -> str: outer = "\n" if self.newline_outer else "" inner = "\n" if self.newline_inner else "" - if self.is_selectable: - tag = _make_tag(self.tag, self.id, self.classes, tabindex=0) - else: - tag = _make_tag(self.tag, self.id, self.classes) + tag = _make_tag(self.tag, self.id, self.classes, self.is_selectable, **self.custom_attrs) return outer + tag + inner def make_deferred_text(self) -> str: @@ -353,6 +361,7 @@ def __init__( newline_inner=newline_inner, newline_outer=newline_outer, is_selectable=is_selectable, + nodeid=node.nodeid, ) def __repr__(self) -> str: From 6490f7bc7f6dc42053ed86ad3a72e905f565f27e Mon Sep 17 00:00:00 2001 From: Leo Torres Date: Thu, 9 May 2024 20:51:26 +0200 Subject: [PATCH 05/11] call a command that uses nodeid --- rsm/static/classes.js | 72 +++++++++++++++++++++++++++++++++++++++++-- rsm/static/onload.js | 1 - 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/rsm/static/classes.js b/rsm/static/classes.js index 28b9e60..3fd8916 100644 --- a/rsm/static/classes.js +++ b/rsm/static/classes.js @@ -16,15 +16,81 @@ export function setupClassInteractions() { }; }); - $(".tools-sidebar").mousedown(function(e) { + $("html").on("keyup", function(ev) { + const focused = document.activeElement; + const node_el = $(focused).find("[data-nodeid]"); + const nodeid = node_el.data("nodeid"); + + switch(ev.which) { + case 74: + console.log("J"); + lsp_ws.send(JSON.stringify({ + "jsonrpc" : "2.0", + "method" : "workspace/executeCommand", + "id": "command-next_sibling", + "params": { + "command": "next_sibling", + "arguments": [nodeid], + } + })) + break; + case 75: + console.log("K"); + lsp_ws.send(JSON.stringify({ + "jsonrpc" : "2.0", + "method" : "workspace/executeCommand", + "id": "command-prev_sibling", + "params": { + "command": "prev_sibling", + "arguments": [nodeid], + } + })) + break; + } + + + }); + + $(".manuscriptwrapper").on("focusin", function(e) { + const focused = document.activeElement; + const node_el = $(focused).find("[data-nodeid]"); + const nodeid = node_el.data("nodeid"); + if (!nodeid) return; + console.log(`asking for ${nodeid}`); + lsp_ws.send(JSON.stringify({ + "jsonrpc" : "2.0", + "method" : "workspace/executeCommand", + "id": "command-list_vars-999", + "params": { + "command": "list_vars", + "arguments": [nodeid], + } + })) + }); + + $(".tools-sidebar").on("mousedown", function(e) { // This element cannot receive focus via the mouse because it needs to access // the currently focused element - and clicking it would normally change the // focus to it. e.stopImmediatePropagation(); //stops event bubbling e.preventDefault(); //stops default browser action (focus) }).click(function() { - const src = $("body").children(".rsm-source"); - console.log(document.activeElement); + let wrapper = $(".manuscriptwrapper"); + if (wrapper.hasClass("manuscriptwrapper--narrow")) { + wrapper.removeClass("manuscriptwrapper--narrow"); + } + else { + wrapper.addClass("manuscriptwrapper--narrow"); + } + + let vars_list = $(".tools-sidebar .vars-list"); + if (vars_list.hasClass("hide")) { + vars_list.removeClass("hide"); + } + else { + vars_list.addClass("hide"); + + } }); $(".handrail").mouseleave(function () { diff --git a/rsm/static/onload.js b/rsm/static/onload.js index 5ad2909..47f3be2 100644 --- a/rsm/static/onload.js +++ b/rsm/static/onload.js @@ -39,7 +39,6 @@ export function onload(path = "/static/") { }); lsp_ws = new WebSocket("ws://127.0.0.1:1234"); - lsp_ws.onmessage = function(event) {console.log(`[message] Data received from server: ${event.data}`)}; lsp_ws.onerror = function(error) {console.log(`[error]`)}; lsp_ws.onclose = function(event) { if (event.wasClean) { From 101a1c016b6dc53bac8fa8a21d0b38801a279b3a Mon Sep 17 00:00:00 2001 From: Leo Torres Date: Thu, 9 May 2024 20:51:54 +0200 Subject: [PATCH 06/11] flesh out the tools sidebar and accompanying css --- rsm/static/onload.js | 17 ++++++++++++ rsm/static/rsm.css | 52 +++++++++++++++++++++++++++--------- rsm/static/rsm.scss | 60 ++++++++++++++++++++++++++++++++++++------ rsm/static/tooltips.js | 4 --- rsm/translator.py | 10 +++++-- 5 files changed, 116 insertions(+), 27 deletions(-) diff --git a/rsm/static/onload.js b/rsm/static/onload.js index 47f3be2..06ff291 100644 --- a/rsm/static/onload.js +++ b/rsm/static/onload.js @@ -47,6 +47,23 @@ export function onload(path = "/static/") { console.log('[close] Connection died'); } }; + lsp_ws.onmessage = function(event) { + console.log(`[message] Data received from server: ${event.data}`); + const json = JSON.parse(event.data); + if (("id" in json) && (typeof(json.id) === "string") && json.id.startsWith("command-list_vars")) { + let content = ""; + const vars_list = $(".vars-list-ul"); + vars_list.empty(); + for (let nodeid of json.result) { + content = $(`[data-nodeid=${nodeid}]`).html(); + content = `
                          1. ${content}
                          2. `; + vars_list.append(content); + } + }; + if (("id" in json) && (typeof(json.id) === "string") && json.id.startsWith("command-next_sibling")) { + console.log(`move focus to ${json.result}`) + }; + }; lsp_ws.onopen = function(e) { console.log("[open] Connection established"); lsp_ws.send(JSON.stringify({ diff --git a/rsm/static/rsm.css b/rsm/static/rsm.css index 4e3b4c8..2268c75 100644 --- a/rsm/static/rsm.css +++ b/rsm/static/rsm.css @@ -51,7 +51,24 @@ .tools-sidebar { position: fixed; top: calc(var(--h1-size)); - right: 1em; } + right: 1em; + max-width: 18em; + display: flex; + flex-direction: row-reverse; } + .tools-sidebar .vars-list { + max-width: 85%; + box-shadow: 0 0 8px 4px #eee; + padding: 1em; + border-radius: 10px; + margin: auto; + font-size: 80%; + overflow-x: scroll; } + .tools-sidebar .vars-list-ul { + padding-inline-start: 1em; } + .tools-sidebar .tools-sidebar__btn:hover > svg { + background: var(--gray-900); + color: var(--gray-200); + cursor: pointer; } .manuscriptwrapper { border-radius: 8px; @@ -60,6 +77,9 @@ overflow: hidden; padding: 0 var(--side-padding) 0 var(--side-padding); } +.manuscriptwrapper--narrow { + margin: 2.5em 15em 2.5em auto; } + .manuscriptwrapper.embedded { margin: 0; padding-inline: 2.5rem 2.5rem; @@ -110,7 +130,7 @@ .manuscriptwrapper ul.contents ul.itemize { list-style: none; margin-block-end: 0; - padding-inline-start: 2rem; } + padding-inline-start: 1rem; } .manuscriptwrapper p:has(+ .mathblock) { margin-block-end: 0; } .manuscriptwrapper div.statement p { @@ -186,6 +206,8 @@ padding: 0 0 0 var(--handrail-offset); } .manuscriptwrapper .handrail .proof__title, .manuscriptwrapper .handrail .theorem__title { padding-block: 1rem; } + .manuscriptwrapper .handrail .theorem__title { + border-bottom: var(--gray-200) solid 1px; } .manuscriptwrapper .handrail--hug > p:not(.topic-title), .manuscriptwrapper .handrail--hug > .proof__title { padding-block: 0; } .manuscriptwrapper .handrail--offset { @@ -272,21 +294,21 @@ transform: translateX(-100%); } .manuscriptwrapper .handrail.handrail--hug > .handrail__btn-container { top: 0; } - .manuscriptwrapper .abstract div.handrail > .handrail__btn-container, - .manuscriptwrapper .toc div.handrail > .handrail__btn-container { + .manuscriptwrapper .abstract div.handrail:first-of-type > .handrail__btn-container, + .manuscriptwrapper .toc div.handrail:first-of-type > .handrail__btn-container { top: calc(var(--h3-size)/2 + (var(--header-line-height)*var(--h3-size) - var(--body-line-height)*1rem)/2); } - .manuscriptwrapper div.theorem > .handrail > .handrail__btn-container, - .manuscriptwrapper div.proof > .handrail > .handrail__btn-container { + .manuscriptwrapper div.theorem > .handrail:first-of-type > .handrail__btn-container, + .manuscriptwrapper div.proof > .handrail:first-of-type > .handrail__btn-container { top: 1rem; } - .manuscriptwrapper section.level-1 > .handrail > .handrail__btn-container { + .manuscriptwrapper section.level-1 > .handrail:first-of-type > .handrail__btn-container { top: calc(var(--h1-size)/2 + (var(--header-line-height)*var(--h1-size) - var(--body-line-height)*1rem)/2); } - .manuscriptwrapper section.level-2 > .handrail > .handrail__btn-container { + .manuscriptwrapper section.level-2 > .handrail:first-of-type > .handrail__btn-container { top: calc(var(--h2-size)/2 + (var(--header-line-height)*var(--h2-size) - var(--body-line-height)*1rem)/2); } - .manuscriptwrapper section.level-3 > .handrail > .handrail__btn-container { + .manuscriptwrapper section.level-3 > .handrail:first-of-type > .handrail__btn-container { top: calc(var(--h3-size)/2 + (var(--header-line-height)*var(--h3-size) - var(--body-line-height)*1rem)/2); } - .manuscriptwrapper section.level-4 > .handrail > .handrail__btn-container { + .manuscriptwrapper section.level-4 > .handrail:first-of-type > .handrail__btn-container { top: calc(var(--h4-size)/2 + (var(--header-line-height)*var(--h4-size) - var(--body-line-height)*1rem)/2); } - .manuscriptwrapper section.level-5 > .handrail > .handrail__btn-container { + .manuscriptwrapper section.level-5 > .handrail:first-of-type > .handrail__btn-container { top: calc(var(--h5-size)/2 + (var(--header-line-height)*var(--h5-size) - var(--body-line-height)*1rem)/2); } .manuscriptwrapper .keyword { color: var(--keyword-blue); @@ -313,8 +335,8 @@ display: none; color: var(--med-gray); position: absolute; - left: calc(var(--handrail-offset) * 0.38); - transform: translateX(-100%) translateX(-2em); + right: 0; + transform: translateX(100%) translateX(2em); font-family: 'Inconsolata', monospace; } .manuscriptwrapper .step.last { padding-block-end: 1rem; } @@ -517,6 +539,8 @@ .manuscriptwrapper { box-shadow: 0 0 8px 10px #eee; margin: 2.5em auto; } + .manuscriptwrapper--narrow { + margin: 2.5em 20em 2.5em auto; } a.bibitem-doi { float: right; } } @@ -530,6 +554,8 @@ --h6-size: 1.000rem; --side-padding: 1.5em; --font-size: 93.75%; } + .manuscriptwrapper--narrow { + margin: 2.5em 15em 2.5em auto; } .options { left: 0; right: unset; } diff --git a/rsm/static/rsm.scss b/rsm/static/rsm.scss index d29e8d1..00328d0 100644 --- a/rsm/static/rsm.scss +++ b/rsm/static/rsm.scss @@ -66,8 +66,34 @@ position: fixed; top: calc(var(--h1-size)); right: 1em; + max-width: 18em; + display: flex; + flex-direction: row-reverse; + + .vars-list { + max-width: 85%; + box-shadow: 0 0 8px 4px #eee; + padding: 1em; + border-radius: 10px; + margin: auto; + font-size: 80%; + overflow-x: scroll; + } + + .vars-list-ul { + padding-inline-start: 1em; + } + + .tools-sidebar__btn:hover > svg { + background: var(--gray-900); + color: var(--gray-200); + cursor: pointer; + } + } + + .manuscriptwrapper { border-radius: 8px; margin: 0 auto; @@ -76,6 +102,10 @@ padding: 0 var(--side-padding) 0 var(--side-padding); } +.manuscriptwrapper--narrow { + margin: 2.5em 15em 2.5em auto; +} + .manuscriptwrapper.embedded { margin: 0; padding-inline: 2.5rem 2.5rem; @@ -135,7 +165,7 @@ ul.itemize { list-style: none; margin-block-end: 0; - padding-inline-start: 2rem; + padding-inline-start: 1rem; } } @@ -250,6 +280,11 @@ & .proof__title, .theorem__title { padding-block: 1rem; + + } + + & .theorem__title { + border-bottom: var(--gray-200) solid 1px; } &--hug > p:not(.topic-title), &--hug > .proof__title { @@ -368,18 +403,18 @@ top: 0; } - .abstract div.handrail > .handrail__btn-container, - .toc div.handrail > .handrail__btn-container { + .abstract div.handrail:first-of-type > .handrail__btn-container, + .toc div.handrail:first-of-type > .handrail__btn-container { top: calc(var(--h3-size)/2 + (var(--header-line-height)*var(--h3-size) - var(--body-line-height)*1rem)/2); } - div.theorem > .handrail > .handrail__btn-container, - div.proof > .handrail > .handrail__btn-container { + div.theorem > .handrail:first-of-type > .handrail__btn-container, + div.proof > .handrail:first-of-type > .handrail__btn-container { top: 1rem; } @for $i from 1 through 5 { - section.level-#{$i} > .handrail > .handrail__btn-container { + section.level-#{$i} > .handrail:first-of-type > .handrail__btn-container { top: calc(var(--h#{$i}-size)/2 + (var(--header-line-height)*var(--h#{$i}-size) - var(--body-line-height)*1rem)/2); } } @@ -440,8 +475,9 @@ display: none; color: var(--med-gray); position: absolute; - left: calc(var(--handrail-offset) * 0.38); - transform: translateX(-100%) translateX(-2em); + // left: calc(var(--handrail-offset) * 0.38); + right: 0; + transform: translateX(100%) translateX(2em); font-family: 'Inconsolata', monospace; } @@ -814,6 +850,10 @@ margin: 2.5em auto; } + .manuscriptwrapper--narrow { + margin: 2.5em 20em 2.5em auto; + } + a.bibitem-doi { float: right; } @@ -834,6 +874,10 @@ --font-size: 93.75%; } + .manuscriptwrapper--narrow { + margin: 2.5em 15em 2.5em auto; + } + .options { left: 0; right: unset; diff --git a/rsm/static/tooltips.js b/rsm/static/tooltips.js index c9565e6..829e111 100644 --- a/rsm/static/tooltips.js +++ b/rsm/static/tooltips.js @@ -38,10 +38,6 @@ export function createTooltips() { } else if (tag == "SECTION") { let clone = $(target).clone(); clone.children().slice(2).remove(); - // clone.children().each(function () {$(this).css('transform', 'scale(0.75)');}); - // clone.children().each(function () {$(this).attr('onload', 'this.width*=0.25;');}); - // clone.css('transform', 'scale(0.75)'); - // clone.attr('onload', 'this.width*=0.25;') clone.css('font-size', '0.7rem'); content = clone.html(); } else if (tag == "A") { diff --git a/rsm/translator.py b/rsm/translator.py index f0a0705..f6c33c9 100644 --- a/rsm/translator.py +++ b/rsm/translator.py @@ -1174,7 +1174,13 @@ def _replace_cmd_with_handrails(self, cmd, include_content=False): ) def _make_tools_sidebar(self): - return AppendText(text=f'
                            {self.svg["vars"]}
                            ') + html = f""" +
                            +
                            {self.svg["vars"]}
                            +
                            • Nothing here...
                            +
                            + """ + return AppendText(text=html) def _make_source_div(self): return AppendText(text=f'
                            {self.tree.src}
                            ') @@ -1184,7 +1190,7 @@ def visit_manuscript(self, node: nodes.Manuscript) -> EditCommand: if node.title: batch = self._replace_batch_with_handrails(4, batch) if self.sidebar: - batch.items.insert(1, self._make_tools_sidebar()) + batch.items.insert(2, self._make_tools_sidebar()) if self.add_source: batch.items.insert(1, self._make_source_div()) return batch From f52812bd2b85e55a2e880246ad83ff0366a8eeba Mon Sep 17 00:00:00 2001 From: Leo Torres Date: Thu, 9 May 2024 21:05:01 +0200 Subject: [PATCH 07/11] update grammar --- tree-sitter-rsm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tree-sitter-rsm b/tree-sitter-rsm index 4e420b5..eb7fd47 160000 --- a/tree-sitter-rsm +++ b/tree-sitter-rsm @@ -1 +1 @@ -Subproject commit 4e420b557a3d30ce9ddf1e040a21bdbd29a38c3d +Subproject commit eb7fd479f1299bc8a14dc9c1e1b0a10824c21c3c From a41fd3b99542060c69187c172b2272608db2a35b Mon Sep 17 00:00:00 2001 From: Leo Torres Date: Thu, 9 May 2024 21:06:19 +0200 Subject: [PATCH 08/11] remove unnecessary line --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.py b/build.py index 139df34..60d22d6 100644 --- a/build.py +++ b/build.py @@ -44,7 +44,7 @@ def build(_: Any): # one argument is passed by poetry but we don't need it # watch out: tree-sitter might change this dir inadvertently... # run(f"cp ~/.tree-sitter/bin/{fn} rsm/", cwd=".") run(f"cp build/{fn} ../rsm/") - run(f"cp build/{fn} /Users/leo.torres/.emacs.d/tree-sitter/libtree-sitter-rsm.so") # for emacs + # run(f"cp build/{fn} /Users/leo.torres/.emacs.d/tree-sitter/libtree-sitter-rsm.so") # for emacs if __name__ == "__main__": From 18f4ae89d8245447f3f95a2b02362b9664a4e939 Mon Sep 17 00:00:00 2001 From: Leo Torres Date: Thu, 9 May 2024 21:17:57 +0200 Subject: [PATCH 09/11] pin node version on all machines --- .github/workflows/test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c5ed512..29d9380 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,6 +27,11 @@ jobs: with: submodules: true + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: From 3772d27d8c2164f007064e365c94b258bed8370c Mon Sep 17 00:00:00 2001 From: Leo Torres Date: Thu, 9 May 2024 22:28:00 +0200 Subject: [PATCH 10/11] update --- tree-sitter-rsm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tree-sitter-rsm b/tree-sitter-rsm index eb7fd47..0c7bc93 160000 --- a/tree-sitter-rsm +++ b/tree-sitter-rsm @@ -1 +1 @@ -Subproject commit eb7fd479f1299bc8a14dc9c1e1b0a10824c21c3c +Subproject commit 0c7bc938aaccdabe2381d0e2ac735972bc1627a1 From ae3c702421fd8de966794c96e6b5b0170bd6bb71 Mon Sep 17 00:00:00 2001 From: Leo Torres Date: Thu, 9 May 2024 22:38:33 +0200 Subject: [PATCH 11/11] windows is havign problems so bye --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 29d9380..a15b340 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: - os: [ubuntu, macos, windows] + os: [ubuntu, macos] python-version: ['3.9', '3.10', '3.11'] steps:
                            foofoobarbar