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
19 changes: 8 additions & 11 deletions src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,31 +820,28 @@ impl Render<Message> for HarmonyEncoding {
}
};

// 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you intentionally reversed the order of recipient/channel?

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)?;
}

// 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 content type with mandatory leading space
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