Convert Figma logo to code with AI

jgm logopandoc

Universal markup converter

33,890
3,339
33,890
1,128

Top Related Projects

A Python implementation of John Gruber’s Markdown with Extension support.

CommonMark spec, with reference implementations in C and JavaScript

Blackfriday: a markdown processor for Go

5,853

Determines which markup library to use to render a content file (e.g. README) on GitHub

14,258

A bidirectional Markdown to HTML to Markdown converter written in Javascript

:gem: A fast, open source text processor and publishing toolchain, written in Ruby, for converting AsciiDoc content to HTML 5, DocBook 5, and other formats.

Quick Overview

Pandoc is a universal document converter that can convert between numerous markup and document formats. It's particularly useful for converting between different flavors of Markdown, HTML, LaTeX, and various word processing formats. Pandoc is highly extensible and can be used as a library in multiple programming languages.

Pros

  • Supports a wide range of input and output formats
  • Highly customizable with options for fine-tuning output
  • Can be used as a command-line tool or as a library in various programming languages
  • Active development and community support

Cons

  • Learning curve can be steep for advanced usage
  • Some conversions may not preserve all formatting perfectly
  • Large installation size due to comprehensive feature set
  • Performance can be slow for very large documents

Code Examples

  1. Basic Markdown to HTML conversion:
import Text.Pandoc

main :: IO ()
main = do
  let markdown = "# Hello, Pandoc!\nThis is a **test**."
  result <- runIO $ readMarkdown def markdown >>= writeHtml5String def
  putStrLn $ either show id result
  1. Converting a file from Markdown to PDF:
import Text.Pandoc
import qualified Data.Text.IO as TIO

main :: IO ()
main = do
  input <- TIO.readFile "input.md"
  result <- runIO $ do
    doc <- readMarkdown def input
    writeLaTeX def doc >>= writeFileLaTeX def "output.pdf"
  print result
  1. Custom writer example:
import Text.Pandoc
import Text.Pandoc.Writers.Custom

main :: IO ()
main = do
  let markdown = "# Title\n\nParagraph with *emphasis*."
  result <- runIO $ do
    doc <- readMarkdown def markdown
    writeCustom def { writerRawHtml = True } customWriter doc
  putStrLn $ either show id result

customWriter :: [Block] -> String
customWriter = concatMap blockToHtml

blockToHtml :: Block -> String
blockToHtml (Header 1 _ inlines) = "<h1>" ++ inlinesToHtml inlines ++ "</h1>"
blockToHtml (Para inlines) = "<p>" ++ inlinesToHtml inlines ++ "</p>"
blockToHtml _ = ""

inlinesToHtml :: [Inline] -> String
inlinesToHtml = concatMap inlineToHtml

inlineToHtml :: Inline -> String
inlineToHtml (Str s) = s
inlineToHtml (Emph inlines) = "<em>" ++ inlinesToHtml inlines ++ "</em>"
inlineToHtml _ = ""

Getting Started

To use Pandoc as a Haskell library:

  1. Install Pandoc: cabal install pandoc
  2. In your Haskell file, import Pandoc:
import Text.Pandoc

main :: IO ()
main = do
  let markdown = "# Hello, Pandoc!"
  result <- runIO $ readMarkdown def markdown >>= writeHtml5String def
  putStrLn $ either show id result
  1. Compile and run your Haskell program.

For command-line usage, install Pandoc and use it directly in the terminal:

pandoc input.md -o output.html

Competitor Comparisons

A Python implementation of John Gruber’s Markdown with Extension support.

Pros of Python-Markdown

  • Lightweight and focused specifically on Markdown processing
  • Easy to integrate into Python projects
  • Extensible through custom extensions

Cons of Python-Markdown

  • Limited to Markdown input and HTML output
  • Fewer supported input/output formats compared to Pandoc
  • Less comprehensive documentation and community support

Code Comparison

Python-Markdown:

import markdown

html = markdown.markdown(text)

Pandoc:

import Text.Pandoc

result <- runIO $ readMarkdown def text >>= writeHTML5 def

