Skip to content

Exporting an MD doc to itself as a cleanup trick #2814

@tajmone

Description

@tajmone

A trick which I often use (but don't see mentioned much) to cleanup my draft MD documents, is to use Pandoc to process the document to itself (as output) using the same format as input — plus some other option to achieve some "celanup tricks".

>pandoc -f markdown -t markdown -o mydoc.md mydoc.md
  • Pandoc defaults to 80 columns auto-wrapping, which means that all text blocks will be "paginated" to 80 columns, giving a cleaner feel to the raw source. Using the --columns= option one can customize the width.
>pandoc -f markdown -t markdown --columns=120 -o mydoc.md mydoc.md
  • All lazy syntax is cleaned up by this process, making lists and quotations look clean (to mention just a few).
  • Pandoc will apply default (or chosen) styling to the document (ATX vs Setext headers, and so on) giving uniformity to the document.
  • The --smart option will convert straight quotes, dashes, ecc.
  • The --standalone --toc options will create an auto-generated TOC at the beginning of the document — quite useful for working with API docs, READMEs, ecc. (The -s / --standalone is required for this to work).

And possibly quite a few other useful hacks one could apply to the document he is working on.

So, with this issue I propose two things:

  1. I think this trick could be added to Documentation/Usage, it's a neat trick for beginners.
  2. Also, it would nice to have a new option implemented to invoke this in a quick way. Something like --cleanup, which would require only the source file as a parameter, defaulting to itself as an output.
    Some sort of alias for -f markdown -t markdown -o filename.md filename.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions