qiita-markdown 0.44.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +2 -2
- data/.rubocop.yml +0 -4
- data/.rubocop_todo.yml +6 -44
- data/CHANGELOG.md +10 -0
- data/README.md +3 -1
- data/lib/qiita/markdown/filters/checkbox.rb +5 -1
- data/lib/qiita/markdown/filters/custom_block.rb +7 -6
- data/lib/qiita/markdown/filters/final_sanitizer.rb +8 -2
- data/lib/qiita/markdown/filters/heading_anchor.rb +44 -0
- data/lib/qiita/markdown/filters/html_toc.rb +67 -0
- data/lib/qiita/markdown/filters/qiita_marker.rb +55 -0
- data/lib/qiita/markdown/filters/user_input_sanitizer.rb +14 -9
- data/lib/qiita/markdown/processor.rb +2 -1
- data/lib/qiita/markdown/summary_processor.rb +1 -1
- data/lib/qiita/markdown/version.rb +1 -1
- data/lib/qiita/markdown.rb +4 -5
- data/qiita-markdown.gemspec +2 -3
- data/spec/qiita/markdown/filters/checkbox_spec.rb +28 -0
- data/spec/qiita/markdown/filters/heading_anchor_spec.rb +73 -0
- data/spec/qiita/markdown/filters/html_toc_spec.rb +223 -0
- data/spec/qiita/markdown/filters/qiita_marker_spec.rb +60 -0
- data/spec/qiita/markdown/processor_spec.rb +48 -54
- data/spec/qiita/markdown/summary_processor_spec.rb +2 -2
- metadata +23 -39
- data/benchmark/heading_anchor_rendering.rb +0 -248
- data/benchmark/sample.md +0 -317
- data/lib/qiita/markdown/filters/greenmat.rb +0 -38
- data/lib/qiita/markdown/greenmat/heading_rendering.rb +0 -61
- data/lib/qiita/markdown/greenmat/html_renderer.rb +0 -60
- data/lib/qiita/markdown/greenmat/html_toc_renderer.rb +0 -78
- data/spec/qiita/markdown/filters/greenmat_spec.rb +0 -15
- data/spec/qiita/markdown/greenmat/html_toc_renderer_spec.rb +0 -156
| @@ -0,0 +1,73 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Qiita::Markdown::Filters::HeadingAnchor do
         | 
| 4 | 
            +
              subject(:filter) { described_class.new(html) }
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              let(:html) do
         | 
| 7 | 
            +
                <<~HTML
         | 
| 8 | 
            +
                  <h1>foo</h1>
         | 
| 9 | 
            +
                  <h2>bar</h2>
         | 
| 10 | 
            +
                  <h3>fizz</h3>
         | 
| 11 | 
            +
                  <p>paragraph</p>
         | 
| 12 | 
            +
                  <h4>buzz</h4>
         | 
| 13 | 
            +
                  <h5>hoge</h5>
         | 
| 14 | 
            +
                  <h6>fuga</h6>
         | 
| 15 | 
            +
                  <code>code</code>
         | 
| 16 | 
            +
                HTML
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              it "renders ids" do
         | 
| 20 | 
            +
                expect(filter.call.to_s).to eq(<<~HTML)
         | 
| 21 | 
            +
                  <h1 id="foo">foo</h1>
         | 
| 22 | 
            +
                  <h2 id="bar">bar</h2>
         | 
| 23 | 
            +
                  <h3 id="fizz">fizz</h3>
         | 
| 24 | 
            +
                  <p>paragraph</p>
         | 
| 25 | 
            +
                  <h4 id="buzz">buzz</h4>
         | 
| 26 | 
            +
                  <h5 id="hoge">hoge</h5>
         | 
| 27 | 
            +
                  <h6 id="fuga">fuga</h6>
         | 
| 28 | 
            +
                  <code>code</code>
         | 
| 29 | 
            +
                HTML
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              context "with headings text is same" do
         | 
| 33 | 
            +
                let(:html) do
         | 
| 34 | 
            +
                  <<~HTML
         | 
| 35 | 
            +
                    <h1>foo</h1>
         | 
| 36 | 
            +
                    <h2>foo</h2>
         | 
| 37 | 
            +
                    <h3>foo</h3>
         | 
| 38 | 
            +
                    <p>paragraph</p>
         | 
| 39 | 
            +
                    <h4>foo</h4>
         | 
| 40 | 
            +
                    <h5>foo</h5>
         | 
| 41 | 
            +
                    <h6>foo</h6>
         | 
| 42 | 
            +
                    <code>code</code>
         | 
| 43 | 
            +
                  HTML
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                it "renders suffixed ids" do
         | 
| 47 | 
            +
                  expect(filter.call.to_s).to eq(<<~HTML)
         | 
| 48 | 
            +
                    <h1 id="foo">foo</h1>
         | 
| 49 | 
            +
                    <h2 id="foo-1">foo</h2>
         | 
| 50 | 
            +
                    <h3 id="foo-2">foo</h3>
         | 
| 51 | 
            +
                    <p>paragraph</p>
         | 
| 52 | 
            +
                    <h4 id="foo-3">foo</h4>
         | 
| 53 | 
            +
                    <h5 id="foo-4">foo</h5>
         | 
