matthiasnoback/leanpub-sampler 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

matthiasnoback/leanpub-sampler

Composer 安装命令:

composer require matthiasnoback/leanpub-sampler

包简介

A simple script for generating samples for Leanpub books

README 文档

README

This tool can be used to generate sample text for Leanpub books.

Installation

Install with Composer. Add a composer.json file to the root of your Leanpub book project (one directory higher than manuscript/):

{
    "require": {
        "matthiasnoback/leanpub-sampler": "~0.1"
    }
}

Then run composer update. A vendor/ directory will be created, containing the Leanpub sampler and its dependencies.

Usage

First you need to edit your manuscript files and add markers for the sample texts:

# A regular chapter

## A regular section

Some text.

%% begin sample

## A sample section

Some sample text.

%% end sample

Then run:

php vendor/bin/generate-sample.php

The sampler will generate sample text based on the %% begin sample and %% end sample markers. It scans all .txt or .md files inside the manuscript/ directory, including its subdirectories.

The result is a new file, manuscript/sample-text.txt, that contains all the sample text.

Add all section titles (parts, chapters, sections)

Using the command-line option --all-sections or -s you can instruct the sampler to automatically add any part, chapter or section title to the sample text:

php vendor/bin/generate-sample.php -s

This is useful if you want to preserve the original structure of your manuscript in the generated sample file. It is also useful because if all the part, chapter and section titles are present in the sample file, Leanpub will add the full table of contents to the generated preview file.

Last step: mention sample-text.txt in Sample.txt

When Leanpub generates a preview file, it looks at the manuscript/Sample.txt file. All files mentioned there will be added to the generated preview file. Make sure you add the sample-text.txt file to the list too:

The contents of manuscript/Sample.txt should be:

sample-text.txt

Suggestions

The Leanpub sampler scans the manuscript files in alphabetical order. So to preserve initial order, it's best to sort your manuscript files alphabetically too, like:

00-chapter1.txt
01-chapter2.txt
...

统计信息

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

GitHub 信息

  • Stars: 9
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-02-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固