PHP code example of huenisys / parsers

1. Go to this page and download the library: Download huenisys/parsers library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

huenisys / parsers example snippets



use huenisys\Parsers\Yaml;
use huenisys\Parsers\Markdown;

/** @test **/
public function simple_yaml_is_parsed()
{
    $this->assertEquals(['title' => 'Some Title'], Yaml::parseText('title: Some Title'));
}

/** @test **/
public function yaml_file_is_parsed()
{
    $filePath = __DIR__.'/../test-files/hello.yaml';
    $this->assertEquals(['hello' => 'world'], Yaml::parseFile($filePath));
}

/** @test **/
public function simple_md_is_parsed()
{
    $this->assertEquals('<h1>hello</h1>', Markdown::parseText('# hello'));
    $this->assertEquals('<h2>hello</h2>', Markdown::parseText('## hello'));
}

/** @test **/
public function md_file_is_parsed()
{
    $filePath = __DIR__.'/../test-files/hello.md';
    $this->assertEquals('<h1>hello world</h1>', Markdown::parseFile($filePath));
}