Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,31 +820,29 @@ impl Render<Message> for HarmonyEncoding {
}
};

// next render the header recipient, if there is one
if let Some(recipient) = &message.recipient {
if recipient != "all" {
self.render_text_into(format!(" to={recipient}"), into)?;
}
}

// next header channel
if let Some(channel) = &message.channel {
self.render_formatting_token_into(FormattingToken::Channel, into)?;
self.render_text_into(channel, into)?;
}

// next render the header recipient, if there is one
if let Some(recipient) = &message.recipient {
if recipient != "all" {
self.render_text_into(" to", into)?;
self.render_text_into(format!("={recipient}"), into)?;
}
}

// finally content type
if let Some(content_type) = &message.content_type {
// <|constrain|> is a unique case which needs to be tokenized as a special token
if let Some(constrain_marker) =
self.mapped_format_token(FormattingToken::ConstrainedFormat)
{
if let Some(rest) = content_type.strip_prefix(constrain_marker) {
// Render the space, then the constrain marker as a special token, then the rest as text (if any)
self.render_text_into(" ", into)?;
self.render_formatting_token_into(FormattingToken::ConstrainedFormat, into)?;
// Render the rest as text (if any)
if !rest.is_empty() {
self.render_text_into(rest, into)?;
self.render_text_into(format!(" {rest}"), into)?;
}
} else {
self.render_text_into(format!(" {content_type}"), into)?;
Expand Down