<commit_before>
import { expect } from 'chai'
import * as Up from '../../index'
import { insideDocumentAndParagraph } from './Helpers'
import { LinkNode } from '../../SyntaxNodes/LinkNode'
import { DocumentNode } from '../../SyntaxNodes/DocumentNode'
import { PlainTextNode } from '../../SyntaxNodes/PlainTextNode'
import { EmphasisNode } from '../../SyntaxNodes/EmphasisNode'
import { StressNode } from '../../SyntaxNodes/StressNode'
import { InlineCodeNode } from '../../SyntaxNodes/InlineCodeNode'
import { RevisionInsertionNode } from '../../SyntaxNodes/RevisionInsertionNode'
import { RevisionDeletionNode } from '../../SyntaxNodes/RevisionDeletionNode'
import { SpoilerNode } from '../../SyntaxNodes/SpoilerNode'
import { PlaceholderFootnoteReferenceNode } from '../../SyntaxNodes/PlaceholderFootnoteReferenceNode'
import { ParagraphNode } from '../../SyntaxNodes/ParagraphNode'
import { SectionSeparatorNode } from '../../SyntaxNodes/SectionSeparatorNode'
import { FootnoteReferenceNode } from '../../SyntaxNodes/FootnoteReferenceNode'
import { FootnoteBlockNode } from '../../SyntaxNodes/FootnoteBlockNode'
import { Footnote } from '../../SyntaxNodes/Footnote'


describe('In a paragraph, text surrounded by 2 parentheses', () => {
  it('produces a footnote reference node. This node references a footnote within a footnote block node after the paragraph', () => {
    expect(Up.toAst("I don't eat cereal. ((Well, I do, but I pretend not to.)) Never have.")).to.be.eql(
      new DocumentNode([
        new ParagraphNode([
          new PlainTextNode("I don't eat cereal."),
          new FootnoteReferenceNode(1),
          new PlainTextNode(" Never have."),
        ]),
        new FootnoteBlockNode([
          new Footnote([
            new PlainTextNode('Well, I do, but I pretend not to.')
          ], 1)
        ])
      ]))
  })
})


describe('A footnote reference', () => {
  it('is evaluated for other conventions', () => {
    expect(Up.toAst("I don't eat cereal. ((Well, I *do*, but I pretend not to.)) Never have.")).to.be.eql(
      new DocumentNode([
        new ParagraphNode([
          new PlainTextNode("I don't eat cereal."),
          new FootnoteReferenceNode(1),
          new PlainTextNode(" Never have."),
        ]),
        new FootnoteBlockNode([
          new Footnote([
            new PlainTextNode('Well, I '),
            new EmphasisNode([
              new PlainTextNode('do')
            ]),
            new PlainTextNode(', but I pretend not to.')
          ], 1)
        ])
      ]))
  })

  it('can contain other footnote references, which produce additional footnotes in the same footnote block', () => {
    expect(Up.toAst("Me? I'm totally normal. ((That said, I don't eat cereal. ((Well, I *do*, but I pretend not to.)) Never have.)) Really.")).to.be.eql(
      new DocumentNode([
        new ParagraphNode([
          new PlainTextNode("Me? I'm totally normal."),
          new FootnoteReferenceNode(1),
          new PlainTextNode(" Really."),
        ]),
        new FootnoteBlockNode([
          new Footnote([
            new PlainTextNode("That said, I don't eat cereal."),
            new FootnoteReferenceNode(2),
            new PlainTextNode(" Never have."),
          ], 1),
          new Footnote([
            new PlainTextNode('Well, I '),
            new EmphasisNode([
              new PlainTextNode('do')
            ]),
            new PlainTextNode(', but I pretend not to.'),
          ], 2)
        ])
      ]))
  })
})


