All Projects → ueberdosis → pandoc

ueberdosis / pandoc

Licence: MIT license
A PHP wrapper for Pandoc to convert any text format in any other text format

Programming Languages

PHP
23972 projects - #3 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to pandoc

PanBook
Pandoc LaTeX,Epub模板,用于生成书籍,幻灯片(beamer),简历,论文等(cv, thesis, ebook,beamer)
Stars: ✭ 190 (+352.38%)
Mutual labels:  pandoc
citeproc-rs
CSL processor in Rust.
Stars: ✭ 56 (+33.33%)
Mutual labels:  pandoc
Palabra
tools for leaving microsoft word behind.
Stars: ✭ 19 (-54.76%)
Mutual labels:  pandoc
Markdown-Templates
Templates for creating scientific, academic and technical documents using Markdown and Pandoc that support equations, code blocks, citations, Unicode symbols and vector graphics.
Stars: ✭ 130 (+209.52%)
Mutual labels:  pandoc
paru
Control pandoc with Ruby and write pandoc filters in Ruby
Stars: ✭ 30 (-28.57%)
Mutual labels:  pandoc
casile
The CaSILE toolkit, a book publishing workflow employing SILE and other wizardry.
Stars: ✭ 36 (-14.29%)
Mutual labels:  pandoc
pandoc-lecture
This project defines a skeleton repo for creating lecture slides and handouts including lecture notes out of Pandoc Markdown (http://pandoc.org/MANUAL.html) using a single source approach.
Stars: ✭ 72 (+71.43%)
Mutual labels:  pandoc
pandocomatic
Automate the use of pandoc
Stars: ✭ 123 (+192.86%)
Mutual labels:  pandoc
umdoc
A Markdown to LaTeX to PDF converter
Stars: ✭ 15 (-64.29%)
Mutual labels:  pandoc
pandoc samples
sample pandoc-generated PDF font examples
Stars: ✭ 29 (-30.95%)
Mutual labels:  pandoc
redmine convert textile to markown
Redmine rake task to convert content from textile to markdown
Stars: ✭ 45 (+7.14%)
Mutual labels:  pandoc
pandoc-doc-ja
Pandocユーザーズガイド日本語版(Pandoc 2.7.2+準拠)のリポジトリ by Sphinx
Stars: ✭ 19 (-54.76%)
Mutual labels:  pandoc
bookends-tools
Alfred Workflow to Integrate with Bookends, an academic reference manager/bibliography tool for macOS
Stars: ✭ 78 (+85.71%)
Mutual labels:  pandoc
tufte-pandoc-jekyll
A Jekyll theme for using Tufte CSS with Jekyll + Pandoc
Stars: ✭ 56 (+33.33%)
Mutual labels:  pandoc
pandoc-latex-environment
Pandoc filter for adding LaTeX environement on specific div
Stars: ✭ 27 (-35.71%)
Mutual labels:  pandoc
docker-alpine-pandoc-ja
Pandoc for Japanese based on Alpine Linux
Stars: ✭ 14 (-66.67%)
Mutual labels:  pandoc
uiucthemes
RMarkdown Templates for UIUC Theme-Oriented Documents
Stars: ✭ 45 (+7.14%)
Mutual labels:  pandoc
pandoc-include
Pandoc filter to allow file and header includes
Stars: ✭ 35 (-16.67%)
Mutual labels:  pandoc
pandoc-templates
An opinionated set of Pandoc templates and scripts for converting markdown to DOCX manuscripts that adhere to William Shunn's Proper Manuscript Format guidelines using Pandoc.
Stars: ✭ 30 (-28.57%)
Mutual labels:  pandoc
gedit-plugin-markdown preview
A gedit plugin previewing markdown (.md) documents
Stars: ✭ 79 (+88.1%)
Mutual labels:  pandoc

Pandoc PHP Package

Integrate Sponsor

If you need to convert text files from one format to another, pandoc is your swiss-army knife. This package is a PHP wrapper for pandoc.

Installation

You can install the package via composer:

composer require ueberdosis/pandoc

This package is a wrapper for the command-line tool pandoc. Don’t forget to install pandoc. Here is an example for Ubuntu:

sudo apt-get update
sudo apt-get install -y wget
sudo mkdir -p /usr/src/pandoc
cd /usr/src/pandoc
sudo wget https://github.com/jgm/pandoc/releases/download/2.11.4/pandoc-2.11.4-1-amd64.deb
sudo dpkg -i pandoc-2.11.4-1-amd64.deb

More examples are available in the pandoc documentation

Usage

Return the converted text as string

$output = (new \Pandoc\Pandoc)
    ->from('markdown')
    ->input('# Test')
    ->to('html')
    ->run();

Use a file as input and write a file as output

(new \Pandoc\Pandoc)
    ->from('markdown')
    ->inputFile('tests/data/example.md')
    ->to('plain')
    ->output('tests/temp/example.txt')
    ->run();

Change path to Pandoc

new \Pandoc\Pandoc([
    'command' => '/usr/local/bin/pandoc',
]);

Change working directory

(new \Pandoc\Pandoc)->cwd('/tmp/pandoc/');

List available input formats

(new \Pandoc\Pandoc)->listInputFormats();

List available output formats

(new \Pandoc\Pandoc)->listOutputFormats();

Write a log file

echo (new \Pandoc\Pandoc)
    ->from('markdown')
    ->input('# Markdown')
    ->to('html')
    ->log('log.txt')
    ->run();

Retrieve Pandoc version

echo (new \Pandoc\Pandoc)->version();

Use magic methods to make calls shorter

$output = (new \Pandoc\Pandoc)
    ->fromMarkdown('# Test')
    ->toHtml('tests/temp/example.txt')
    ->run();

Pass options to Pandoc

echo (new \Pandoc\Pandoc)
    ->fromMarkdown('# Test')
    ->toHtml('tests/temp/example.txt')
    ->option('fail-if-warnings')
    ->option('data-dir', './tmp')
    ->run();

See https://pandoc.org/MANUAL.html for a full list of available options

Laravel Facade

This package includes a Laravel facade for people that like that little bit of syntactic sugar.

echo \Pandoc\Facades\Pandoc::version();

Exceptions

If something went wrong, the package throws a generic \Symfony\Component\Process\Exception\ProcessFailedException. There are even a few specific exceptions.

  • \Pandoc\Exceptions\PandocNotFound
  • \Pandoc\Exceptions\InputFileNotFound
  • \Pandoc\Exceptions\UnknownInputFormat
  • \Pandoc\Exceptions\UnknownOutputFormat
  • \Pandoc\Exceptions\LogFileNotWriteable
  • \Pandoc\Exceptions\BadMethodCall

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].