npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

doclax

v2.0.0

Published

A tool for creating books from Markdown

Downloads

3

Readme

Doclax

Doclax is a command-line tool designed to generate different types of document formats (PDF, EPUB, MOBI) from HTML/Markdown input, with a live preview feature to see the output as you work. The tool is built with Node.js and uses several libraries like Puppeteer, epub-gen, and commander to handle various functionalities.

Features

  • Convert Markdown/MDX to PDF
  • Live preview server with auto-reload
  • Easy configuration and customization

Overall Functionalities

  1. PDF Generation: Convert HTML/Markdown into a PDF file using Puppeteer.
  2. EPUB Generation: Convert HTML/Markdown into an EPUB file using epub-gen.
  3. MOBI Generation: Convert HTML/Markdown into a MOBI file (for Kindle).
  4. Live Preview: Start a local server to preview your content in the browser while working.

Available Commands

  1. generate-pdf:

    • Description: Generates a PDF from the index.html file in the public folder.
    • Usage: npx doclax generate-pdf
    • Output: Saves the PDF in the output folder as output.pdf.
  2. generate-epub:

    • Description: Generates an EPUB from the index.html file in the public folder.
    • Usage: npx doclax generate-epub
    • Output: Saves the EPUB in the output folder as output.epub.
  3. generate-mobi:

    • Description: Generates a MOBI file from the index.html file in the public folder.
    • Usage: npx doclax generate-mobi
    • Output: Saves the MOBI file in the output folder as output.mobi.
  4. start-preview:

    • Description: Starts a live preview server to view the content of the index.html file in the public folder.
    • Usage: npx doclax start-preview
    • Output: Opens the preview in your default web browser at http://localhost:3000.

How the Tool Works

  1. Installation:

    • Clone the repository to your local machine.
    • Navigate to the directory and install the dependencies:
      git clone [email protected]:fasakinhenry/Doclax.git
      cd Doclax
      npm install
  2. Usage:

    • Run any of the available commands listed above using npx doclax <command>.
    • For example, to generate a PDF, you would run:
      npx doclax generate-pdf
    • This command uses the index.html file in the public folder, generates a PDF, and saves it in the output folder.
  3. Folder Structure:

    • The primary folders and files:
      • src/: Contains the main code for each functionality (e.g., pdf/generator.js, epub/generator.js, mobi/generator.js, etc.).
      • public/: Contains the index.html file used as the input for document generation.
      • output/: Created automatically to store the generated documents.
      • doclax.config.js: (Optional) Configuration file for customizing certain aspects of the tool.
  4. Configuration:

    • The tool is designed to work out of the box with minimal configuration. However, a configuration file (doclax.config.js) can be added in the config folder if customization is needed.

How to Publish the Tool

  1. Prepare for Publishing:

    • Ensure all dependencies are correctly listed in package.json.
    • Update the version number in package.json following semantic versioning.
    • Write a README.md file that describes how to install and use the tool.
  2. Login to npm:

    • If you don't already have an npm account, create one.
    • Log in to npm in your terminal:
      npm login
  3. Publish the Package:

    • Run the following command to publish the package to the npm registry:
      npm publish --access public
    • This will make Doclax available as an npm package that anyone can install and use globally.
  4. Global Installation:

    • Once published, users can install Doclax globally using:
      npm install -g doclax
  5. Usage After Installation:

    • After global installation, the tool can be used directly without npx:
      doclax generate-pdf
      doclax generate-epub
      doclax start-preview

Future Improvements

  • Customization: Allow users to customize the output formats (PDF, EPUB, MOBI) more granularly via a configuration file.
  • Template Support: Support for different templates for document generation.
  • Improved Error Handling: Enhance error messages and validation to guide users when issues arise.
  • Markdown Support: Integrate Markdown parsing directly to support Markdown files as input.

Packages used

Here’s what each package does:

  • commander: Helps create command-line interfaces.
  • puppeteer-core: Used for rendering HTML to PDF.
  • remark, unified, remark-parse, remark-rehype, rehype-stringify: Handle Markdown and MDX to HTML conversion.
  • figlet: Generates ASCII art from text.
  • chalk: Adds color to the terminal output.
  • cli-progress: Creates progress bars in the terminal.

Doclax Feature Checklist

  • [x] PDF Generation

    • Generate PDF from compiled chapters.
    • Serve and preview PDF in the browser with live reload on changes.
  • [x] HTML Preview

    • Convert chapters to an HTML template.
    • Serve and preview HTML in the browser with live reload on changes.
  • [x] EPUB Generation

    • Generate EPUB format and serve it in the browser.
  • [x] Terminal Interface Enhancements

    • Progress bar during file regeneration.
    • Figlet branding in the terminal.
    • Inquirer-based prompts for preview format selection.
  • [x] File Watcher Integration

    • Automatically regenerate files and update previews using Chokidar.
  • [ ] Markdown and MDX Support

    • Parse and compile Markdown and MDX content into preview formats (HTML, PDF, EPUB).
  • [ ] Tailwind CSS Integration

    • Allow custom styling using Tailwind CSS in generated documents (HTML, PDF).
  • [ ] Multi-Format Output

    • Seamless generation of additional formats like MOBI.
  • [ ] Live Reload Enhancements

    • Improve the speed and efficiency of live reloading for large projects.
  • [ ] Theming and Customization

    • Support theming and customization of documents, including templates, fonts, colors, and layouts.
  • [ ] Collaboration and Versioning

    • Implement collaborative editing and version control features.
  • [ ] Improved User Interface for CLI

    • Further enhance the visual appeal and usability of the CLI interface.
  • [ ] Command-Line Tool Enhancements

    • Add additional commands or options to cater to a broader range of use cases.
  • [ ] Efficient Image Handling

    • Optimize image handling in documents to maintain quality while reducing file sizes.
  • [ ] PDF-specific Features

    • Explore additional PDF features like bookmarks, table of contents, and internal linking.