Download the PHP package laravelista/sherlock without Composer
On this page you can find all versions of the php package laravelista/sherlock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download laravelista/sherlock
More information about laravelista/sherlock
Files in laravelista/sherlock
Package sherlock
Short Description Deduct a markdown document and get a specific chapter and/or a table of content.
License MIT
Informations about the package sherlock
Sherlock
Sherlock is a PHP package that provides unique features for markdown.
It can create a Table of Content or retrieve a specific chapter.
Overview
I use this package on my website Laravelista to create table of content for my lessons, posts and packages. Also, I use it to provide free samples of my lessons.
Get the Table of Content
Given this markdown:
You can generate a table of content:
HTML Output:
Get a specific chapter
Given the same markdown as in the sample above we can fetch a specific chapter from our markdown documents by its name.
Markdown output:
Laravel usage inside views
If you are using Laravel, there is a convenient way of loading Sherlock in your views. At the top of your view file where you want to display the Table of Content add this code to inject Sherlock and deduct the content:
And then in the place where you want to display the actual Table of Content add this:
or to get a specific chapter use $sherlock->get()
. Just remember that get()
returns markdown, so be sure to parse the markdown to HTML.
Installation
From the command line:
API
deduct
Reads given markdown string and generates an index of the document (Library).
You can chain this method with other methods from the API, but this method must always be called first. Library can be retrieved if needed with getLibrary()
.
getToc
Returns the Table of Content in HTML format.
Example:
Given this markdown:
it returns this HTML output:
get
Returns markdown for specific chapter.
Example:
Given this markdown:
it returns this Markdown output:
getLibrary
It returns the index of the document (Library); which was deducted from the given markdown in deduct()
method; as an array.
Example:
This is a sample of the Library you get:
With it you can do all sorts of things.