Merge pull request #17663 from vivganes
* pr/17663: Polish "Escape reserved asciidoc character in generated documentation" Escape reserved asciidoc character in generated documentation Closes gh-17663
This commit is contained in:
@@ -76,7 +76,8 @@ class SingleConfigurationTableEntry extends ConfigurationTableEntry {
|
||||
builder.append("|");
|
||||
}
|
||||
else {
|
||||
builder.append("|+++", this.description, "+++");
|
||||
String cleanedDescription = this.description.replace("|", "\\|");
|
||||
builder.append("|+++", cleanedDescription, "+++");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +86,19 @@ class SingleConfigurationTableEntryTests {
|
||||
+ "|+++This is a description.+++" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void descriptionWithPipe() {
|
||||
ConfigurationMetadataProperty property = new ConfigurationMetadataProperty();
|
||||
property.setId("spring.test.prop");
|
||||
property.setDescription("This is a description with a | pipe.");
|
||||
property.setType("java.lang.String");
|
||||
SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property);
|
||||
AsciidocBuilder builder = new AsciidocBuilder();
|
||||
entry.write(builder);
|
||||
assertThat(builder.toString()).isEqualTo("|`+spring.test.prop+`" + NEWLINE + "|" + NEWLINE
|
||||
+ "|+++This is a description with a \\| pipe.+++" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapProperty() {
|
||||
ConfigurationMetadataProperty property = new ConfigurationMetadataProperty();
|
||||
|
||||
Reference in New Issue
Block a user