<commit_before>import { expect } from 'chai'
import Up from '../../../../index'
import { insideDocumentAndParagraph } from '../../Helpers'
import { DocumentNode } from '../../../../SyntaxNodes/DocumentNode'
import { ParagraphNode } from '../../../../SyntaxNodes/ParagraphNode'
import { RevisionInsertionNode } from '../../../../SyntaxNodes/RevisionInsertionNode'
import { RevisionDeletionNode } from '../../../../SyntaxNodes/RevisionDeletionNode'
import { PlainTextNode } from '../../../../SyntaxNodes/PlainTextNode'
import { LinkNode } from '../../../../SyntaxNodes/LinkNode'
import { EmphasisNode } from '../../../../SyntaxNodes/EmphasisNode'
import { StressNode } from '../../../../SyntaxNodes/StressNode'
import { ParenthesizedNode } from '../../../../SyntaxNodes/ParenthesizedNode'
import { SquareBracketedNode } from '../../../../SyntaxNodes/SquareBracketedNode'
import { FootnoteNode } from '../../../../SyntaxNodes/FootnoteNode'


context('Most inline conventions are not applied if they have no content', () => {
  context('Specifically:', () => {
    specify('Spoilers', () => {
      expect(Up.toAst('[SPOILER:]')).to.eql(
        insideDocumentAndParagraph([
          new SquareBracketedNode([
            new PlainTextNode('SPOILER:')
          ])
        ]))
    })

    specify('NSFW', () => {
      expect(Up.toAst('[NSFW:]')).to.eql(
        insideDocumentAndParagraph([
          new SquareBracketedNode([
            new PlainTextNode('NSFW:')
          ])
        ]))
    })

    specify('NSFL', () => {
      expect(Up.toAst('[NSFL:]')).to.eql(
        insideDocumentAndParagraph([
          new SquareBracketedNode([
            new PlainTextNode('NSFL:')
          ])
        ]))
    })

    specify('Footnotes', () => {
      expect(Up.toAst('(^)')).to.eql(
        insideDocumentAndParagraph([
          new ParenthesizedNode([
            new PlainTextNode('^')
          ])
        ]))
    })

    specify('Parentheses', () => {
      expect(Up.toAst('()')).to.eql(
        insideDocumentAndParagraph([
          new PlainTextNode('()')
        ]))
    })

    specify('Square brackets', () => {
      expect(Up.toAst('[]')).to.eql(
        insideDocumentAndParagraph([
          new PlainTextNode('[]')
        ]))
    })

    specify('Actions', () => {
      expect(Up.toAst('{}')).to.eql(
        insideDocumentAndParagraph([
          new PlainTextNode('{}')
        ]))
    })

    specify('Revision insertion', () => {
      // If the revision insertion delimiters were alone on a line, they would be interpreted as a section separator streak. 
      expect(Up.toAst('Spiders.++++')).to.eql(
        insideDocumentAndParagraph([
          new PlainTextNode('Spiders.++++')
        ])
      )
    })

    specify('Revision insertion', () => {
      // If the revision deletion delimiters were alone on a line, they would be interpreted as a section separator streak.
      expect(Up.toAst('Spiders.~~~~')).to.eql(
        insideDocumentAndParagraph([
          new PlainTextNode('Spiders.~~~~')
        ])
      )
    })


    context('Of those conventions, only the revision conventions apply when containing only unescaped whitespace.', () => {
      specify('Revision insertion applies.', () => {
        expect(Up.toAst('no++ ++one')).to.eql(
          insideDocumentAndParagraph([
            new PlainTextNode('no'),
            new RevisionInsertionNode([
              new PlainTextNode(' ')
            ]),
            new PlainTextNode('one')
          ])
        )
      })

      specify('Revision deletion applies.', () => {
        expect(Up.toAst('e~~ ~~mail')).to.eql(
          insideDocumentAndParagraph([
            new PlainTextNode('e'),
            new RevisionDeletionNode([
              new PlainTextNode(' ')
            ]),
            new PlainTextNode('mail')
          ])
        )
      })


      context("These don't:", () => {
        specify('Spoilers', () => {
          expect(Up.toAst('[SPOILER:  \t  \t ]')).to.eql(
            insideDocumentAndParagraph([
              new PlainTextNode('[SPOILER:  \t  \t ]')
            ]))
        })

        specify('NSFW', () => {
          expect(Up.toAst('[NSFW:  \t  \t ]')).to.eql(
            insideDocumentAndParagraph([
              new PlainTextNode('[NSFW:  \t  \t ]')
            ]))
        })

        specify('NSFL', () => {
          expect(Up.toAst('[NSFL:  \t  \t ]')).to.eql(
            insideDocumentAndParagraph([
              new PlainTextNode('[NSFL:  \t  \t ]')
            ]))
        })

    specify('Footnotes', () => {
      expect(Up.toAst('(^  \t \t )')).to.eql(
        insideDocumentAndParagraph([
          new ParenthesizedNode([
            new PlainTextNode('(^  \t \t )')
          ])
        ]))
    })

        specify('Parentheses', () => {
          expect(Up.toAst('(  \t  \t )')).to.eql(
            insideDocumentAndParagraph([
              new PlainTextNode('(  \t  \t )')
            ]))
        })

        specify('Square brackets', () => {
          expect(Up.toAst('[  \t  \t ]')).to.eql(
            insideDocumentAndParagraph([
              new PlainTextNode('[  \t  \t ]')
            ]))
        })

        specify('Actions', () => {
          expect(Up.toAst('{  \t  \t }')).to.eql(
            insideDocumentAndParagraph([
              new PlainTextNode('{  \t  \t }')
            ]))
        })

        specify('Furthermore, these conventions produce no syntax nodes if they contain only whitespace and other empty "void" inline conventions', () => {
          expect(Up.toAst('[NSFL:  \t [SPOILER: {} [NSFW: ++++   ]  ] \t ]')).to.eql(new DocumentNode())
        })
      })
    })
  })


  context('Links are handled a bit differently, because they also have a URL to worry about.', () => {
    describe('An otherwwise-valid link with an empty URL', () => {
      it("does not produce a link. Instead, its content produces the appropriate bracketed convention, and its empty bracketed URL is treated as normal empty brackets", () => {
        expect(Up.toAst('[*Yggdra Union*][]')).to.be.eql(
          insideDocumentAndParagraph([
            new SquareBracketedNode([
              new EmphasisNode([
                new PlainTextNode('Yggdra Union')
              ])
            ]),
            new PlainTextNode('[]')
          ]))
      })
    })


    describe('An otherwise valid link with a blank URL', () => {
      it("does not produce a link. Instead, its content produces the appropriate bracketed convention, and its blank bracketed URL is treated as normal blank brackets", () => {
        expect(Up.toAst('[*Yggdra Union*]( \t )')).to.be.eql(
          insideDocumentAndParagraph([
            new SquareBracketedNode([
              new EmphasisNode([
                new PlainTextNode('Yggdra Union')
              ])
            ]),
            new PlainTextNode('( \t )')
          ]))
      })
    })


    describe('An otherwise-valid link with no content', () => {
      it("does not produce a link. Instead, its content is treated as normal empty brackets, and its bracketed URL is treated as the appropriate bracketed convention", () => {
        expect(Up.toAst('()[https://google.com]')).to.be.eql(
          insideDocumentAndParagraph([
            new PlainTextNode('()'),
            new SquareBracketedNode([
              new LinkNode([
                new PlainTextNode('https://google.com')
              ], 'https://google.com')
            ])
          ]))
      })
    })


    describe('An otherwise-valid link with blank content', () => {
      it("does not produce a link. Instead, its content is treated as normal blank brackets, and its bracketed URL is treated as the appropriate bracketed convention", () => {
        expect(Up.toAst('[ \t ](https://google.com)')).to.be.eql(
          insideDocumentAndParagraph([
            new PlainTextNode('[ \t ]'),
            new ParenthesizedNode([
              new LinkNode([
                new PlainTextNode('https://google.com')
              ], 'https://google.com')
            ])
          ]))
      })
    })


    describe('A link with blank escaped content', () => {<commit_msg>Remove now-invalid test<commit_after>import { expect } from 'chai'
import Up from '../../../../index'
import { insideDocumentAndParagraph } from '../../Helpers'
import { DocumentNode } from '../../../../SyntaxNodes/DocumentNode'
import { ParagraphNode } from '../../../../SyntaxNodes/ParagraphNode'
import { RevisionInsertionNode } from '../../../../SyntaxNodes/RevisionInsertionNode'
import { RevisionDeletionNode } from '../../../../SyntaxNodes/RevisionDeletionNode'
import { PlainTextNode } from '../../../../SyntaxNodes/PlainTextNode'
import { LinkNode } from '../../../../SyntaxNodes/LinkNode'
import { EmphasisNode } from '../../../../SyntaxNodes/EmphasisNode'
import { StressNode } from '../../../../SyntaxNodes/StressNode'
import { ParenthesizedNode } from '../../../../SyntaxNodes/ParenthesizedNode'
import { SquareBracketedNode } from '../../../../SyntaxNodes/SquareBracketedNode'
import { FootnoteNode } from '../../../../SyntaxNodes/FootnoteNode'


context('Most inline conventions are not applied if they have no content', () => {
  context('Specifically:', () => {
    specify('Spoilers', () => {
      expect(Up.toAst('[SPOILER:]')).to.eql(
        insideDocumentAndParagraph([
          new SquareBracketedNode([
            new PlainTextNode('SPOILER:')
          ])
        ]))
    })

    specify('NSFW', () => {
      expect(Up.toAst('[NSFW:]')).to.eql(
        insideDocumentAndParagraph([
          new SquareBracketedNode([
            new PlainTextNode('NSFW:')
          ])
        ]))
    })

    specify('NSFL', () => {
      expect(Up.toAst('[NSFL:]')).to.eql(
        insideDocumentAndParagraph([
          new SquareBracketedNode([
            new PlainTextNode('NSFL:')
          ])
        ]))
    })

    specify('Footnotes', () => {
      expect(Up.toAst('(^)')).to.eql(
        insideDocumentAndParagraph([
          new ParenthesizedNode([
            new PlainTextNode('^')
          ])
        ]))
    })

    specify('Parentheses', () => {
      expect(Up.toAst('()')).to.eql(
        insideDocumentAndParagraph([
          new PlainTextNode('()')
        ]))
    })

    specify('Square brackets', () => {
      expect(Up.toAst('[]')).to.eql(
        insideDocumentAndParagraph([
          new PlainTextNode('[]')
        ]))
    })

    specify('Actions', () => {
      expect(Up.toAst('{}')).to.eql(
        insideDocumentAndParagraph([
          new PlainTextNode('{}')
        ]))
    })

    specify('Revision insertion', () => {
      // If the revision insertion delimiters were alone on a line, they would be interpreted as a section separator streak. 
      expect(Up.toAst('Spiders.++++')).to.eql(
        insideDocumentAndParagraph([
          new PlainTextNode('Spiders.++++')
        ])
      )
    })

    specify('Revision insertion', () => {
      // If the revision deletion delimiters were alone on a line, they would be interpreted as a section separator streak.
      expect(Up.toAst('Spiders.~~~~')).to.eql(
        insideDocumentAndParagraph([
          new PlainTextNode('Spiders.~~~~')
        ])
      )
    })


    context('Of those conventions, only the revision conventions apply when containing only unescaped whitespace.', () => {
      specify('Revision insertion applies.', () => {
        expect(Up.toAst('no++ ++one')).to.eql(
          insideDocumentAndParagraph([
            new PlainTextNode('no'),
            new RevisionInsertionNode([
              new PlainTextNode(' ')
            ]),
            new PlainTextNode('one')
          ])
        )
      })

      specify('Revision deletion applies.', () => {
        expect(Up.toAst('e~~ ~~mail')).to.eql(
          insideDocumentAndParagraph([
            new PlainTextNode('e'),
            new RevisionDeletionNode([
              new PlainTextNode(' ')
            ]),
            new PlainTextNode('mail')
          ])
        )
      })


      context("These don't:", () => {
        specify('Spoilers', () => {
          expect(Up.toAst('[SPOILER:  \t  \t ]')).to.eql(
            insideDocumentAndParagraph([
              new PlainTextNode('[SPOILER:  \t  \t ]')
            ]))
        })

        specify('NSFW', () => {
          expect(Up.toAst('[NSFW:  \t  \t ]')).to.eql(
            insideDocumentAndParagraph([
              new PlainTextNode('[NSFW:  \t  \t ]')
            ]))
        })

        specify('NSFL', () => {
          expect(Up.toAst('[NSFL:  \t  \t ]')).to.eql(
            insideDocumentAndParagraph([
              new PlainTextNode('[NSFL:  \t  \t ]')
            ]))
        })

        specify('Footnotes', () => {
          expect(Up.toAst('(^  \t \t )')).to.eql(
            insideDocumentAndParagraph([
              new ParenthesizedNode([
                new PlainTextNode('(^  \t \t )')
              ])
            ]))
        })

        specify('Parentheses', () => {
          expect(Up.toAst('(  \t  \t )')).to.eql(
            insideDocumentAndParagraph([
              new PlainTextNode('(  \t  \t )')
            ]))
        })

        specify('Square brackets', () => {
          expect(Up.toAst('[  \t  \t ]')).to.eql(
            insideDocumentAndParagraph([
              new PlainTextNode('[  \t  \t ]')
            ]))
        })

        specify('Actions', () => {
          expect(Up.toAst('{  \t  \t }')).to.eql(
            insideDocumentAndParagraph([
              new PlainTextNode('{  \t  \t }')
            ]))
        })
      })
    })
  })


  context('Links are handled a bit differently, because they also have a URL to worry about.', () => {
    describe('An otherwwise valid link with an empty URL', () => {
      it("does not produce a link. Instead, its content produces the appropriate bracketed convention, and its empty bracketed URL is treated as normal empty brackets", () => {
        expect(Up.toAst('[*Yggdra Union*][]')).to.be.eql(
          insideDocumentAndParagraph([
            new SquareBracketedNode([
              new EmphasisNode([
                new PlainTextNode('Yggdra Union')
              ])
            ]),
            new PlainTextNode('[]')
          ]))
      })
    })


    describe('An otherwise valid link with a blank URL', () => {
      it("does not produce a link. Instead, its content produces the appropriate bracketed convention, and its blank bracketed URL is treated as normal blank brackets", () => {
        expect(Up.toAst('[*Yggdra Union*]( \t )')).to.be.eql(
          insideDocumentAndParagraph([
            new SquareBracketedNode([
              new EmphasisNode([
                new PlainTextNode('Yggdra Union')
              ])
            ]),
            new PlainTextNode('( \t )')
          ]))
      })
    })


    describe('An otherwise valid link with no content', () => {
      it("does not produce a link. Instead, its content is treated as normal empty brackets, and its bracketed URL is treated as the appropriate bracketed convention", () => {
        expect(Up.toAst('()[https://google.com]')).to.be.eql(
          insideDocumentAndParagraph([
            new PlainTextNode('()'),
            new SquareBracketedNode([
              new LinkNode([
                new PlainTextNode('https://google.com')
              ], 'https://google.com')
            ])
          ]))
      })
    })


    describe('An otherwise-valid link with blank content', () => {
      it("does not produce a link. Instead, its content is treated as normal blank brackets, and its bracketed URL is treated as the appropriate bracketed convention", () => {
        expect(Up.toAst('[ \t ](https://google.com)')).to.be.eql(
          insideDocumentAndParagraph([
            new PlainTextNode('[ \t ]'),
            new ParenthesizedNode([
              new LinkNode([
                new PlainTextNode('https://google.com')
              ], 'https://google.com')
            ])
          ]))
      })
    })


    describe('An otherwise valid link with blank escaped content', () => {
{'fraction_non_alphanumeric': 0.16422269168634274, 'fraction_numerical': 0.0, 'mean_word_length': 1.901568415359654, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 68, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2639052', 'n_tokens_mistral': 4735, 'n_tokens_neox': 4500, 'n_words': 983}