Skip to content

Commit 3b193f0

Browse files
trim white space as last serialization step
1 parent 0fd8723 commit 3b193f0

4 files changed

+16
-8
lines changed

R/serialize.R

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ serialize_parse_data_nested_helper <- function(pd_nested, pass_indent) {
3131

3232
#' Serialize a nested parse table
3333
#'
34-
#' Collapses a nested parse table into its character vector representation.
34+
#' Collapses a nested parse table into its character vector representation and
35+
#' removes trailing white spaces.
3536
#' @param pd_nested A nested parse table with line break, spaces and indention
3637
#' information.
3738
#' @return A character string.
@@ -48,7 +49,8 @@ serialize_parse_data_nested <- function(pd_nested) {
4849

4950
#' Serialize Flat Parse Data
5051
#'
51-
#' Collapses a parse table into character vector representation.
52+
#' Collapses a parse table into character vector representation and
53+
#' removes trailing white spaces.
5254
#' @param pd_flat A parse table.
5355
#' @details
5456
#' The function essentially collapses the column text of `pd_flat`
@@ -66,12 +68,14 @@ serialize_parse_data_flat <- function(pd_flat) {
6668
collapse = "")) %>%
6769
.[["text_ws"]] %>%
6870
strsplit("\n", fixed = TRUE) %>%
69-
.[[1L]]
71+
.[[1L]] %>%
72+
trimws(which = "right")
7073
}
7174

7275
#' Serialize flattened parse data
7376
#'
74-
#' Collapses a flattened parse table into character vector representation.
77+
#' Collapses a flattened parse table into character vector representation and
78+
#' removes trailing white spaces.
7579
#' @param flattened_pd A flattened parse table.
7680
serialize_parse_data_flattened <- function(flattened_pd) {
7781
flattened_pd$lag_newlines[1] <- flattened_pd$line1[1] - 1
@@ -84,7 +88,8 @@ serialize_parse_data_flattened <- function(flattened_pd) {
8488
collapse = "")) %>%
8589
.[["text_ws"]] %>%
8690
strsplit("\n", fixed = TRUE) %>%
87-
.[[1L]]
91+
.[[1L]] %>%
92+
trimws(which = "right")
8893

8994

9095
}

man/serialize_parse_data_flat.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/serialize_parse_data_flattened.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/serialize_parse_data_nested.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)