| 54 | 
            +
                    <h6 id="foo-5">foo</h6>
         | 
| 55 | 
            +
                    <code>code</code>
         | 
| 56 | 
            +
                  HTML
         | 
| 57 | 
            +
                end
         | 
| 58 | 
            +
              end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
              context "with characters that cannot included" do
         | 
| 61 | 
            +
                let(:html) do
         | 
| 62 | 
            +
                  <<~HTML
         | 
| 63 | 
            +
                    <h1>test [foo-bar]</h1>
         | 
| 64 | 
            +
                  HTML
         | 
| 65 | 
            +
                end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                it "renders id with omitted characters" do
         | 
| 68 | 
            +
                  expect(filter.call.to_s).to eq(<<~HTML)
         | 
| 69 | 
            +
                    <h1 id="test-foo-bar">test [foo-bar]</h1>
         | 
| 70 | 
            +
                  HTML
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
              end
         | 
| 73 | 
            +
            end
         | 
| @@ -0,0 +1,223 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Qiita::Markdown::Filters::HtmlToc do
         | 
| 4 | 
            +
              subject(:filter) { described_class.new(html) }
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              context "with headings h1, h2, h3, h4, h5, h6" do
         | 
| 7 | 
            +
                let(:html) do
         | 
| 8 | 
            +
                  <<~HTML
         | 
| 9 | 
            +
                    <h1 id="foo">foo</h1>
         | 
| 10 | 
            +
                    <h2 id="bar">bar</h2>
         | 
| 11 | 
            +
                    <h3 id="fizz">fizz</h3>
         | 
| 12 | 
            +
                    <p>paragraph</p>
         | 
| 13 | 
            +
                    <h4 id="buzz">buzz</h4>
         | 
| 14 | 
            +
                    <h5 id="hoge">hoge</h5>
         | 
| 15 | 
            +
                    <h6 id="fuga">fuga</h6>
         | 
| 16 | 
            +
                    <code>code</code>
         | 
| 17 | 
            +
                  HTML
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                let(:result) do
         | 
| 21 | 
            +
                  <<~HTML
         | 
| 22 | 
            +
                    <ul>
         | 
| 23 | 
            +
                    <li>
         | 
| 24 | 
            +
                    <a href="#foo">foo</a>
         | 
| 25 | 
            +
                    <ul>
         | 
| 26 | 
            +
                    <li>
         | 
| 27 | 
            +
                    <a href="#bar">bar</a>
         | 
| 28 | 
            +
                    <ul>
         | 
| 29 | 
            +
                    <li>
         | 
| 30 | 
            +
                    <a href="#fizz">fizz</a>
         | 
| 31 | 
            +
                    <ul>
         | 
| 32 | 
            +
                    <li>
         | 
| 33 | 
            +
                    <a href="#buzz">buzz</a>
         | 
| 34 | 
            +
                    <ul>
         | 
| 35 | 
            +
                    <li>
         | 
| 36 | 
            +
                    <a href="#hoge">hoge</a>
         | 
| 37 | 
            +
                    <ul>
         | 
| 38 | 
            +
                    <li>
         | 
| 39 | 
            +
                    <a href="#fuga">fuga</a>
         | 
| 40 | 
            +
                    </li>
         | 
| 41 | 
            +
                    </ul>
         | 
| 42 | 
            +
                    </li>
         | 
| 43 | 
            +
                    </ul>
         | 
| 44 | 
            +
                    </li>
         | 
| 45 | 
            +
                    </ul>
         | 
| 46 | 
            +
                    </li>
         | 
| 47 | 
            +
                    </ul>
         | 
| 48 | 
            +
                    </li>
         | 
| 49 | 
            +
                    </ul>
         | 
| 50 | 
            +
                    </li>
         | 
| 51 | 
            +
                    </ul>
         | 
| 52 | 
            +
                  HTML
         | 
| 53 | 
            +
                end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                it "renders nested toc" do
         | 
| 56 | 
            +
                  expect(filter.call).to eq(result)
         | 
| 57 | 
            +
                end
         | 
| 58 | 
            +
              end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
              context "headings are same rank" do
         | 
| 61 | 
            +
                let(:html) do
         | 
| 62 | 
            +
                  <<~HTML
         | 
| 63 | 
            +
                    <h1 id="foo">foo</h1>
         | 
| 64 | 
            +
                    <h1 id="bar">bar</h1>
         | 
| 65 | 
            +
                    <h1 id="fizz">fizz</h1>
         | 
| 66 | 
            +
                  HTML
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                let(:result) do
         | 
| 70 | 
            +
                  <<~HTML
         | 
| 71 | 
            +
                    <ul>
         | 
| 72 | 
            +
                    <li>
         | 
| 73 | 
            +
                    <a href="#foo">foo</a>
         | 
| 74 | 
            +
                    </li>
         | 
| 75 | 
            +
                    <li>
         | 
| 76 | 
            +
                    <a href="#bar">bar</a>
         | 
| 77 | 
            +
                    </li>
         | 
| 78 | 
            +
                    <li>
         | 
| 79 | 
            +
                    <a href="#fizz">fizz</a>
         | 
| 80 | 
            +
                    </li>
         | 
| 81 | 
            +
                    </ul>
         | 
