# frozen_string_literal: true describe PrettyText do before { Jobs.run_immediately! } it "can be disabled" do SiteSetting.enable_markdown_footnotes = false markdown = <<~MD Here is a footnote, [^1] [^1]: I am one MD html = <<~HTML

Here is a footnote, [^1]

\n

[^1]: I am one

HTML cooked = PrettyText.cook markdown.strip expect(cooked).to eq(html.strip) end it "supports normal footnotes" do markdown = <<~MD Here is a footnote, [^1] and another. [^test] [^1]: I am one [^test]: I am one test multiline MD html = <<~HTML

Here is a footnote, [1] and another. [2]

test multiline


  1. I am one ↩︎

  2. I am one ↩︎

HTML cooked = PrettyText.cook markdown.strip expect(cooked).to eq(html.strip) end it "applies unique ids to elements after cooking a post" do raw = <<~MD Here is a footnote, [^1] and another. [^test] [^1]: I am one [^test]: I am one test multiline MD post = create_post(raw: raw) post.reload html = <<~HTML

Here is a footnote, [1] and another. [2]

test multiline


  1. I am one ↩︎

  2. I am one ↩︎

HTML expect(post.cooked.strip).to eq(html.strip) end it "supports inline footnotes wrapped in elements by ending the elements early" do raw = <<~MD I have a point, see footnote. ^[the point] ^[footnote] MD post = create_post(raw: raw) post.reload html = <<~HTML

I have a point, see footnote. [1]

[2]


  1. the point ↩︎

  2. footnote ↩︎

HTML expect(post.cooked.strip).to eq(html.strip) end end