2017 © Pedro Peláez
 

library tlac

Typeset lyrics with chords

image

ludviki/tlac

Typeset lyrics with chords

  • Tuesday, June 3, 2014
  • by ludviki
  • Repository
  • 1 Watchers
  • 1 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 36 % Grown

The README.md

Build Status Scrutinizer Code Quality Code Coverage, (*1)

TLAC - Typeset Lyrics And Chords

Typeset lyrics and chords by writing text, inspired by Markdown (see here and here). The lyrics and chords may be rendered as Html and/or Pdf. PDFs are created using TCPDF., (*2)

Anax-MVC users see extra description at the end., (*3)

Usage

It is recommended to use Composer to install TLAC, handling the dependency (just TCPDF) and autoloading is easy that way. Add TLAC as requirement to your composer.json (watch out for version updates!):, (*4)

``` .json "require": { "ludviki/tlac": "1.0.*", ... }, (*5)


Be sure to have the autoloader loaded (`require '../vendor/autoload.php';` if you don't have it already included). We assume the source is given in a text file but you can take it from a database or whatever. ### Html ``` .php use ludviki\TLAC\TLAC; $song = file_get_contents($filePath); $tlac = new TLAC(); $html = $tlac->toHtml($song);

$html holds the rendered HTML, embed it where you want. Be sure to link to the stylesheet chords.css (found in the example/ directory., (*6)

Pdf

```.php use ludviki\TLAC\TLAC;, (*7)

$song = file_get_contents($filePath);, (*8)

$tlac = new TLAC(); $pdf = $tlac->toPdf($song);, (*9)


`$pdf` is an instance of the `\TCPDF` class. I refer to the [documentation](http://www.tcpdf.org/doc/code/classTCPDF.html#a3d6dcb62298ec9d42e9125ee2f5b23a1), for more information about how to further process the Pdf. To send it as answer to an http request you can do this (which also sends the correct headers) ```.php $pdf->Output('tlac.pdf', 'I');

or more advanced stuff using your frameworks respons object. To save it to disk do, (*10)

```.php $pdf->Output('tlac.pdf', 'F');, (*11)




Syntax ------------------------------------------------------------------------ Your source file should look something like this

:title:
Adele - Someone like you, (*12)

:verse: {G}i heard that you'll {D} settle down that you'v{Em}e found a girl and you'{C}re married now {G}i heard that your d{D}reams came true ..., (*13)

:bridge: i {Am}hate to turn up out o{C}f the blue uninvited but i{Em} couldn't stay away, {D} i couldn't fight it i'd {Am}hoped you'd see my face a{C}nd that you'd be reminded ..., (*14)


Here are some explanations:

:title:
Adele - Someone like you, (*15)

:verse: <= ia new block starts after an empty line {G}i heard <= chords are given in curly brackets that you'll {D} settle down <= space after the chord that you'v{Em}e found a girl <= no space after the chord and you'{C}re married now {G}i heard that your d{D}reams came true ..., (*16)

:bridge: <= another new block i {Am}hate to turn up out o{C}f the blue uninvited but i{Em} couldn't stay away, {D} i couldn't fight it i'd {Am}hoped you'd see my face a{C}nd that you'd be reminded ..., (*17)


If a chord i followed by a space the width of the chord is respected. `that you'll {D} settle down` is rendered something like this
        D

that you'll settle down, (*18)


However, `and you'{C}re married now` is rendered like this
    C

and you're married now, (*19)


There is one additional syntax, `+`. It adds a fixed margin to the chord. `Hej+{D}+you` gets something like
  D

Hej you, (*20)


Useful for intros and outros without lyrics

{G}until the end+{em}+{D}+{G}, (*21)



Integration with [Anax-MVC](https://github.com/mosbth/Anax-MVC) ----------------------------------------------------------------------- This is part of a hand in assignment to a course where Anax-MVC is used. To integrate into Anax-MVC update your `composer.json` as mentioned above. You are now ready to load the TLAC parser as a service into the `DI` container in `config_with_app.php` somewhere after `$di = new \Anax\DI\CDIFactory();`

$di->set('chordparser', '\ludviki\TLAC\TLAC');, (*22)


You can also integrate `TLAC` in more deeply into Anax by adding the following lines to `\Anax\DI\CDIFactoryDefault` (or if you have your own default class in this one)

$this->set('chordparser', function () { return new \ludviki\TLAC\TLAC(); });, (*23)


Now the parser is available if the `DI` container is available as it should be in your controllers. An example for a route defined by a closure (for example in `webroot/index.php`. Adapt this to your needs.

$app->router->add('chordparser', function() use ($app) {, (*24)

$app->theme->setTitle('Chordparser');
$app->theme->addStylesheet('css/chords.css'); // with respect to webroot

//
// standard configuration: this searches for
// ANAX_APP_PATH.'content/chordparser/text.txt'
//
$content = $app->fileContent->get('chordparser/text.txt');
$text = $app->chordparser->toHtml($content);

// nl2br filter misses in standard instalation (see pull request)
// $source = $app->textFilter->doFilter($content, 'nl2br');
$source = nl2br($source);


$app->views->addString('Parsed');
$app->views->add('default/content', [
    'content' => $text,
]);
$app->views->addString('Source');
$app->views->add('default/content', [
    'content' => $source,
]);

}); ``, (*25)

The Versions

03/06 2014

dev-master

9999999-dev https://github.com/ludviki/tlac

Typeset lyrics with chords

  Sources   Download

MIT

The Requires

 

parser html pdf music guitar chord

03/06 2014

v1.0

1.0.0.0 https://github.com/ludviki/tlac

Typeset lyrics with chords

  Sources   Download

MIT

The Requires

 

parser html pdf music guitar chord