Skip to content

Commit ac1ad0c

Browse files
committed
Add warning to the trim_text and trim_text_end methods
1 parent 6a11473 commit ac1ad0c

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/reader/mod.rs

+24-2
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,21 @@ macro_rules! configure_methods {
4242
///
4343
/// Changing this option automatically changes the [`trim_text_end`] option.
4444
///
45-
/// (`false` by default)
45+
/// (`false` by default).
46+
///
47+
/// <div style="background:rgba(80, 240, 100, 0.20);padding:0.75em;">
48+
///
49+
/// WARNING: With this option every text events will be trimmed which is
50+
/// incorrect behavior when text events delimited by comments, processing
51+
/// instructions or CDATA sections. To correctly trim data manually apply
52+
/// [`BytesText::inplace_trim_start`] and [`BytesText::inplace_trim_end`]
53+
/// only to necessary events.
54+
/// </div>
4655
///
4756
/// [`Text`]: Event::Text
4857
/// [`trim_text_end`]: Self::trim_text_end
58+
/// [`BytesText::inplace_trim_start`]: crate::events::BytesText::inplace_trim_start
59+
/// [`BytesText::inplace_trim_end`]: crate::events::BytesText::inplace_trim_end
4960
pub fn trim_text(&mut self, val: bool) -> &mut Self {
5061
self $(.$holder)? .parser.trim_text_start = val;
5162
self $(.$holder)? .parser.trim_text_end = val;
@@ -57,9 +68,20 @@ macro_rules! configure_methods {
5768
/// When set to `true`, trailing whitespace is trimmed in [`Text`] events.
5869
/// If after that the event is empty it will not be pushed.
5970
///
60-
/// (`false` by default)
71+
/// (`false` by default).
72+
///
73+
/// <div style="background:rgba(80, 240, 100, 0.20);padding:0.75em;">
74+
///
75+
/// WARNING: With this option every text events will be trimmed which is
76+
/// incorrect behavior when text events delimited by comments, processing
77+
/// instructions or CDATA sections. To correctly trim data manually apply
78+
/// [`BytesText::inplace_trim_start`] and [`BytesText::inplace_trim_end`]
79+
/// only to necessary events.
80+
/// </div>
6181
///
6282
/// [`Text`]: Event::Text
83+
/// [`BytesText::inplace_trim_start`]: crate::events::BytesText::inplace_trim_start
84+
/// [`BytesText::inplace_trim_end`]: crate::events::BytesText::inplace_trim_end
6385
pub fn trim_text_end(&mut self, val: bool) -> &mut Self {
6486
self $(.$holder)? .parser.trim_text_end = val;
6587
self

0 commit comments

Comments
 (0)