| 82 | 
            +
                  HTML
         | 
| 83 | 
            +
                end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                it "renders toc of same level" do
         | 
| 86 | 
            +
                  expect(filter.call).to eq(result)
         | 
| 87 | 
            +
                end
         | 
| 88 | 
            +
              end
         | 
| 89 | 
            +
             | 
| 90 | 
            +
              context "with heading rank going up" do
         | 
| 91 | 
            +
                let(:html) do
         | 
| 92 | 
            +
                  <<~HTML
         | 
| 93 | 
            +
                    <h1 id="foo">foo</h1>
         | 
| 94 | 
            +
                    <h3 id="bar">bar</h3>
         | 
| 95 | 
            +
                    <h1 id="bazz">bazz</h1>
         | 
| 96 | 
            +
                  HTML
         | 
| 97 | 
            +
                end
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                let(:result) do
         | 
| 100 | 
            +
                  <<~HTML
         | 
| 101 | 
            +
                    <ul>
         | 
| 102 | 
            +
                    <li>
         | 
| 103 | 
            +
                    <a href="#foo">foo</a>
         | 
| 104 | 
            +
                    <ul>
         | 
| 105 | 
            +
                    <li>
         | 
| 106 | 
            +
                    <ul>
         | 
| 107 | 
            +
                    <li>
         | 
| 108 | 
            +
                    <a href="#bar">bar</a>
         | 
| 109 | 
            +
                    </li>
         | 
| 110 | 
            +
                    </ul>
         | 
| 111 | 
            +
                    </li>
         | 
| 112 | 
            +
                    </ul>
         | 
| 113 | 
            +
                    </li>
         | 
| 114 | 
            +
                    <li>
         | 
| 115 | 
            +
                    <a href="#bazz">bazz</a>
         | 
| 116 | 
            +
                    </li>
         | 
| 117 | 
            +
                    </ul>
         | 
| 118 | 
            +
                  HTML
         | 
| 119 | 
            +
                end
         | 
| 120 | 
            +
             | 
| 121 | 
            +
                it "renders toc that the depth goes up" do
         | 
| 122 | 
            +
                  expect(filter.call).to eq(result)
         | 
| 123 | 
            +
                end
         | 
| 124 | 
            +
              end
         | 
| 125 | 
            +
             | 
| 126 | 
            +
              context "with starting from h2" do
         | 
| 127 | 
            +
                let(:html) do
         | 
| 128 | 
            +
                  <<~HTML
         | 
| 129 | 
            +
                    <h2 id="bar">bar</h2>
         | 
| 130 | 
            +
                    <h3 id="fizz">fizz</h3>
         | 
| 131 | 
            +
                  HTML
         | 
| 132 | 
            +
                end
         | 
| 133 | 
            +
             | 
| 134 | 
            +
                let(:result) do
         | 
| 135 | 
            +
                  <<~HTML
         | 
| 136 | 
            +
                    <ul>
         | 
| 137 | 
            +
                    <li>
         | 
| 138 | 
            +
                    <a href="#bar">bar</a>
         | 
| 139 | 
            +
                    <ul>
         | 
| 140 | 
            +
                    <li>
         | 
| 141 | 
            +
                    <a href="#fizz">fizz</a>
         | 
| 142 | 
            +
                    </li>
         | 
| 143 | 
            +
                    </ul>
         | 
| 144 | 
            +
                    </li>
         | 
| 145 | 
            +
                    </ul>
         | 
| 146 | 
            +
                  HTML
         | 
| 147 | 
            +
                end
         | 
| 148 | 
            +
             | 
| 149 | 
            +
                it "renders h2 as top level" do
         | 
| 150 | 
            +
                  expect(filter.call).to eq(result)
         | 
| 151 | 
            +
                end
         | 
| 152 | 
            +
              end
         | 
| 153 | 
            +
             | 
| 154 | 
            +
              context "with some heading rank is higher than first heading" do
         | 
| 155 | 
            +
                let(:html) do
         | 
| 156 | 
            +
                  <<~HTML
         | 
| 157 | 
            +
                    <h2 id="foo">foo</h2>
         | 
| 158 | 
            +
                    <h3 id="bar">bar</h3>
         | 
| 159 | 
            +
                    <h1 id="fizz">fizz</h1>
         | 
| 160 | 
            +
                    <h2 id="bazz">bazz</h2>
         | 
| 161 | 
            +
                  HTML
         | 
| 162 | 
            +
                end
         | 
| 163 | 
            +
             | 
| 164 | 
            +
                let(:result) do
         | 
| 165 | 
            +
                  <<~HTML
         | 
| 166 | 
            +
                    <ul>
         | 
| 167 | 
            +
                    <li>
         | 
| 168 | 
            +
                    <a href="#foo">foo</a>
         | 
| 169 | 
            +
                    <ul>
         | 
| 170 | 
            +
                    <li>
         | 
| 171 | 
            +
                    <a href="#bar">bar</a>
         | 
| 172 | 
            +
                    </li>
         | 
| 173 | 
            +
                    </ul>
         | 
| 174 | 
            +
                    </li>
         | 
| 175 | 
            +
                    <li>
         | 
| 176 | 
            +
                    <a href="#fizz">fizz</a>
         | 
