Code Monkey home page Code Monkey logo

mdproof's Introduction

mdproof

A command line program that generates PDFs from markdown files, with no dependency on LaTeX or a headless browser. Still a work in progress, use at your own risk.

Features

  • No dependency on LaTeX or any other executable
  • Lists, code blocks, regular text, bold text, and italic text!

Screenshots

The readme rendered as a PDF

Installation

$ git clone https://github.com/Geemili/mdproof
$ cd mdproof
$ cargo build

Usage

$ cargo run README.md
$
$ # Or if you've copied `mdproof` to your `~/bin` folder
$ mdproof README.md

Why?

There are already a plethora of ways to generate PDFs, including LaTeX, headless browsers, or libreoffice. However, all of these methods pull in massive dependencies, and can be difficult to set up correctly.

By comparison, this program relies on only a few (direct) dependencies, and can be compiled into a single executable file.

The goal of this program is to compile markdown to pdf, without stepping through dependency hell.

mdproof's People

Contributors

flosse avatar leroycep avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mdproof's Issues

Styles

I would like to generate PDF from Markdown that look "like" when reading the markdown on github, that is, with a similar / same style.

RGBA PNG images are not rendered

RGBA PNG images are not visible in the output PDF, though they do take up space. PDF renderers used include PDF.js, qpdfviewer, apvlv, and whatever the reMarkable tablet uses.

Using imagemagick to remove the alpha channel makes the images show up:

convert -alpha 1 flamer-1.png flamer-1-alpha-removed.png

Example:

test.md

# `flamer-1.png`:

![](flamer-1.png)

# `flamer-1-alpha-removed.png`:

![](flamer-1-alpha-removed.png)

flamer-1.png:
flamer-1

flamer-1-alpha-removed.png
flamer-1-alpha-removed

test.pdf

Explicit page breaks

Seems like a useful feature to have, but CommonMark doesn't define any way to create page breaks. This stackoverflow post suggests using some html to do it:

<div style="page-break-after: always;"></div>

We could also try making extra long thematic breaks page breaks. I.E. five or more on a line = page break.

*****

Or two thematic breaks in a row:

***
***

I'm open to discussion on if and how explicit page breaks could be implemented.

Implement notes as endnotes

Instead of putting notes at the bottom of the page, put the notes at the end of the PDF. This is easier to implement, and conforms more closely to how most markdown to html generators work.

Later this could be a style option, letting you choose between bottom of the page, side of the page, or at the end.

Option for Blank pages

Basically, you would give it a number and it would append that many blank pages to the end.

My use case is taking notes on the remarkable tablet. It does not allow you to append pages to PDFs, so this is an easy workaround for that.

Perhaps this would also be useful for someone who is generating a book? Maybe just in a use case similar to mine. I don't know if dead tree publishers take PDFs, it care about having blank pages at the end.

Implement the complete CommonMark spec

https://spec.commonmark.org/0.28/

One caveat is that mdproof will not implement all html, even though markdown is technically a superset of it. Some html will be recognized, but not all.

Required:

  • Block Quotes
  • Thematic Breaks
  • Unordered Lists
  • Ordered Lists
  • Images
  • Footnotes
    • Render links as footnotes (?)
  • Entity references
    • NVM, these are handled by pulldown-cmark.

Good to have:

  • Tables
  • Checklists

Thanks for this project!

Having migrated away from TeX for most of my uni-related work to Markdown, I could not agree more with this: (from the Readme)

However, all of these methods pull in massive dependencies, and can be difficult to set up correctly.

I have had setup problems for all of this time, and I think I'm still not 100% done.

So, thank you for making it possible to work with MD in a simpler way!

Have a good weekend :)

Feature request: CJK and more characters support

tree -L 1     
.
├── Cargo.lock
├── Cargo.toml
├── Chinese.md
├── Chinese.pdf
├── images
├── README.md
├── src
├── target
├── test.md
└── test.pdf

thread 'main' panicked at 'byte index 7 is not a char boundary; it is inside '─' (bytes 6..9) of ├── src ', libcore/str/mod.rs:2111:5

Default output name

First I just wanted to say this is a really cool project, I'll definitely be using this.

There should be a default ouput name where running mdproof foo.md should create foo.pdf rather than giving an error.

Panic when running against repo example

I tried running

RUST_BACKTRACE=1 cargo run -- example_documents/pagination.md

and I got

    Finished dev [unoptimized + debuginfo] target(s) in 3.06s
     Running `target/debug/mdproof example_documents/pagination.md`
thread 'main' panicked at 'attempted to leave type `linked_hash_map::Node<std::string::String, object::Object>` uninitialized, which is invalid', /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/mem/mod.rs:660:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:50:5
   3: core::mem::uninitialized
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/mem/mod.rs:660:9
   4: linked_hash_map::LinkedHashMap<K,V,S>::insert
             at /home/scott/.cargo/registry/src/github.com-1ecc6299db9ec823/linked-hash-map-0.3.0/src/lib.rs:203:52
   5: lopdf::object::Dictionary::set
             at /home/scott/.cargo/registry/src/github.com-1ecc6299db9ec823/lopdf-0.17.0/src/object.rs:280:3
   6: <lopdf::object::Dictionary as core::iter::traits::collect::FromIterator<(K,lopdf::object::Object)>>::from_iter
             at /home/scott/.cargo/registry/src/github.com-1ecc6299db9ec823/lopdf-0.17.0/src/object.rs:351:4
   7: printpdf::types::plugins::xmp::xmp_metadata::XmpMetadata::into_obj
             at /home/scott/.cargo/registry/src/github.com-1ecc6299db9ec823/printpdf-0.2.10/src/types/plugins/xmp/xmp_metadata.rs:72:30
   8: printpdf::types::pdf_metadata::PdfMetadata::into_obj
             at /home/scott/.cargo/registry/src/github.com-1ecc6299db9ec823/printpdf-0.2.10/src/types/pdf_metadata.rs:66:10
   9: printpdf::types::pdf_document::PdfDocumentReference::save
             at /home/scott/.cargo/registry/src/github.com-1ecc6299db9ec823/printpdf-0.2.10/src/types/pdf_document.rs:267:58
  10: mdproof::main::run
             at ./src/bin/mdproof.rs:67:5
  11: mdproof::main
             at /home/scott/.cargo/registry/src/github.com-1ecc6299db9ec823/quicli-0.3.1/src/main_macro.rs:45:29
  12: core::ops::function::FnOnce::call_once
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.