Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support conversion from standard input #4

Merged
merged 12 commits into from
Aug 25, 2018
Merged

Support conversion from standard input #4

merged 12 commits into from
Aug 25, 2018

Conversation

yhatt
Copy link
Member

@yhatt yhatt commented Aug 25, 2018

This PR will support the conversion from standard input. It could chain process by pipe.

echo "# Markdown" | marp > output.html

By using curl, it will become that can convert Marp Markdown on network resource easily.

# Convert Marp Markdown on Gist
curl https://gist.githubusercontent.com/yhatt/a352e6087c2d5185113b9143f330fb68/raw/1cd8ff1f8b0c0cff39b9273e6ce471240d989de5/uncover.md \
  | marp -o uncover.pdf

The converted buffer came from stdin would output to stdout if you not specified --output option. You can continue processing by piping output to another tools.

For example, you can extract specified pages from converted PDF by using PDFtk server.

# Extract first 3 pages
marp input.md --pdf | pdftk - cat 1-3 output ./output.pdf

}

export class Converter {
readonly options: ConverterOption

constructor(opts: ConverterOption) {
this.options = opts

if (opts.type === ConvertType.pdf && opts.output === '-')
error('PDF cannot output to stdout.')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By this change, we no longer restrict to output PDF into stdout. The default output path will decide by where came input from.

@yhatt yhatt merged commit 4bbcfd0 into master Aug 25, 2018
@yhatt yhatt deleted the support-stdin branch August 25, 2018 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant