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
pull/17742/head
Stephane Nicoll 5 years ago
commit e419aab00f

@ -76,7 +76,8 @@ class SingleConfigurationTableEntry extends ConfigurationTableEntry {
builder.append("|"); builder.append("|");
} }
else { else {
builder.append("|+++", this.description, "+++"); String cleanedDescription = this.description.replace("|", "\\|");
builder.append("|+++", cleanedDescription, "+++");
} }
} }

@ -86,6 +86,19 @@ class SingleConfigurationTableEntryTests {
+ "|+++This is a description.+++" + NEWLINE); + "|+++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 @Test
void mapProperty() { void mapProperty() {
ConfigurationMetadataProperty property = new ConfigurationMetadataProperty(); ConfigurationMetadataProperty property = new ConfigurationMetadataProperty();

Loading…
Cancel
Save