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 = {})
1111 super
1212 end
1313
14+ def preprocess ( document )
15+ UniqueIdentifierGenerator . instance . reset
16+
17+ document
18+ end
19+
1420 def paragraph ( text )
1521 @app . api ( "<p>#{ text . strip } </p>\n " )
1622 end
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ def hello_world
109109 expect ( output ) . to include ( '<h1 id="a-heading">A heading</h1>' )
110110 expect ( output ) . to include ( '<h2 id="a-subheading">A subheading</h2>' )
111111 end
112-
112+
113113 it "Ensures IDs are unique among headings in the page" do
114114 output = processor . render <<~MARKDOWN
115115 # A heading
@@ -130,5 +130,19 @@ def hello_world
130130 # Finally the last occurence will get a prefix, but no number as it's in a different section
131131 expect ( output ) . to include ( '<h3 id="another-subheading-a-shared-heading">A shared heading</h3>' )
132132 end
133+
134+ it "Does not consider unique IDs across multiple renders" do
135+ 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
133147 end
134148end
You can’t perform that action at this time.
0 commit comments