File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,12 @@ def initialize(options = {})
11
11
super
12
12
end
13
13
14
+ def preprocess ( document )
15
+ UniqueIdentifierGenerator . instance . reset
16
+
17
+ document
18
+ end
19
+
14
20
def paragraph ( text )
15
21
@app . api ( "<p>#{ text . strip } </p>\n " )
16
22
end
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ def hello_world
109
109
expect ( output ) . to include ( '<h1 id="a-heading">A heading</h1>' )
110
110
expect ( output ) . to include ( '<h2 id="a-subheading">A subheading</h2>' )
111
111
end
112
-
112
+
113
113
it "Ensures IDs are unique among headings in the page" do
114
114
output = processor . render <<~MARKDOWN
115
115
# A heading
@@ -130,5 +130,19 @@ def hello_world
130
130
# Finally the last occurence will get a prefix, but no number as it's in a different section
131
131
expect ( output ) . to include ( '<h3 id="another-subheading-a-shared-heading">A shared heading</h3>' )
132
132
end
133
+
134
+ it "Does not consider unique IDs across multiple renders" do
135
+ first_output = processor . render <<~MARKDOWN
136
+ # A heading
137
+ ## A subheading
138
+ MARKDOWN
139
+
140
+ second_output = processor . render <<~MARKDOWN
141
+ # A heading
142
+ ## A subheading
143
+ MARKDOWN
144
+
145
+ expect ( second_output ) . to include ( '<h2 id="a-subheading">A subheading</h2>' )
146
+ end
133
147
end
134
148
end
You can’t perform that action at this time.
0 commit comments