Skip to content

Commit 50d75cb

Browse files
committed
Fix bug where addCustomType would fail if setAllowedTypes was called prior
1 parent 8cb6a98 commit 50d75cb

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

commonmark-ext-gfm-alerts/src/main/java/org/commonmark/ext/gfm/alerts/AlertsExtension.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public Builder setAllowedTypes(Map<String, String> allowedTypes) {
150150
}
151151
}
152152

153-
this.allowedTypes = Map.copyOf(allowedTypes);
153+
this.allowedTypes = new HashMap<>(allowedTypes);
154154
return this;
155155
}
156156

commonmark-ext-gfm-alerts/src/test/java/org/commonmark/ext/gfm/alerts/AlertsTest.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ public void customTypeTitleMustNotBeEmpty() {
141141
@Test
142142
public void removeStandardTypes() {
143143
var allowedTypes = Map.ofEntries(Map.entry("IMPORTANT", "Important"));
144-
var extension = AlertsExtension.builder().setAllowedTypes(allowedTypes).build();
144+
var extension = AlertsExtension.builder()
145+
.setAllowedTypes(allowedTypes)
146+
.addCustomType("BUG", "Known Bug")
147+
.build();
145148
var parser = Parser.builder().extensions(Set.of(extension)).build();
146149
var renderer = HtmlRenderer.builder().extensions(Set.of(extension)).build();
147150

@@ -162,6 +165,12 @@ public void removeStandardTypes() {
162165
"<p class=\"markdown-alert-title\">Important</p>\n" +
163166
"<p>Alert</p>\n" +
164167
"</div>\n");
168+
169+
assertThat(renderer.render(parser.parse("> [!BUG]\n> Alert"))).isEqualTo(
170+
"<div class=\"markdown-alert markdown-alert-bug\" data-alert-type=\"bug\">\n" +
171+
"<p class=\"markdown-alert-title\">Known Bug</p>\n" +
172+
"<p>Alert</p>\n" +
173+
"</div>\n");
165174
}
166175

167176
// Custom titles

0 commit comments

Comments
 (0)