承接 simplydi/simplymarkdown 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

simplydi/simplymarkdown

Composer 安装命令:

composer require simplydi/simplymarkdown

包简介

A very simple way to handle Markdown content on your website

README 文档

README

A very simple way to handle Markdown content on your website

This package can be used to render the markdown content on your website. For example, you can write blog posts on your blog using markdown and parse it using SimplyMarkdown. It will return you the markdown content as html as well as the meta data on your markdown file tht you set, such as title, slug, description, etc.

The below example will illustrate.

Example 1: getting the contents of a markdown post:

sample-post.md:

---
title: This is a sample title
description: This is a description
cover_image: /path/to/image.png
slug: sample-post
---

This is the body content of the blog post.

using the parser in your app:

<?php

use SimplyDi\SimplyMarkdown\MdParser;

require_once '../vendor/autoload.php';

$parser = new MdParser(
    __DIR__ . '/md/'
);

$output = $parser->getFileContent("sample-post");

echo "<pre>";
print_r($output);

Output:

Array
(
    [title] => This is a sample title
    [description] => This is a description
    [cover_image] => /path/to/image.png
    [slug] => sample-post
    [content] => 

This is the body content of the blog post.


)

A you can see, you get an array of meta data you passed as Yaml in the markdown file as well as the content you wrote.

Converting Html to Markdown

Simply use the HtmlToMd() class's convert() method:

$string = "<h1>Heading 1 Here</h1>";

$md = (new \SimplyDi\SimplyMarkdown\HtmlToMd)->convert($string);

echo $md;

// OUTPUT:

# Heading 1 Here

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-04