I found a javascript plugin to convert HTML to markdown here https://github.com/domchristie/to-markdown .
I'm using Laravel 5. Let's say a user post an HTML string and I take the request from my PHP class. Here's my controller:
<?php
class TheController extends Controller
{
...
public function index()
{
$html_text = Request::input('html_text');
// Convert $html_text to $markdown
}
}
?>
If I were in a javascript file I could've called the function like this:
var toMarkdown = require('to-markdown');
toMarkdown('<h1>Hello world!</h1>');
How do I convert $html_text
to $markdown
without converting it to a text file and read it, if possible
You shouldn't use a npm package for that, there are plenty php packages to do this. You can find a lot of packages compatible with Laravel on packalyst .
For example: http://packalyst.com/packages/package/alfredo-ramos/parsedown-extra-laravel
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.