Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/fastvolt/markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
oladoyinbov committed Nov 9, 2023
2 parents 330eaa7 + 5d862ae commit 6d7dddb
Showing 1 changed file with 50 additions and 5 deletions.
55 changes: 50 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ $html = Markdown::new();
$html -> setContent( $sample );

# convert data to markdown
$html -> toHtml(); // <h2>Hello, World</h2>
print $html -> toHtml(); // <h2>Hello, World</h2>

```

## Convert Markdown File
## Convert Markdown File to Html

Assuming we created a `sample.md` file in `/resources` folder with the following markdown contents:

Expand Down Expand Up @@ -54,20 +54,65 @@ $html = Markdown::new();

$html -> setFile( $file );

echo $html -> toHtml();
print $html -> toHtml();

// output: <h1>Topic</h1> <h2> Sub-topic</h2> <b>Author:</b> <i>vincent</i>

```
<br>

## 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:
<br>
> **file:** markdowns/hello.md
```md
### hello
```
<br>

> **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

<h3>hello</h3>

```
<br>


## Requirements
- PHP 8.1
- that's all 😇.


# Note
FastVolt is an extended/simplified version of <a href="https://github.com/erusev/parsedown">Erusev's ParseDown Library</a>.
## Note
FastVolt's Markup Library is an extended/simplified version of <a href="https://github.com/erusev/parsedown">Erusev's ParseDown Library</a>.

<hr>

Expand Down

0 comments on commit 6d7dddb

Please sign in to comment.