| 177 | 
            +
                    </li>
         | 
| 178 | 
            +
                    <li>
         | 
| 179 | 
            +
                    <a href="#bazz">bazz</a>
         | 
| 180 | 
            +
                    </li>
         | 
| 181 | 
            +
                    </ul>
         | 
| 182 | 
            +
                  HTML
         | 
| 183 | 
            +
                end
         | 
| 184 | 
            +
             | 
| 185 | 
            +
                it "renders higher rank headings at the same level as the first heading" do
         | 
| 186 | 
            +
                  expect(filter.call).to eq(result)
         | 
| 187 | 
            +
                end
         | 
| 188 | 
            +
              end
         | 
| 189 | 
            +
             | 
| 190 | 
            +
              context "with include html tag" do
         | 
| 191 | 
            +
                let(:html) do
         | 
| 192 | 
            +
                  <<~HTML
         | 
| 193 | 
            +
                    <h2 id="foo"><strong>foo</strong></h2>
         | 
| 194 | 
            +
                  HTML
         | 
| 195 | 
            +
                end
         | 
| 196 | 
            +
             | 
| 197 | 
            +
                let(:result) do
         | 
| 198 | 
            +
                  <<~HTML
         | 
| 199 | 
            +
                    <ul>
         | 
| 200 | 
            +
                    <li>
         | 
| 201 | 
            +
                    <a href="#foo">foo</a>
         | 
| 202 | 
            +
                    </li>
         | 
| 203 | 
            +
                    </ul>
         | 
| 204 | 
            +
                  HTML
         | 
| 205 | 
            +
                end
         | 
| 206 | 
            +
             | 
| 207 | 
            +
                it "anchor text does not include html tag" do
         | 
| 208 | 
            +
                  expect(filter.call).to eq(result)
         | 
| 209 | 
            +
                end
         | 
| 210 | 
            +
              end
         | 
| 211 | 
            +
             | 
| 212 | 
            +
              context "without headings" do
         | 
| 213 | 
            +
                let(:html) do
         | 
| 214 | 
            +
                  <<~HTML
         | 
| 215 | 
            +
                    <p>paragraph</p>
         | 
| 216 | 
            +
                  HTML
         | 
| 217 | 
            +
                end
         | 
| 218 | 
            +
             | 
| 219 | 
            +
                it "renders empty string" do
         | 
| 220 | 
            +
                  expect(filter.call.to_s).to eq("")
         | 
| 221 | 
            +
                end
         | 
| 222 | 
            +
              end
         | 
| 223 | 
            +
            end
         | 
| @@ -0,0 +1,60 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Qiita::Markdown::Filters::QiitaMarker do
         | 
| 4 | 
            +
              subject(:filter) { described_class.new(markdown, context) }
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              let(:context) { nil }
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              context "with footnotes" do
         | 
| 9 | 
            +
                let(:markdown) do
         | 
| 10 | 
            +
                  <<~MD
         | 
| 11 | 
            +
                    foo [^1]
         | 
| 12 | 
            +
                    [^1]: bar
         | 
| 13 | 
            +
                  MD
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                it "renders footnotes" do
         | 
| 17 | 
            +
                  expect(filter.call.to_s).to include('class="footnotes"')
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                context "and disable footnotes option" do
         | 
| 21 | 
            +
                  let(:context) do
         | 
| 22 | 
            +
                    {
         | 
| 23 | 
            +
                      markdown: {
         | 
| 24 | 
            +
                        footnotes: false,
         | 
| 25 | 
            +
                      },
         | 
| 26 | 
            +
                    }
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  it "does not render footnotes" do
         | 
| 30 | 
            +
                    expect(filter.call.to_s).not_to include('class="footnotes"')
         | 
| 31 | 
            +
                  end
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              context "with sourcepos" do
         | 
| 36 | 
            +
                let(:markdown) do
         | 
| 37 | 
            +
                  <<~MD
         | 
| 38 | 
            +
                    foo bar
         | 
| 39 | 
            +
                  MD
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                it "does not render HTML containing data-sourcepos" do
         | 
| 43 | 
            +
                  expect(filter.call.to_s).not_to include("data-sourcepos")
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                context "and enable sourcepos option" do
         | 
| 47 | 
            +
                  let(:context) do
         | 
| 48 | 
            +
                    {
         | 
| 49 | 
            +
                      markdown: {
         | 
| 50 | 
            +
                        sourcepos: true,
         | 
| 51 | 
            +
                      },
         | 
| 52 | 
            +
                    }
         | 
| 53 | 
            +
                  end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                  it "renders HTML containing data-sourcepos" do
         | 
| 56 | 
            +
                    expect(filter.call.to_s).to include("data-sourcepos")
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
            end
         | 
| @@ -69,16 +69,12 @@ describe Qiita::Markdown::Processor do | |
| 69 69 |  | 
| 70 70 | 
             
                    it "adds ID for ToC" do
         | 
| 71 71 | 
             
                      should eq <<-HTML.strip_heredoc
         | 
| 72 | 
            -
             | 
| 73 72 | 
             
                        <h1>
         | 
| 74 73 | 
             
                        <span id="a" class="fragment"></span><a href="#a"><i class="fa fa-link"></i></a>a</h1>
         | 
| 75 | 
            -
             | 
| 76 74 | 
             
                        <h2>
         | 
| 77 75 | 
             
                        <span id="a-1" class="fragment"></span><a href="#a-1"><i class="fa fa-link"></i></a>a</h2>
         | 
| 78 | 
            -
             | 
| 79 76 | 
             
                        <h3>
         | 
| 80 77 | 
             
                        <span id="a-2" class="fragment"></span><a href="#a-2"><i class="fa fa-link"></i></a>a</h3>
         | 
| 81 | 
            -
             | 
| 82 78 | 
             
                        <h3>
         | 
| 83 79 | 
             
                        <span id="a-3" class="fragment"></span><a href="#a-3"><i class="fa fa-link"></i></a>a</h3>
         | 
| 84 80 | 
             
                      HTML
         | 
| @@ -94,7 +90,6 @@ describe Qiita::Markdown::Processor do | |
| 94 90 |  | 
| 95 91 | 
             
                    it "generates fragment identifier by sanitizing the special characters in the title" do
         | 
| 96 92 | 
             
                      should eq <<-HTML.strip_heredoc
         | 
| 97 | 
            -
             | 
| 98 93 | 
             
                        <h1>
         | 
| 99 94 | 
             
                        <span id="rb" class="fragment"></span><a href="#rb"><i class="fa fa-link"></i></a><b>R&B</b>
         | 
| 100 95 | 
             
                        </h1>
         | 
| @@ -109,9 +104,10 @@ describe Qiita::Markdown::Processor do | |
| 109 104 | 
             
                      MARKDOWN
         | 
| 110 105 | 
             
                    end
         | 
| 111 106 |  | 
| 112 | 
            -
                    it " | 
| 107 | 
            +
                    it "adds ID for ToC" do
         | 
| 113 108 | 
             
                      should eq <<-HTML.strip_heredoc
         | 
| 114 | 
            -
                        <h1> | 
| 109 | 
            +
                        <h1>
         | 
| 110 | 
            +
                        <span id="foo" class="fragment"></span><a href="#foo"><i class="fa fa-link"></i></a>foo</h1>
         | 
| 115 111 | 
             
                      HTML
         | 
| 116 112 | 
             
                    end
         | 
| 117 113 | 
             
                  end
         | 
| @@ -586,8 +582,8 @@ describe Qiita::Markdown::Processor do | |
| 586 582 | 
             
                    end
         | 
| 587 583 |  | 
| 588 584 | 
             
                    it "wraps it in a element while keeping the width attribute" do
         | 
| 589 | 
            -
                      should eq %(< | 
| 590 | 
            -
                                %(<img width="80" height="48" alt="a" src="http://example.com/b.png"></a | 
| 585 | 
            +
                      should eq %(<a href="http://example.com/b.png" target="_blank">) +
         | 
| 586 | 
            +
                                %(<img width="80" height="48" alt="a" src="http://example.com/b.png"></a>\n)
         | 
| 591 587 | 
             
                    end
         | 
| 592 588 | 
             
                  end
         | 
| 593 589 |  | 
| @@ -647,7 +643,7 @@ describe Qiita::Markdown::Processor do | |
| 647 643 | 
             
                    let(:markdown) do
         | 
| 648 644 | 
             
                      <<-MARKDOWN.strip_heredoc
         | 
| 649 645 | 
             
                        - [ ] a
         | 
| 650 | 
            -
             | 
| 646 | 
            +
                          - [ ] b
         | 
| 651 647 | 
             
                      MARKDOWN
         | 
| 652 648 | 
             
                    end
         | 
| 653 649 |  | 
| @@ -656,7 +652,6 @@ describe Qiita::Markdown::Processor do | |
| 656 652 | 
             
                        <ul>
         | 
| 657 653 | 
             
                        <li class="task-list-item">
         | 
| 658 654 | 
             
                        <input type="checkbox" class="task-list-item-checkbox" disabled>a
         | 
| 659 | 
            -
             | 
| 660 655 | 
             
                        <ul>
         | 
| 661 656 | 
             
                        <li class="task-list-item">
         | 
| 662 657 | 
             
                        <input type="checkbox" class="task-list-item-checkbox" disabled>b</li>
         | 
| @@ -698,8 +693,12 @@ describe Qiita::Markdown::Processor do | |
| 698 693 | 
             
                    it "inserts checkbox" do
         | 
| 699 694 | 
             
                      should eq <<-HTML.strip_heredoc
         | 
| 700 695 | 
             
                        <ul>
         | 
| 701 | 
            -
                        <li class="task-list-item" | 
| 702 | 
            -
                        < | 
| 696 | 
            +
                        <li class="task-list-item">
         | 
| 697 | 
            +
                        <p><input type="checkbox" class="task-list-item-checkbox" disabled>a</p>
         | 
| 698 | 
            +
                        </li>
         | 
| 699 | 
            +
                        <li class="task-list-item">
         | 
| 700 | 
            +
                        <p><input type="checkbox" class="task-list-item-checkbox" checked disabled>b</p>
         | 
| 701 | 
            +
                        </li>
         | 
| 703 702 | 
             
                        </ul>
         | 
| 704 703 | 
             
                      HTML
         | 
| 705 704 | 
             
                    end
         | 
| @@ -759,20 +758,7 @@ describe Qiita::Markdown::Processor do | |
| 759 758 | 
             
                    end
         | 
| 760 759 |  | 
| 761 760 | 
             
                    it "generates footnotes elements" do
         | 
| 762 | 
            -
                      should  | 
| 763 | 
            -
                        <p><sup id="fnref1"><a href="#fn1" title="test">1</a></sup></p>
         | 
| 764 | 
            -
             | 
| 765 | 
            -
                        <div class="footnotes">
         | 
| 766 | 
            -
                        <hr>
         | 
| 767 | 
            -
                        <ol>
         | 
| 768 | 
            -
             | 
| 769 | 
            -
                        <li id="fn1">
         | 
| 770 | 
            -
                        <p>test <a href="#fnref1">↩</a></p>
         | 
| 771 | 
            -
                        </li>
         | 
| 772 | 
            -
             | 
| 773 | 
            -
                        </ol>
         | 
| 774 | 
            -
                        </div>
         | 
| 775 | 
            -
                      HTML
         | 
| 761 | 
            +
                      should include('class="footnotes"')
         | 
| 776 762 | 
             
                    end
         | 
| 777 763 | 
             
                  end
         | 
| 778 764 |  | 
| @@ -837,7 +823,8 @@ describe Qiita::Markdown::Processor do | |
| 837 823 |  | 
| 838 824 | 
             
                    it "does not generate footnote elements" do
         | 
| 839 825 | 
             
                      should eq <<-HTML.strip_heredoc
         | 
| 840 | 
            -
                        <p | 
| 826 | 
            +
                        <p>[^1]<br>
         | 
| 827 | 
            +
                        [^1]: test</p>
         | 
| 841 828 | 
             
                      HTML
         | 
| 842 829 | 
             
                    end
         | 
| 843 830 | 
             
                  end
         | 
| @@ -1085,13 +1072,10 @@ describe Qiita::Markdown::Processor do | |
| 1085 1072 |  | 
| 1086 1073 | 
             
                    it "returns HTML output parsed as markdown" do
         | 
| 1087 1074 | 
             
                      expect(subject).to eq <<-HTML.strip_heredoc
         | 
| 1088 | 
            -
                        < | 
| 1089 | 
            -
             | 
| 1075 | 
            +
                        <details><summary>Folding sample</summary><div>
         | 
| 1090 1076 | 
             
                        <div class="code-frame" data-lang="rb"><div class="highlight"><pre class="codehilite"><code><span class="nb">puts</span> <span class="s2">"Hello, World"</span>
         | 
| 1091 1077 | 
             
                        </code></pre></div></div>
         | 
| 1092 | 
            -
             | 
| 1093 | 
            -
                        <p></p>
         | 
| 1094 | 
            -
                        </div></details></p>
         | 
| 1078 | 
            +
                        </div></details>
         | 
| 1095 1079 | 
             
                      HTML
         | 
| 1096 1080 | 
             
                    end
         | 
| 1097 1081 | 
             
                  end
         | 
| @@ -1425,14 +1409,14 @@ describe Qiita::Markdown::Processor do | |
| 1425 1409 | 
             
                    if allowed
         | 
| 1426 1410 | 
             
                      it "does not sanitize embed code" do
         | 
| 1427 1411 | 
             
                        should eq <<-HTML.strip_heredoc
         | 
| 1428 | 
            -
                          <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p | 
| 1412 | 
            +
                          <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p>
         | 
| 1429 1413 | 
             
                          <script src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
         | 
| 1430 1414 | 
             
                        HTML
         | 
| 1431 1415 | 
             
                      end
         | 
| 1432 1416 | 
             
                    else
         | 
| 1433 1417 | 
             
                      it "forces async attribute on script" do
         | 
| 1434 1418 | 
             
                        should eq <<-HTML.strip_heredoc
         | 
| 1435 | 
            -
                          <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p | 
| 1419 | 
            +
                          <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p>
         | 
| 1436 1420 | 
             
                          <script src="https://production-assets.codepen.io/assets/embed/ei.js" async="async"></script>
         | 
| 1437 1421 | 
             
                        HTML
         | 
| 1438 1422 | 
             
                      end
         | 
| @@ -1450,14 +1434,14 @@ describe Qiita::Markdown::Processor do | |
| 1450 1434 | 
             
                    if allowed
         | 
| 1451 1435 | 
             
                      it "does not sanitize embed code" do
         | 
| 1452 1436 | 
             
                        should eq <<-HTML.strip_heredoc
         | 
| 1453 | 
            -
                          <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p | 
| 1437 | 
            +
                          <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p>
         | 
| 1454 1438 | 
             
                          <script src="https://static.codepen.io/assets/embed/ei.js"></script>
         | 
| 1455 1439 | 
             
                        HTML
         | 
| 1456 1440 | 
             
                      end
         | 
| 1457 1441 | 
             
                    else
         | 
| 1458 1442 | 
             
                      it "forces async attribute on script" do
         | 
| 1459 1443 | 
             
                        should eq <<-HTML.strip_heredoc
         | 
| 1460 | 
            -
                          <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p | 
| 1444 | 
            +
                          <p data-height="1" data-theme-id="0" data-slug-hash="foo" data-default-tab="bar" data-user="baz" data-embed-version="2" data-pen-title="qux" class="codepen"></p>
         | 
| 1461 1445 | 
             
                          <script src="https://static.codepen.io/assets/embed/ei.js" async="async"></script>
         | 
| 1462 1446 | 
             
                        HTML
         | 
| 1463 1447 | 
             
                      end
         | 
| @@ -1747,7 +1731,7 @@ describe Qiita::Markdown::Processor do | |
| 1747 1731 |  | 
| 1748 1732 | 
             
                    it "does not sanitize embed code" do
         | 
| 1749 1733 | 
             
                      should eq <<-HTML.strip_heredoc
         | 
| 1750 | 
            -
                        <blockquote class="twitter-tweet" data-lang="es" data-cards="hidden" data-conversation="none">foo</blockquote | 
| 1734 | 
            +
                        <blockquote class="twitter-tweet" data-lang="es" data-cards="hidden" data-conversation="none">foo</blockquote>
         | 
| 1751 1735 | 
             
                        <script async src="https://platform.twitter.com/widgets.js"></script>
         | 
| 1752 1736 | 
             
                      HTML
         | 
| 1753 1737 | 
             
                    end
         | 
| @@ -1809,14 +1793,16 @@ describe Qiita::Markdown::Processor do | |
| 1809 1793 | 
             
                      if allowed
         | 
| 1810 1794 | 
             
                        it "returns simple div element" do
         | 
| 1811 1795 | 
             
                          should eq <<-HTML.strip_heredoc
         | 
| 1812 | 
            -
                            <div data-type="customblock"> | 
| 1796 | 
            +
                            <div data-type="customblock" data-metadata="">
         | 
| 1797 | 
            +
                            <p>Some kind of text is here.</p>
         | 
| 1813 1798 | 
             
                            </div>
         | 
| 1814 1799 | 
             
                          HTML
         | 
| 1815 1800 | 
             
                        end
         | 
| 1816 1801 | 
             
                      else
         | 
| 1817 1802 | 
             
                        it "returns simple div element" do
         | 
| 1818 1803 | 
             
                          should eq <<-HTML.strip_heredoc
         | 
| 1819 | 
            -
                            <div> | 
| 1804 | 
            +
                            <div>
         | 
| 1805 | 
            +
                            <p>Some kind of text is here.</p>
         | 
| 1820 1806 | 
             
                            </div>
         | 
| 1821 1807 | 
             
                          HTML
         | 
| 1822 1808 | 
             
                        end
         | 
| @@ -1829,14 +1815,16 @@ describe Qiita::Markdown::Processor do | |
| 1829 1815 | 
             
                      if allowed
         | 
| 1830 1816 | 
             
                        it "returns simple div element" do
         | 
| 1831 1817 | 
             
                          should eq <<-HTML.strip_heredoc
         | 
| 1832 | 
            -
                            <div data-type="customblock" data-metadata="anytype"> | 
| 1818 | 
            +
                            <div data-type="customblock" data-metadata="anytype">
         | 
| 1819 | 
            +
                            <p>Some kind of text is here.</p>
         | 
| 1833 1820 | 
             
                            </div>
         | 
| 1834 1821 | 
             
                          HTML
         | 
| 1835 1822 | 
             
                        end
         | 
| 1836 1823 | 
             
                      else
         | 
| 1837 1824 | 
             
                        it "returns simple div element" do
         | 
| 1838 1825 | 
             
                          should eq <<-HTML.strip_heredoc
         | 
| 1839 | 
            -
                            <div> | 
| 1826 | 
            +
                            <div>
         | 
| 1827 | 
            +
                            <p>Some kind of text is here.</p>
         | 
| 1840 1828 | 
             
                            </div>
         | 
| 1841 1829 | 
             
                          HTML
         | 
| 1842 1830 | 
             
                        end
         | 
| @@ -1851,8 +1839,9 @@ describe Qiita::Markdown::Processor do | |
| 1851 1839 | 
             
                          it "returns info note block with class including icon as default type" do
         | 
| 1852 1840 | 
             
                            should eq <<-HTML.strip_heredoc
         | 
| 1853 1841 | 
             
                              <div data-type="customblock" data-metadata="note" class="note info">
         | 
| 1854 | 
            -
                              <span class="fa fa-fw fa-check-circle"></span>< | 
| 1855 | 
            -
                               | 
| 1842 | 
            +
                              <span class="fa fa-fw fa-check-circle"></span><div>
         | 
| 1843 | 
            +
                              <p>Some kind of text is here.</p>
         | 
| 1844 | 
            +
                              </div>
         | 
| 1856 1845 | 
             
                              </div>
         | 
| 1857 1846 | 
             
                            HTML
         | 
| 1858 1847 | 
             
                          end
         | 
| @@ -1860,8 +1849,9 @@ describe Qiita::Markdown::Processor do | |
| 1860 1849 | 
             
                          it "returns note block with class including icon" do
         | 
| 1861 1850 | 
             
                            should eq <<-HTML.strip_heredoc
         | 
| 1862 1851 | 
             
                              <div class="note info">
         | 
| 1863 | 
            -
                              <span class="fa fa-fw fa-check-circle"></span>< | 
| 1864 | 
            -
                               | 
| 1852 | 
            +
                              <span class="fa fa-fw fa-check-circle"></span><div>
         | 
| 1853 | 
            +
                              <p>Some kind of text is here.</p>
         | 
| 1854 | 
            +
                              </div>
         | 
| 1865 1855 | 
             
                              </div>
         | 
| 1866 1856 | 
             
                            HTML
         | 
| 1867 1857 | 
             
                          end
         | 
| @@ -1875,8 +1865,9 @@ describe Qiita::Markdown::Processor do | |
| 1875 1865 | 
             
                          it "returns warning note block with class including icon" do
         | 
| 1876 1866 | 
             
                            should eq <<-HTML.strip_heredoc
         | 
| 1877 1867 | 
             
                              <div data-type="customblock" data-metadata="note warn" class="note warn">
         | 
| 1878 | 
            -
                              <span class="fa fa-fw fa-exclamation-circle"></span>< | 
| 1879 | 
            -
                               | 
| 1868 | 
            +
                              <span class="fa fa-fw fa-exclamation-circle"></span><div>
         | 
| 1869 | 
            +
                              <p>Some kind of text is here.</p>
         | 
| 1870 | 
            +
                              </div>
         | 
| 1880 1871 | 
             
                              </div>
         | 
| 1881 1872 | 
             
                            HTML
         | 
| 1882 1873 | 
             
                          end
         | 
| @@ -1884,8 +1875,9 @@ describe Qiita::Markdown::Processor do | |
| 1884 1875 | 
             
                          it "returns note block with class including icon" do
         | 
| 1885 1876 | 
             
                            should eq <<-HTML.strip_heredoc
         | 
| 1886 1877 | 
             
                              <div class="note warn">
         | 
| 1887 | 
            -
                              <span class="fa fa-fw fa-exclamation-circle"></span>< | 
| 1888 | 
            -
                               | 
| 1878 | 
            +
                              <span class="fa fa-fw fa-exclamation-circle"></span><div>
         | 
| 1879 | 
            +
                              <p>Some kind of text is here.</p>
         | 
| 1880 | 
            +
                              </div>
         | 
| 1889 1881 | 
             
                              </div>
         | 
| 1890 1882 | 
             
                            HTML
         | 
| 1891 1883 | 
             
                          end
         | 
| @@ -1899,8 +1891,9 @@ describe Qiita::Markdown::Processor do | |
| 1899 1891 | 
             
                          it "returns alerting note block with class including icon" do
         | 
| 1900 1892 | 
             
                            should eq <<-HTML.strip_heredoc
         | 
| 1901 1893 | 
             
                              <div data-type="customblock" data-metadata="note alert" class="note alert">
         | 
| 1902 | 
            -
                              <span class="fa fa-fw fa-times-circle"></span>< | 
| 1903 | 
            -
                               | 
| 1894 | 
            +
                              <span class="fa fa-fw fa-times-circle"></span><div>
         | 
| 1895 | 
            +
                              <p>Some kind of text is here.</p>
         | 
| 1896 | 
            +
                              </div>
         | 
| 1904 1897 | 
             
                              </div>
         | 
| 1905 1898 | 
             
                            HTML
         | 
| 1906 1899 | 
             
                          end
         | 
| @@ -1908,8 +1901,9 @@ describe Qiita::Markdown::Processor do | |
| 1908 1901 | 
             
                          it "returns note block with class including icon" do
         | 
| 1909 1902 | 
             
                            should eq <<-HTML.strip_heredoc
         | 
| 1910 1903 | 
             
                              <div class="note alert">
         | 
| 1911 | 
            -
                              <span class="fa fa-fw fa-times-circle"></span>< | 
| 1912 | 
            -
                               | 
| 1904 | 
            +
                              <span class="fa fa-fw fa-times-circle"></span><div>
         | 
| 1905 | 
            +
                              <p>Some kind of text is here.</p>
         | 
| 1906 | 
            +
                              </div>
         | 
| 1913 1907 | 
             
                              </div>
         | 
| 1914 1908 | 
             
                            HTML
         | 
| 1915 1909 | 
             
                          end
         | 
| @@ -111,7 +111,6 @@ describe Qiita::Markdown::SummaryProcessor do | |
| 111 111 | 
             
                  it "flattens them" do
         | 
| 112 112 | 
             
                    should eq <<-EOS.strip_heredoc
         | 
| 113 113 | 
             
                      Lorem ipsum dolor sit amet.
         | 
| 114 | 
            -
             | 
| 115 114 | 
             
                      Consectetur adipisicing elit.
         | 
| 116 115 | 
             
                    EOS
         | 
| 117 116 | 
             
                  end
         | 
| @@ -254,7 +253,8 @@ describe Qiita::Markdown::SummaryProcessor do | |
| 254 253 |  | 
| 255 254 | 
             
                  it "does not generate footnote elements by default" do
         | 
| 256 255 | 
             
                    should eq <<-EOS.strip_heredoc
         | 
| 257 | 
            -
                       | 
| 256 | 
            +
                      [^1]
         | 
| 257 | 
            +
                      [^1]: test
         | 
| 258 258 | 
             
                    EOS
         | 
| 259 259 | 
             
                  end
         | 
| 260 260 | 
             
                end
         |