Python-Markdown focuses on simplicity and ease of use within Python ecosystems, while Pandoc offers a more comprehensive document conversion solution with support for numerous formats. Python-Markdown is ideal for projects requiring straightforward Markdown-to-HTML conversion, whereas Pandoc excels in complex document transformations across various formats.

Python-Markdown's lightweight nature makes it quicker to set up and use in Python projects, but it lacks the versatility of Pandoc's extensive format support. Pandoc's broader feature set comes with a steeper learning curve and potentially more complex integration, especially in Python-centric environments.

CommonMark spec, with reference implementations in C and JavaScript

Pros of CommonMark

  • Focused specifically on standardizing Markdown syntax
  • Provides a clear, unambiguous specification for Markdown
  • Offers a test suite for implementers to ensure compliance

Cons of CommonMark

  • Limited in scope compared to Pandoc's broader document conversion capabilities
  • Less flexible for handling various input and output formats
  • Lacks advanced features like citation support and custom extensions

Code Comparison

CommonMark (JavaScript implementation):

var reader = new commonmark.Parser();
var writer = new commonmark.HtmlRenderer();
var parsed = reader.parse("Hello *world*");
var result = writer.render(parsed);

Pandoc (Haskell):

import Text.Pandoc
import Text.Pandoc.PDF

main :: IO ()
main = runIOorExplode $ do
  doc <- readMarkdown def "Hello *world*"
  writeHtml5String def doc

Summary

CommonMark focuses on standardizing Markdown syntax, providing a clear specification and test suite. Pandoc, on the other hand, offers a more comprehensive document conversion tool with support for multiple formats and advanced features. CommonMark is ideal for those seeking a consistent Markdown implementation, while Pandoc is better suited for complex document processing tasks across various formats.

Blackfriday: a markdown processor for Go

Pros of Blackfriday

  • Written in Go, offering better performance for Go-based applications
  • Lightweight and focused specifically on Markdown parsing
  • Easier to integrate into Go projects with minimal dependencies

Cons of Blackfriday

  • Limited to Markdown input and HTML output
  • Fewer features and customization options compared to Pandoc
  • Less active development and community support

Code Comparison

Blackfriday (Go):

import "github.com/russross/blackfriday/v2"

markdown := []byte("# Hello, Markdown!")
html := blackfriday.Run(markdown)

Pandoc (Haskell):

import Text.Pandoc

main :: IO ()
main = do
  let markdown = "# Hello, Markdown!"
  result <- runIO $ readMarkdown def markdown >>= writeHtml5String def
  putStrLn $ either show id result

Summary

Blackfriday is a lightweight, Go-specific Markdown parser that excels in performance and ease of integration for Go projects. However, it lacks the extensive features and format support of Pandoc. Pandoc, written in Haskell, offers a more comprehensive document conversion toolset with support for numerous input and output formats, making it more versatile but potentially more complex to use and integrate, especially in non-Haskell environments.

5,853

Determines which markup library to use to render a content file (e.g. README) on GitHub

Pros of Markup

  • Lightweight and focused specifically on rendering various markup formats for GitHub
  • Easier integration with GitHub-specific features and workflows
  • Supports a wider range of markup languages out-of-the-box (e.g., .textile, .rdoc, .org)

Cons of Markup

  • Limited functionality compared to Pandoc's extensive conversion capabilities
  • Less flexible for non-GitHub use cases or complex document transformations
  • Smaller community and fewer extensions/plugins available

Code Comparison

Markup (Ruby):

def render(content)
  GitHub::Markup.render(file, content)
end

Pandoc (Haskell):

convertMarkdown :: String -> IO String
convertMarkdown input = runIOorExplode $ readMarkdown def input >>= writeHtml5String def

Summary

Markup is a specialized tool for GitHub-centric markup rendering, while Pandoc offers a more comprehensive document conversion solution. Markup excels in its simplicity and GitHub integration, whereas Pandoc provides greater flexibility and power for complex document transformations across various formats. The choice between the two depends on the specific use case and required features.

14,258

A bidirectional Markdown to HTML to Markdown converter written in Javascript

Pros of Showdown

  • Lightweight and focused on Markdown to HTML conversion
  • Easy to integrate into JavaScript projects, especially for browser-based applications
  • Simpler to use for basic Markdown tasks

