Skip to content

Commit

Permalink
fix: Handle returns in open ended questions
Browse files Browse the repository at this point in the history
When generating bullet points, any newline we write is treated as a new
bullet point. This is problematic if the survey responses include a new
line.

To prevent this issue, we replace newlines in answers with \u000b which
is the line tabulation unicode character. In this way, we preserve the
breaks without creating new bullet points.
  • Loading branch information
keelerm84 committed Dec 27, 2020
1 parent 73d7d00 commit 28c9f12
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions surveydoc/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,14 @@ def divergent_bar_chart(self, question, image_path):
self.insert_text("Comments")
self.change_style("HEADING_2", "START")
self.insert_text("")
# TODO(mmk) We are going to have to generate something for the images in inline_objects

def text_summary(self, question, answers):
self.insert_text(question)
self.change_style("HEADING_1", "START")

# TODO(mmk) If the answers have a newline in them, then they are being
# separated out into different bullet points. We need to convert the newlines to the line tabulation character (\u000b)
self.insert_text("\n".join(answers))
formatted = [answer.replace("\n", u"\u000b") for answer in answers]

self.insert_text("\n".join(formatted))
self.change_to_bullets()

self.insert_text("Comments")
Expand Down

0 comments on commit 28c9f12

Please sign in to comment.