diff --git a/README.md b/README.md index ec50c51..f133fc9 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,11 @@ $html = Markdown::new(); $html -> setContent( $sample ); # convert data to markdown -$html -> toHtml(); //

Hello, World

+print $html -> toHtml(); //

Hello, World

``` -## Convert Markdown File +## Convert Markdown File to Html Assuming we created a `sample.md` file in `/resources` folder with the following markdown contents: @@ -54,11 +54,56 @@ $html = Markdown::new(); $html -> setFile( $file ); -echo $html -> toHtml(); +print $html -> toHtml(); // output:

Topic

Sub-topic

Author: vincent ``` +
+ +## Convert Markdown File to Html File + +In order to achieve this, you need to create a folder to store the compiled markdown files. + +> ➡️ If we've already set up directories named `pages` and `markdowns` with a file named `hello.md` in the `markdowns` directory, let's see how we can convert the `hello.md` markdown file into an HTML file. Afterward, we will save the resulting HTML output in a new file named `hello.html` in `pages` directory: +
+ +> **file:** markdowns/hello.md + +```md +### hello +``` +
+ +> **file:** index.php + +```php + +use FastVolt\Helper\Markdown; + +# convert md file to html file +$markdown = Markdown::new() + -> setFile( __DIR__ . '/files/hello.md' ) + -> setCompileDir( 'pages/' ) + -> toHtmlFile( filename: 'hello' ); + +# check if markdown compile to html successfully +if ($markdown) { + print ("compile successful"); +} + +``` + +After above operation, you will get the following result: + +> **file:** pages/hello.html + +```html + +

hello

+ +``` +
## Requirements @@ -66,8 +111,8 @@ echo $html -> toHtml(); - that's all 😇. -# Note -FastVolt is an extended/simplified version of Erusev's ParseDown Library. +## Note +FastVolt's Markup Library is an extended/simplified version of Erusev's ParseDown Library.