Cons of Showdown

  • Limited input/output format support compared to Pandoc's extensive capabilities
  • Less powerful for complex document conversions or academic writing needs
  • Smaller community and fewer extensions/plugins available

Code Comparison

Showdown (JavaScript):

var converter = new showdown.Converter();
var html = converter.makeHtml('# Hello, Markdown!');

Pandoc (Command-line):

pandoc input.md -o output.html

Key Differences

  • Pandoc is a comprehensive document conversion tool supporting numerous formats, while Showdown focuses on Markdown to HTML conversion.
  • Showdown is JavaScript-based and easily integrates into web applications, whereas Pandoc is a standalone command-line tool written in Haskell.
  • Pandoc offers more advanced features like citations, metadata handling, and custom templates, making it suitable for academic and complex document processing.
  • Showdown is more appropriate for simpler Markdown tasks in web environments, while Pandoc excels in versatility and power for various document conversion needs.

:gem: A fast, open source text processor and publishing toolchain, written in Ruby, for converting AsciiDoc content to HTML 5, DocBook 5, and other formats.

Pros of Asciidoctor

  • Native Ruby implementation, making it faster and more efficient for Ruby-based projects
  • More extensive syntax and formatting options for technical documentation
  • Better support for generating complex, multi-format output (HTML, PDF, EPUB)

Cons of Asciidoctor

  • Limited support for input formats compared to Pandoc
  • Steeper learning curve due to more complex syntax
  • Less flexibility in converting between various document formats

Code Comparison

Asciidoctor (Ruby):

require 'asciidoctor'

Asciidoctor.convert_file 'document.adoc', to_file: 'output.html', safe: :safe

Pandoc (Haskell):

import Text.Pandoc

main :: IO ()
main = runIOorExplode $ readMarkdown def "input.md" >>= writeHtml5 def

Both Asciidoctor and Pandoc are powerful document conversion tools, but they cater to different needs. Asciidoctor excels in creating technical documentation with its rich syntax and multi-format output capabilities, making it ideal for Ruby-based projects. Pandoc, on the other hand, offers unparalleled flexibility in converting between various document formats and supports a wider range of input formats. The choice between the two depends on the specific requirements of your project and the ecosystem you're working in.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Pandoc

github
release hackage
release homebrew stackage LTS
package CI
tests license pandoc-discuss on google
groups

The universal markup converter

Pandoc is a Haskell library for converting from one markup format to another, and a command-line tool that uses this library.

It can convert from

It can convert to

Pandoc can also produce PDF output via LaTeX, Groff ms, or HTML.

Pandoc’s enhanced version of Markdown includes syntax for tables, definition lists, metadata blocks, footnotes, citations, math, and much more. See the User’s Manual below under Pandoc’s Markdown.

Pandoc has a modular design: it consists of a set of readers, which parse text in a given format and produce a native representation of the document (an abstract syntax tree or AST), and a set of writers, which convert this native representation into a target format. Thus, adding an input or output format requires only adding a reader or writer. Users can also run custom pandoc filters to modify the intermediate AST (see the documentation for filters and Lua filters).

Because pandoc’s intermediate representation of a document is less expressive than many of the formats it converts between, one should not expect perfect conversions between every format and every other. Pandoc attempts to preserve the structural elements of a document, but not formatting details such as margin size. And some document elements, such as complex tables, may not fit into pandoc’s simple document model. While conversions from pandoc’s Markdown to all formats aspire to be perfect, conversions from formats more expressive than pandoc’s Markdown can be expected to be lossy.

Installing

Here’s how to install pandoc.

Documentation

Pandoc’s website contains a full User’s Guide. It is also available here as pandoc-flavored Markdown. The website also contains some examples of the use of pandoc and a limited online demo.

Contributing

Pull requests, bug reports, and feature requests are welcome. Please make sure to read the contributor guidelines before opening a new issue.

License

© 2006-2024 John MacFarlane (jgm@berkeley.edu). Released under the GPL, version 2 or greater. This software carries no warranty of any kind. (See COPYRIGHT for full copyright and warranty notices.)