Closed TylerFisher closed 2 years ago
I've spent some time with the various options google docs offers for formatting text, and then how that formatting carries through to the data from the docs api.
From what I can tell, there are two options to note lines of poetry: format the lines differently from all the other text, or use a start & end marker.
I wish we could make our own custom text style and call it "POEM" but I don't see how to do that in Google Docs. Using an existing format (ex: highlight; superscript; strikethrough; red text color) seems either like a hack or prone to confusion (what if the text should just be red and is not poetry?). To be fair... this is a hack, but I don't want to make things confusing.
Using a start and end marker might be better, then, as it's clear and doesn't co-opt another format's meaning. The data that comes through treats each line as a separate element:
{"paragraph":{"elements":[{"textRun":{"content":"POEM START\n","textStyle":{}},"startIndex":1,"endIndex":12}],"paragraphStyle":{"namedStyleType":"NORMAL_TEXT","direction":"LEFT_TO_RIGHT"}},"startIndex":1,"endIndex":12}
// I've omitted most of the lines here for brevity
{"startIndex":12,"endIndex":26,"paragraph":{"elements":[{"startIndex":12,"textRun":{"textStyle":{},"content":" in the rain-\n"},"endIndex":26}],"paragraphStyle":{"namedStyleType":"NORMAL_TEXT","direction":"LEFT_TO_RIGHT"}}}
{"endIndex":402,"startIndex":391,"paragraph":{"paragraphStyle":{"direction":"LEFT_TO_RIGHT","namedStyleType":"NORMAL_TEXT"},"elements":[{"endIndex":402,"startIndex":391,"textRun":{"textStyle":{},"content":" \tof you\n"}}]}}
{"paragraph":{"paragraphStyle":{"direction":"LEFT_TO_RIGHT","namedStyleType":"NORMAL_TEXT"},"elements":[{"endIndex":410,"textRun":{"content":"POEM END","textStyle":{}},"startIndex":402},{"textRun":{"textStyle":{},"content":"\n"},"endIndex":411,"startIndex":410}]},"startIndex":402,"endIndex":411}
This is using a poem by e.e. cummings as an example - here's the google doc.
A few things would need to change in the processDocumentContents
function:
POEM START
in the content of the line of textPOEM START
, give them a custom namedStyleType
of our own, like poem
instead of copying the default paragraph type of NORMAL_TEXT
from the dataPOEM END
and note the indexpoem start
& poem end
will be marked as poem
poem
should also not get the text cleanup applied to it, so extra spaces and so on are preservedI feel like this could work. Then the front-end could use a special node to format poems differently than other text.
What do you think?
Crystal publishes poetry from her community, which obviously has unique spacing and line break needs. Is there some way we can mark a section of content as-is kind of like backticks on a coding-forward platform?