describe('Nested footnote references', () => {
  it('produce footnotes that appear after any footnotes produced by non-nested references', () => {
    expect(Up.toAst("Me? I'm totally normal. ((That said, I don't eat cereal. ((Well, I *do*, but I pretend not to.)) Never have.)) Really. ((Probably.))")).to.be.eql(
      new DocumentNode([
        new ParagraphNode([
          new PlainTextNode("Me? I'm totally normal."),
          new FootnoteReferenceNode(1),
          new PlainTextNode(" Really."),
          new FootnoteReferenceNode(2),
        ]),
        new FootnoteBlockNode([
          new Footnote([
            new PlainTextNode("That said, I don't eat cereal."),
            new FootnoteReferenceNode(3),
            new PlainTextNode(" Never have."),
          ], 1),
          new Footnote([
            new PlainTextNode("Probably."),
          ], 2),
          new Footnote([
            new PlainTextNode('Well, I '),
            new EmphasisNode([
              new PlainTextNode('do')
            ]),
            new PlainTextNode(', but I pretend not to.'),
          ], 3),
        ])
      ]))
  })


  it('produce footnotes that appear after any footnotes produced by less nested references', () => {
    expect(Up.toAst("Me? I'm totally normal. ((That said, I don't eat cereal. ((Well, I *do* ((Only on Mondays...)) but I pretend not to.)) Never have. ((At least you've never seen me.)))) Really. ((Probably.))")).to.be.eql(
      new DocumentNode([
        new ParagraphNode([
          new PlainTextNode("Me? I'm totally normal."),
          new FootnoteReferenceNode(1),
          new PlainTextNode(" Really."),
          new FootnoteReferenceNode(2),
        ]),
        new FootnoteBlockNode([
          new Footnote([
            new PlainTextNode("That said, I don't eat cereal."),
            new FootnoteReferenceNode(3),
            new PlainTextNode(" Never have."),
            new FootnoteReferenceNode(4),
          ], 1),<commit_msg>Add failed footnote test (for unordered lists)<commit_after>
import { expect } from 'chai'
import * as Up from '../../index'
import { insideDocumentAndParagraph } from './Helpers'
import { LinkNode } from '../../SyntaxNodes/LinkNode'
import { DocumentNode } from '../../SyntaxNodes/DocumentNode'
import { PlainTextNode } from '../../SyntaxNodes/PlainTextNode'
import { EmphasisNode } from '../../SyntaxNodes/EmphasisNode'
import { StressNode } from '../../SyntaxNodes/StressNode'
import { InlineCodeNode } from '../../SyntaxNodes/InlineCodeNode'
import { RevisionInsertionNode } from '../../SyntaxNodes/RevisionInsertionNode'
import { RevisionDeletionNode } from '../../SyntaxNodes/RevisionDeletionNode'
import { SpoilerNode } from '../../SyntaxNodes/SpoilerNode'
import { PlaceholderFootnoteReferenceNode } from '../../SyntaxNodes/PlaceholderFootnoteReferenceNode'
import { UnorderedListNode } from '../../SyntaxNodes/UnorderedListNode'
import { UnorderedListItem } from '../../SyntaxNodes/UnorderedListItem'
import { ParagraphNode } from '../../SyntaxNodes/ParagraphNode'
import { SectionSeparatorNode } from '../../SyntaxNodes/SectionSeparatorNode'
import { FootnoteReferenceNode } from '../../SyntaxNodes/FootnoteReferenceNode'
import { FootnoteBlockNode } from '../../SyntaxNodes/FootnoteBlockNode'
import { Footnote } from '../../SyntaxNodes/Footnote'


describe('In a paragraph, text surrounded by 2 parentheses', () => {
  it('produces a footnote reference node. This node references a footnote within a footnote block node after the paragraph', () => {
    expect(Up.toAst("I don't eat cereal. ((Well, I do, but I pretend not to.)) Never have.")).to.be.eql(
      new DocumentNode([
        new ParagraphNode([
          new PlainTextNode("I don't eat cereal."),
          new FootnoteReferenceNode(1),
          new PlainTextNode(" Never have."),
        ]),
        new FootnoteBlockNode([
          new Footnote([
            new PlainTextNode('Well, I do, but I pretend not to.')
          ], 1)
        ])
      ]))
  })
})



describe('Footnote references in unordered list items', () => {
  it('produce a footnote block node that appears after the entire list, not after the paragraph containing the reference', () => {
    const text = `
* I don't eat cereal. ((Well, I do, but I pretend not to.)) Never have.

  It's too expensive.

* I don't eat ((Or touch.)) pumpkins.`

    expect(Up.toAst(text)).to.be.eql(
      new DocumentNode([
        new UnorderedListNode([
          new UnorderedListItem([
            new ParagraphNode([
              new PlainTextNode("I don't eat cereal."),
              new FootnoteReferenceNode(1),
              new PlainTextNode(" Never have."),
            ]),
            new ParagraphNode([
              new PlainTextNode("It's too expnsive.")
            ])
          ]),
          new UnorderedListItem([
            new ParagraphNode([
              new PlainTextNode("I don't eat"),
              new FootnoteReferenceNode(2),
              new PlainTextNode(" pumpkins."),
            ])
          ])
        ]),
        new FootnoteBlockNode([
          new Footnote([
            new PlainTextNode("Well, I do, but I pretend not to."),
          ], 1),
          new Footnote([
            new PlainTextNode("Or touch."),
          ], 2)
        ])
      ]))
  })
})


describe('A footnote reference', () => {
  it('is evaluated for other conventions', () => {
    expect(Up.toAst("I don't eat cereal. ((Well, I *do*, but I pretend not to.)) Never have.")).to.be.eql(
      new DocumentNode([
        new ParagraphNode([
          new PlainTextNode("I don't eat cereal."),
          new FootnoteReferenceNode(1),
          new PlainTextNode(" Never have."),
        ]),
        new FootnoteBlockNode([
          new Footnote([
            new PlainTextNode('Well, I '),
            new EmphasisNode([
              new PlainTextNode('do')
            ]),
            new PlainTextNode(', but I pretend not to.')
          ], 1)
        ])
      ]))
  })

  it('can contain other footnote references, which produce additional footnotes in the same footnote block', () => {
    expect(Up.toAst("Me? I'm totally normal. ((That said, I don't eat cereal. ((Well, I *do*, but I pretend not to.)) Never have.)) Really.")).to.be.eql(
      new DocumentNode([
        new ParagraphNode([
          new PlainTextNode("Me? I'm totally normal."),
          new FootnoteReferenceNode(1),
          new PlainTextNode(" Really."),
        ]),
        new FootnoteBlockNode([
          new Footnote([
            new PlainTextNode("That said, I don't eat cereal."),
            new FootnoteReferenceNode(2),
            new PlainTextNode(" Never have."),
          ], 1),
          new Footnote([
            new PlainTextNode('Well, I '),
            new EmphasisNode([
              new PlainTextNode('do')
            ]),
            new PlainTextNode(', but I pretend not to.'),
          ], 2)
        ])
      ]))
  })
})


describe('Nested footnote references', () => {
  it('produce footnotes that appear after any footnotes produced by non-nested references', () => {
    expect(Up.toAst("Me? I'm totally normal. ((That said, I don't eat cereal. ((Well, I *do*, but I pretend not to.)) Never have.)) Really. ((Probably.))")).to.be.eql(
      new DocumentNode([
        new ParagraphNode([
          new PlainTextNode("Me? I'm totally normal."),
          new FootnoteReferenceNode(1),
          new PlainTextNode(" Really."),
          new FootnoteReferenceNode(2),
        ]),
        new FootnoteBlockNode([
          new Footnote([
            new PlainTextNode("That said, I don't eat cereal."),
            new FootnoteReferenceNode(3),
            new PlainTextNode(" Never have."),
          ], 1),
          new Footnote([
            new PlainTextNode("Probably."),
          ], 2),
          new Footnote([
            new PlainTextNode('Well, I '),
            new EmphasisNode([
              new PlainTextNode('do')
            ]),
            new PlainTextNode(', but I pretend not to.'),
          ], 3),
        ])
      ]))
  })


  it('produce footnotes that appear after any footnotes produced by less nested references', () => {
    const text =
      "Me? I'm totally normal. ((That said, I don't eat cereal. ((Well, I *do* ((Only on Mondays...)) but I pretend not to.)) Never have. ((At least you've never seen me.)))) Really. ((Probably.))"

    expect(Up.toAst(text)).to.be.eql(
      new DocumentNode([
        new ParagraphNode([
          new PlainTextNode("Me? I'm totally normal."),
          new FootnoteReferenceNode(1),
          new PlainTextNode(" Really."),
          new FootnoteReferenceNode(2),
        ]),
        new FootnoteBlockNode([
          new Footnote([
            new PlainTextNode("That said, I don't eat cereal."),
            new FootnoteReferenceNode(3),
            new PlainTextNode(" Never have."),
            new FootnoteReferenceNode(4),
          ], 1),
{'fraction_non_alphanumeric': 0.13780634793089594, 'fraction_numerical': 0.0035355564483728406, 'mean_word_length': 2.2632406921866806, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3592620', 'n_tokens_mistral': 3540, 'n_tokens_neox': 3311, 'n_words': 1032}