Starting with a song file MHALL.txt
(Mary Had A Little Lamb), according to the OP's desired format:
Mary Had a Little Lamb
Anonymous
Children's song
^{A}Mary had a little lamb,
^{E}Little lamb, ^{A}little lamb,
^{A}Mary had a little lamb,
Its ^{E}fleece was white as ^{A}snow.
^{A}Everywhere that Mary went,
^{E}Mary went, ^{A}Mary went,
^{A}Everywhere that Mary went
The ^{E}lamb was sure to ^{A}go
It ^{A$\sharp$}followed her to school one day
...
and the following short code using readarray
, the output may be formatted as an annotated song lyric. I don't know anything about a guitar
environment, so I created my own format for "formatting" chords, namely, to top-lap the chord name, using the input syntax ^{<chord name>}
as an active input from the input file. Note that chord names like ^{A$\flat$}
are perfectly suitable to this input style. Obviously, this part of the formatting can be tailored to the OP's desires.
\documentclass{article}
\usepackage{readarray,forloop,stackengine}
\setstackgap{L}{.9\baselineskip}% VERTICAL CHORD POSITION
\newcounter{songlines}
{\catcode`\^=\active
\gdef^#1{\trlap{\fbox{\tiny\sffamily\bfseries#1}}}}% CHORD FORMAT
\newcommand\formatsong[1]{%
\bgroup
\catcode`\^=\active
\readrecordarray{#1}\songdata
\section{\songdata[1]}%
\paragraph{\songdata[2]}%
\textit{\songdata[3]}%
\begin{quote}
\forloop{songlines}{4}{\value{songlines}<\nrecords}{%
\songdata[\thesonglines]\\
}%
\end{quote}
\egroup
}
\fboxsep=2pt
\begin{document}
\formatsong{MHALL.txt}
\end{document}

SUPPLEMENT
Just to show how the chord format can be adjusted to suit, I grab some routines from my answer at Typesetting guitar chord diagrams in a songbook and to my prior code, I merely enlarge the VERTICAL CHORD POSITION (to allow room for the chord typesetting) and simplify the CHORD FORMAT (removing all extraneous formatting).
Then, using the pulled-in routines to define for the user guitar chords like \Cm
(C-minor) and \GM
(G-major), I can allow the user to specify these as the chords in the input file:
Mary Had a Little Lamb
Anonymous
Children's song
^{\Cm}Mary had a little lamb,
^{\GM}Little lamb, ^{\Cm}little lamb,
...
Then, with this augmented code,
\documentclass{article}
\usepackage{readarray,forloop,stackengine}
\setstackgap{L}{2.7\baselineskip}% VERTICAL CHORD POSITION
\newcounter{songlines}
{\catcode`\^=\active
\gdef^#1{\trlap{#1}}}% CHORD FORMAT
\newcommand\formatsong[1]{%
\bgroup
\catcode`\^=\active
\readrecordarray{#1}\songdata
\section{\songdata[1]}%
\paragraph{\songdata[2]}%
\textit{\songdata[3]}%
\begin{quote}
\forloop{songlines}{4}{\value{songlines}<\nrecords}{%
\songdata[\thesonglines]\\
}%
\end{quote}
\egroup
}
\fboxsep=2pt
% FOLLOWING PULLED FROM ANSWER AT
% https://tex.stackexchange.com/questions/324828/typesetting-guitar-chord-diagrams-in-a-songbook/324924#324924
\usepackage{musixguit}
\def\chordalign{\dimexpr2.2ex}% 2.2ex sets alignment of chord
\def\chordminwidth{\dimexpr6.5ex}% 6.5ex provides min. hskip for optional argument
\newcommand\guitarchord[2]{%
\savestack#1{\kern\chordalign\NOtes\guitar #2\en}
}
\newcommand\showchord[2][\relax]{%
\ifx\relax#1\relax\def\tmpuaw{T}\else\def\tmpuaw{F}\fi%
\stackengine{\Lstackgap}{#1}{%
\makebox[0ex][l]{#2}\kern\chordminwidth}{O}{l}{F}{\tmpuaw}{L}%
}
\newcommand\chordline[2]{\setbox0=\hbox{#2}%
\ifdim\wd0>\chordminwidth\showchord{#1}#2\else\showchord[#2]{#1}\fi%
}
\raiseguitar {0}
\guitarchord\Cm{{Cm $^7$}{2}x-----\gbarre1\gdot33\gdot52}
\guitarchord\GM{G{}o-----\gbarre3\gdot25\gdot35\gdot44}
%
\begin{document}
\formatsong{MHALL.txt}
\end{document}
the result may be more what the OP had in mind:
