Running the Pandoc container

Given that anyone can create a Docker image with most applications and tools, you will find more than one Pandoc implementation on the internet. I have prepared a stable example in this book's GitHub repository: https://github.com/DenysVuika/pandoc-docker.

The image for this section was initially forked from https://github.com/jagregory/pandoc-docker, so credit goes to the author, James Gregory. In my version, I am keeping the base image and Pandoc libraries up to date.

Let's learn how the conversion process works:

  1. Start Docker.
  2. Navigate to the Monaco Editor demo page (https://microsoft.github.io/monaco-editor/) and copy the contents of the markdown example.
  1. Save the markdown example somewhere on your local drive with the name test.md.
  1. In the Terminal window, navigate to the location of the test.md file and run the following command:
// for Linux and macOS
docker run -v `pwd`:/source denysvuika/pandoc -f markdown -t html5 test.md -o test.html

// for Windows
docker run -v %cd%:/source denysvuika/pandoc -f markdown -t html5 test.md -o test.html

Here, we're taking test.md as input and using the denysvuika/pandoc image to convert it into an HTML5 page called test.html. After a while, you should see the following output:

Unable to find image 'denysvuika/pandoc:latest' locally
latest: Pulling from denysvuika/pandoc
bc9ab73e5b14: Pull complete
d553ba08f210: Pull complete
a5e51e378eb4: Pull complete
858ca3975bae: Pull complete
c3ecb06ceeb4: Pull complete
Digest: sha256:010d68dcc6a3de0a8ca2a6b812ccd5be16b515524270fb4996413990a6e50776
Status: Downloaded newer image for denysvuika/pandoc:latest
The first run may take a while because of Docker downloading and caching the images. All subsequent runs are usually instant.
  1. Now, if you check the output folder, you should see the test.html file. Open the file in your preferred browser and check its contents:

You have successfully generated HTML output from the markdown file. Feel free to experiment with changing the content of the markdown file and converting init to HTML5. Check out all the possible conversion scenarios at https://pandoc.org/.

Next, we need to find out how we can run the same command from within our Electron application. However, before doing that, we need to update the save process so that we can use the Node.js process.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset