Skip to content

Instantly share code, notes, and snippets.

@BroVic
Forked from dmode/build.ps1
Last active August 31, 2023 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BroVic/a01390df06b74f2fa6848ecf9fa865eb to your computer and use it in GitHub Desktop.
Save BroVic/a01390df06b74f2fa6848ecf9fa865eb to your computer and use it in GitHub Desktop.
Powershell script to convert a markdown file into an word document by using pandoc
<#
.SYNOPSIS
Script to convert markdown file to word document
.DESCRIPTION
Convertes a markdown file into an word document using pandoc as converter. The process uses a word template file
.PARAMETER i
Specifies the input file. This is the markdown file
.PARAMETER o
Specifies the output file. This is the word document
.PARAMETER t
specifies the name of the word template used to convert the markdown file to a word document
.EXAMPLE
C:\PS> ./build.ps1 -i myfile.md -o myfile.docx -t mytemplate.docx
Example that converts the file myfile.md
.NOTES
Author: Oliver Graf
Date: November 19, 2016
#>
#Requires -Version 3.0
param(
[Parameter(Mandatory)][string]$in,
[Parameter(Mandatory)][string]$out,
[string]$temp = "build.docx"
)
Write-Host ("Processing file {0} with template {1} and convert to {2}" -f $in, $temp, $out)
pandoc --reference-docx=$temp $in -o $out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment