blob: 55575d4cf846be55b7f5d8cd1d88804b71ed2c72 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Banzai::Pipeline::PreProcessPipeline, feature_category: :team_planning do
it 'pre-processes the source text' do
markdown = <<~MD
\xEF\xBB\xBF---
foo: :foo_symbol
bar: :bar_symbol
---
>>>
blockquote
>>>
MD
result = described_class.call(markdown, {})
aggregate_failures do
expect(result[:output]).not_to include "\xEF\xBB\xBF"
expect(result[:output]).not_to include '---'
expect(result[:output]).to include "```yaml:frontmatter\nfoo: :foo_symbol\n"
expect(result[:output]).to include "> blockquote\n"
end
end
it 'truncates the text if requested' do
text = (['foo'] * 10).join(' ')
result = described_class.call(text, limit: 12)
expect(result[:output]).to eq('foo foo f...')
end
context 'when multiline blockquote' do
it 'data-sourcepos references correct line in source markdown' do
markdown = <<~MD
>>>
foo
>>>
MD
pipeline_output = described_class.call(markdown, {})[:output]
pipeline_output = Banzai::Pipeline::PlainMarkdownPipeline.call(pipeline_output, {})[:output]
sourcepos = pipeline_output.at('blockquote')['data-sourcepos']
source_line = sourcepos.split(':').first.to_i
expect(markdown.lines[source_line - 1]).to eq "foo\n"
end
end
end
|