new-humans/markdown-article-library

PHP7 的 Markdown 文件组织器

v1.0.1 2017-12-23 00:13 UTC

This package is not auto-updated.

Last update: 2024-09-29 03:52:47 UTC


README

new-humans/markdown-article-library 是一个基于 PHP 的文件系统包装器,用于 league/commonmark 的 Markdown 解析器。文件系统导航灵感来自 new-humans/ubfs

目标

  • 让作家在 PHP 中与相对可组织的 Markdown 文件系统进行交互。
  • 让作家将这些文件作为网页浏览器的 HTML 渲染提供。
  • 让作家将这些文件作为下载提供。

安装

此项目可以通过 Composer 安装。

$ composer require new-humans/markdown-article-library

基本用法

ArticleLibrary 类提供了一个简单的包装器,用于加载 1 级深度的 Markdown 文件系统。在您的项目中应存在一个库目录,其格式如下

/library
    - /notes
        - on-the-nature-of-the-universe.md
        - the-purpose-of-the-state.md
    - /ideas
        - persona-purpose-and-human-purpose.md
        - why-we-do-the-things-we-do.md
    - /lists
        - four-steps-for-preventing-career-bureacurism

/library 的每个子目录代表一个写作主题。子目录中的每个文件代表该主题内的一个写作片段,格式为 Markdown。

注意:这些名称中的任何一个都可以替换 - 它们都是开发人员根据解决方案中的实际文件提供的。此存储库中的示例包括主题 /notes/whimsy

use NewHumans\MarkdownArticleLibrary\ArticleLibrary;

// Instantiate the ArticleLibrary
$articleLibrary = new ArticleLibrary(__DIR__.'/articles');

// Instatiate the subject 'notes'
$articleLibrary->newSubject("notes");

// Instantiate the article 'grocery.md' to key 'grocery' within subject 'notes'
$articleLibrary->newArticle("notes", "grocery.md", "grocery");

// Output the article contents to client (HMTL or download)
echo $articleLibrary->readArticle("notes", "grocery");
// or $articleLibrary->downloadArticle("notes", "grocery");

文档

最佳查看位置是在内部!/src 中只有两个类。