Giter Site home page Giter Site logo

kurenai's People

Contributors

alexsoft avatar crynobone avatar daylerees avatar driesvints avatar hirenkeraliya avatar jessiesiat avatar orthographic-pedant avatar rgomezcasas avatar trq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

kurenai's Issues

Notice for use of list function

Here is the error:

Notice: Undefined offset: 1 in /vendor/daylerees/kurenai/src/Parser.php on line 58

I assume that is for a wrong use of list php function.

Add php 5.4 dependency in composer.json

This "package" can't be used in php 5.3 because the DocumentParser class uses "callable" type hint, that is present in php >= 5.4.

I manually removed the type hint to could use it in a production server, but if you don't want to support php 5.3 I'll recomment to add a "note" in the readme.md or add it to composer dependency.

(I'm Spanish, sorry for my English!)

Regards and thnaks for this package! ๐Ÿ‘

Suggestions?

Hi @daylerees,
It is very funny I was working on something similar and I just discovered your repository.

May I bring some suggestions?

When you parse the document for metadata, why don't you use use Symfony\Component\Yaml\Yaml; and then something like Yaml::parse($metadata);. With that we will end with a similar key => `value' (multidimensional) array and you bring the power of Yaml inside your package which means we can put even more structured metadata.

My code looks like the following.


---
title: foo
slug: bar
tags: [foo, bar, baz]
related:
    - foo: bar
      baz: doo

---
@
# My markdown content
@

Then I extract the content with:

    /**
     * Extract content inside delimiters.
     *
     * @param string $start
     * @param string $end
     * @return string Extracted content.
     *
     * @source
     * http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html
     */
    protected function extract_unit($string, $start, $end)
    {
        $pos        = stripos($string, $start);
        $str        = substr($string, $pos);
        $str_two    = substr($str, strlen($start));
        $second_pos = stripos($str_two, $end);
        $str_three  = substr($str_two, 0, $second_pos);

        return trim($str_three);
    }

But I admit I feel stupid because in your code you don't even need to use delimiter for the markdown content... I will dig in your code to see how you do the magic.

Then, once I have extracted the content between --- I simply parse it with: return Yaml::parse($this->extract_unit($content, '---', '---')); and voila.

What do you think about it and the use of Yaml?

Support for Laravel blade templates

Have you considered writing an extended Laravel ViewFactory, that would first parse all blade templates for metadata before handing the content back to Laravel for normal handling?

I can think of a number of cases where I might want to allow views to offer up some config, and access that in the controller.

public function myControllerFunction()
{
    $view = view('my.page');
    if($view->getMetadata()['foo'] == 'bar') {
        doSomething();
    }

    return $view;
}

my/page.blade.php:

{
    "foo": "bar"
}
===
@extends('layouts.main')
@section('content')
    The rest of my normal blade template
@endsection

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.