[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ASCII formatting for plain text email



On Tue, Jan 31, 2023 at 11:06:44PM +0100, Pierre Willaime wrote:
> I do not want to do ASCII art, I am only searching a simple way to do
> something close to the debian-annouce emails.
> 
> ------------------------------------------------------------------------
> The Debian Project                               https://www.debian.org/
> Updated Debian 11: 11.6 released                        press@debian.org
> December 17th, 2022            https://www.debian.org/News/2022/20221217
> ------------------------------------------------------------------------
> 
> How this header is generated?

I see 3 constant fields and 3 variable fields in there, so I'm guessing
this header is generated by software.  Like, someone is using an
*application* to write those announcements, so that they're stored in
a database, formatted in a consistent way, propagated to that URL you
see in the header, and so on.  Might be a web-based app, might not.

> 1- a simple way to draw a line (without pressing 72 times on "-")
> -----------------------------------------------------------------------

In the programming language used to write whatever application is
generating those announcements, I'm sure there are several ways to
produce a string of hyphens of a given length.

But you seem to want to use a text editor, rather than an application.
In a text editor, you either press - 72 times, or you hold - down until
approximately the right number of hyphens appears (and then fix it up),
or you paste a line of hyphens from an outside source, or you have some
kind of macro or other editor-specific feature.

If you do periodic announcement emails, perhaps you have one from last
month (or last week, or whenever).  You could copy the top of that one
and then edit it.  Or at least copy the formatting characters.

> 2- a simple way to align some text to the right

In many languages, printf.  If it's not printf, then it'll be some
other function or method that's designed for producing very simple
formatted text strings.

In a text editor?  Type a bunch of spaces.

> 3- a simple way to do boxes (no present in debian-annouce header)

Again, a programming language can easily take an input string, measure
its length in characters, and produce an output string that looks like
a "box" around the input string.  (Less easily if full Unicode is in play.)

In a text editor?  See previous answers.


Reply to: