with Expl3, environ and tcolorbox one can make an environment that will put each piece of text ending with a white line in a box. I'd like to modify its code given below so that it also fills the "Title" optional field of a tcolobox box and the upper - lower parts. For example in a cyclic way filling in the same order "Tile", "upper" part, and "lower" part as it finds lines ending with a blank line or \end{mynewenviron}. "mynewenviron" being the name of the environ created for this purpose.
\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{xcolor}
\usepackage{varwidth}
\usepackage{environ}
\usepackage{xparse}
\newlength{\bubblesep}
\newlength{\bubblewidth}
\setlength{\bubblesep}{2pt}
\AtBeginDocument{\setlength{\bubblewidth}{.75\textwidth}}
\newcommand{\bubble}[1]{%
\tcbox[
on line,
arc=2.5mm,
rounded corners,
]{\begin{varwidth}{\bubblewidth}#1\end{varwidth}}%
}
\ExplSyntaxOn
\seq_new:N \l__ooker_bubbles_seq
\tl_new:N \l__ooker_bubbles_first_tl
\tl_new:N \l__ooker_bubbles_last_tl
\NewEnviron{rightbubbles}
{
\begin{flushright}
\sffamily
\seq_set_split:NnV \l__ooker_bubbles_seq { \par } \BODY
\int_compare:nTF { \seq_count:N \l__ooker_bubbles_seq < 2 }
{
\bubble{\BODY}\par
}
{
\seq_pop_left:NN \l__ooker_bubbles_seq \l__ooker_bubbles_first_tl
\seq_pop_right:NN \l__ooker_bubbles_seq \l__ooker_bubbles_last_tl
\bubble{\l__ooker_bubbles_first_tl}
\par\nointerlineskip
\addvspace{\bubblesep}
\seq_map_inline:Nn \l__ooker_bubbles_seq
{
\bubble{##1}
\par\nointerlineskip
\addvspace{\bubblesep}
}
\bubble{\l__ooker_bubbles_last_tl}
\par
}
\end{flushright}
}
\ExplSyntaxOff
\begin{document}
\begin{rightbubbles}
Right-aligned gray bubbles (103, 184,104) with white text
Bubbles only break after a paragraph (equivalent to an enter press
when chatting). Long message with multiple lines will be kept in one bubble.
Left and right edges are round.
Single
\end{rightbubbles}
\begin{rightbubbles}
Single
\end{rightbubbles}
\end{document}
\par. So, messing around with blank lines could also be achieved by redefining\par, I think. Second, I personally don't think\parshould be hijacked. For example, you could instead use thetcbitemizeenvironment by the tcolorbox package, if you don't mind adding\tcbitembefore each speaker. Maybe there is a way to define\paras\tcbitemin a custom environment but I couldn't figure it out. – jessexknight Nov 25 '20 at 14:50\parthen blank lines will also invoke the new definition. – jessexknight Nov 25 '20 at 19:17