--- /dev/null
+%% This is an extension of Martin Väth's *guitar* package with high
+%% level environments for song sectioning: chorus, verse and
+%% bridge, etc.
+
+%% Author: Gustav Eek <gustav.eek@fripost.org>
+
+%% Licence: GNU GPL v3
+
+%% This is a LaTeX3 package (LaTeX3 is actually LaTeX continued on top
+%% of LaTeX2e). See [Introduction to LaTeX3
+%% ideas](http://texdoc.net/pkg/expl3) for throughout details.
+
+%% The inspiration is the ChordPro format as well as Ultimate Guitar's
+%% sectioning in their text format and Wikipedia's "Song structure",
+%% "Verse–chorus form". Pre-defined song sections:
+%%
+%% * Introduction, intro,
+%% * Verse, verse,
+%% * Bridge, bridge,
+%% * Pre-chorus prech,
+%% * Chorus or refrain, chorus,
+%% * Post-chorus postch,
+%% * Conclusion or outro, outro,
+%% * Elision, elison,
+%% * Instrumental solo, instr,
+%% * Ad lib, ad-lib,
+%% * Break, break,
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesExplPackage{
+ guitarsections}{
+ 2024-08-08}{0.2}{
+ An extension of Martin Väth's {\em guitar} package with high level
+ environments for sections: chorus, verse and bridge. The inspiration
+ is the ChordPro format.}
+\RequirePackage{guitar}[v1.6]
+\RequirePackage{xparse}
+%% Use lengths \labelwidth (default 20 pt, 2 em in normal font size) and
+%% \labelsep (default 5 pt, 0.5 em = 1.15 ex in normal font size)
+
+\RequirePackage{calc}
+
+\newlength{\labelrule}
+\setlength{\labelwidth}{2em}
+\setlength{\labelsep}{2.5ex}
+\setlength{\labelrule}{2pt}
+
+%% Style declaration commands, implemented with LaTeX3 property lists
+
+\NewDocumentCommand\guitarLabelDelim{}{:~}
+
+\PassOptionsToPackage{svgnames}{xcolor}
+\RequirePackage{xcolor}
+\colorlet{gtr@default@sty}{darkgray}
+
+
+%%
+
+\def\gtr@default@stylabel{} % empty by default
+\NewDocumentCommand\guitarFont{}{\sffamily\itshape\small}
+\NewDocumentCommand\guitarFontChords{}{\guitarFont\color{gtr@let@heavy-red}}
+\NewDocumentCommand\guitarFontRespMusic{}{\guitarFont\color{gtr@let@heavy-purple}}
+\NewDocumentCommand\guitarFontRespStruct{}{\guitarFont\color{gtr@let@heavy-blue}}
+
+
+\tl_new:N \gtr_key %% temporary variable
+\tl_new:N \gtr_val %% temporary variable
+\prop_new:N \gtr_stycolors %% data structure
+\prop_new:N \gtr_stylabels %% data structure
+
+\NewDocumentCommand\guitarStyle{O{} m}{%
+ \tl_set:Nx \gtr_key {\tl_lower_case:n {#2}}
+ \str_if_empty:nTF{#1}{
+ \prop_if_in:NoTF\gtr_stycolors\gtr_key{}{
+ \prop_put:Non\gtr_stycolors\gtr_key{gtr@default@sty}}
+ }{
+ \prop_put:Non\gtr_stycolors\gtr_key{#1}
+ }
+}
+
+\NewDocumentCommand\guitarSectionStyle{O{} O{} m}{%
+ \tl_set:Nx \gtr_key {\tl_lower_case:n {#3}}
+ \guitarStyle[#1]{#3}
+ \str_if_empty:nTF{#2}{
+ \prop_if_in:NoTF\gtr_stylabels\gtr_key{}{
+ \prop_put:Non\gtr_stylabels\gtr_key{#3}}
+ }{
+ \prop_put:Non\gtr_stylabels\gtr_key{#2}
+ }
+}
+
+\NewDocumentCommand{\gtr_color}{m}{
+ \tl_set:Nx \gtr_key {\tl_lower_case:n {#1}}%
+ \tl_clear:N \gtr_val%
+ \prop_get:NoN \gtr_stycolors \gtr_key \gtr_val%
+ \color{\gtr_val}%
+}
+
+\NewDocumentCommand{\gtr_get_label}{o m}{
+ \tl_set:Nx \gtr_key {\tl_lower_case:n {#2}}%
+ \tl_clear:N \gtr_val%
+ \prop_get:NoN \gtr_stylabels \gtr_key \gtr_val%
+ \gtr_val%%
+ \IfValueT{#1}{\guitarLabelDelim#1}%
+}
+
+
+%% Define guitar section environment commands
+
+\RequirePackage{rotating}
+\setlength\fboxsep{-\fboxrule}
+\newlength\gtr@versewidth
+
+\guitarStyle{chords} %% place holder chords style
+
+\NewDocumentEnvironment{guitarSection}{o m o}{
+ \let\gtr@precrd@push\guitarPreAccord%
+ \def\guitarPreAccord{\guitarFont\gtr_color{chords}\gtr@precrd@push}%
+ \noindent%
+ \IfValueTF{#3}{%
+ \settowidth\gtr@versewidth{#3}%
+ \addtolength\gtr@versewidth{\labelwidth}%
+ }{%
+ \setlength\gtr@versewidth{\linewidth - \labelwidth}%
+ }%
+ \makebox[\labelwidth - \labelsep][r]{%
+ \IfValueT{#1}{%
+ \raisebox{1\baselineskip - 2pt}{
+ \rotatebox{90}{%
+ \makebox[0pt][r]{%
+ \guitarFont\gtr_color{#2}\gtr_get_label[#1]{#2}
+ }
+ }
+ }
+ }}
+ \hspace{%
+ .5\labelsep - \labelrule%
+ }{\gtr_color{#2}\vline width \labelrule}\hspace{.5\labelsep}%
+ \begin{minipage}[t]{\gtr@versewidth}%
+ \noindent%
+ \begin{guitar}%
+}{%
+ \par\vspace{- 1em + 2pt}%
+ \end{guitar}%
+ \end{minipage}%
+ \let\guitarPreAccord\gtr@precrd@push%
+}
+
+\NewDocumentCommand{\guitarSectionAgain}{o m}{
+ \noindent%
+ \hspace{\labelwidth - \labelsep}%
+ \hspace{.5\labelsep - \labelrule}%
+ \mbox{%
+ \guitarFont\gtr_color{#2}%
+ \vline width \labelrule \hspace{.5\labelsep}%
+ \gtr_get_label[#1]{#2}%
+ }%
+}
+
+%% Provide annotation commands
+\newlength\gtr_annotfill
+
+\NewDocumentCommand\guitarAnnot{m m}{%
+ \mbox{}\hfill\mbox{}{\guitarFont\gtr_color{#1}\hspace{1ex}#2\hspace{1ex}}\mbox{}%
+}
+
+%% Provide a horrizontal pragraph ruler
+
+\NewDocumentCommand\guitarRule{o m}{%
+ \begin{flushleft}%
+ {\gtr_color{#2}\rule{\IfValueTF{#1}{#1}{\linewidth}}{.2pt}}%
+ \end{flushleft}%
+}
+
+%% Define the color pallet for pre-configured sections
+
+\colorlet{blackgray}{black!75!darkgray}
+\colorlet{turquoisegreen}{cyan!25!green}
+\colorlet{orangelime}{orange!75!lime}
+
+\colorlet{gtr@let@black}{black}
+\colorlet{gtr@let@heavy-red}{black!50!red}
+\colorlet{gtr@let@soft-orange-green}{lightgray!25!orange!50!olive}
+\colorlet{gtr@let@medium-orange}{black!25!orangelime}
+\colorlet{gtr@let@soft-orange}{lightgray!50!orange}
+\colorlet{gtr@let@medium-yellow-green}{darkgray!50!lime}
+\colorlet{gtr@let@heavy-green}{black!65!green}
+\colorlet{gtr@let@medium-green}{blackgray!65!green}
+\colorlet{gtr@let@soft-green}{darkgray!50!green}
+\colorlet{gtr@let@medium-turquoise-green}{darkgray!50!turquoisegreen}
+\colorlet{gtr@let@soft-turquoise-green}{gray!50!turquoisegreen}
+\colorlet{gtr@let@medium-turquoise}{darkgray!50!cyan}
+\colorlet{gtr@let@heavy-blue}{blackgray!50!teal!75!blue}
+\colorlet{gtr@let@heavy-purple}{blackgray!50!violet!75!blue}
+
+\colorlet{gtr@sty@chords}{gtr@let@heavy-red}
+
+\colorlet{gtr@sty@intro}{gtr@let@medium-turquoise}
+\colorlet{gtr@sty@verse}{gtr@let@soft-turquoise-green}
+\colorlet{gtr@sty@bridge}{gtr@let@medium-turquoise-green}
+\colorlet{gtr@sty@prechorus}{gtr@let@soft-green}
+\colorlet{gtr@sty@chorus}{gtr@let@heavy-green}
+\colorlet{gtr@sty@postchorus}{gtr@let@medium-green}
+\colorlet{gtr@sty@break}{gtr@let@medium-yellow-green}
+\colorlet{gtr@sty@instr}{gtr@let@medium-orange}
+\colorlet{gtr@sty@elison}{gtr@let@soft-orange-green}
+\colorlet{gtr@sty@adlib}{gtr@let@soft-orange-green}
+\colorlet{gtr@sty@outro}{gtr@let@medium-turquoise}
+
+\colorlet{gtr@sty@music}{gtr@let@heavy-purple}
+\colorlet{gtr@sty@structure}{gtr@let@heavy-blue}
+
+%% Finally define the actual pre-configured sections
+
+\guitarSectionStyle[gtr@sty@intro]{Intro}
+\guitarSectionStyle[gtr@sty@verse]{Verse}
+\guitarSectionStyle[gtr@sty@bridge]{Bridge}
+\guitarSectionStyle[gtr@sty@prechorus]{Pre-chorus}
+\guitarSectionStyle[gtr@sty@chorus]{Chorus}
+\guitarSectionStyle[gtr@sty@postchorus]{Post-chorus}
+\guitarSectionStyle[gtr@sty@break]{Break}
+\guitarSectionStyle[gtr@sty@instr][Instrumental]{instr}
+\guitarSectionStyle[gtr@sty@elison]{Elision}
+\guitarSectionStyle[gtr@sty@adlib]{Ad lib}
+\guitarSectionStyle[gtr@sty@outro]{Outro}
+
+%% Defnide other pre-configured annotations and other styles
+
+\guitarStyle[gtr@sty@chords]{chords}
+\guitarStyle[gtr@sty@music]{music}
+\guitarStyle[gtr@sty@structure]{structure}
+
+%% Utility commands. Activation commands are for client usage. These
+%% will not be modified internally
+
+\NewDocumentCommand\guitarActivate{m}{%
+ \tl_set:Nx \gtr_key {\tl_lower_case:n {#1}}%
+ \tl_clear:N \gtr_val%
+ \prop_get:NoN \gtr_stycolors \gtr_key \gtr_val%
+ \colorlet{gtr@active}{\gtr_val}%
+}
+\NewDocumentCommand\guitarActiveFont{}{%
+ \guitarFont\color{gtr@active}}
+