refactor ppt
This commit is contained in:
parent
bda5c933a3
commit
4bd44ec4b5
3 changed files with 3 additions and 12 deletions
|
|
@ -9,11 +9,10 @@ type exportExtension string
|
||||||
const GIF exportExtension = ".gif"
|
const GIF exportExtension = ".gif"
|
||||||
const PNG exportExtension = ".png"
|
const PNG exportExtension = ".png"
|
||||||
const PPTX exportExtension = ".pptx"
|
const PPTX exportExtension = ".pptx"
|
||||||
const PPT exportExtension = ".ppt"
|
|
||||||
const PDF exportExtension = ".pdf"
|
const PDF exportExtension = ".pdf"
|
||||||
const SVG exportExtension = ".svg"
|
const SVG exportExtension = ".svg"
|
||||||
|
|
||||||
var SUPPORTED_EXTENSIONS = []exportExtension{SVG, PNG, PDF, PPTX, GIF, PPT}
|
var SUPPORTED_EXTENSIONS = []exportExtension{SVG, PNG, PDF, PPTX, GIF}
|
||||||
|
|
||||||
func getExportExtension(outputPath string) exportExtension {
|
func getExportExtension(outputPath string) exportExtension {
|
||||||
ext := filepath.Ext(outputPath)
|
ext := filepath.Ext(outputPath)
|
||||||
|
|
|
||||||
|
|
@ -57,14 +57,6 @@ func TestOutputFormat(t *testing.T) {
|
||||||
requiresAnimationInterval: false,
|
requiresAnimationInterval: false,
|
||||||
requiresPngRender: true,
|
requiresPngRender: true,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
outputPath: "/out.ppt",
|
|
||||||
extension: PPT,
|
|
||||||
supportsDarkTheme: false,
|
|
||||||
supportsAnimation: false,
|
|
||||||
requiresAnimationInterval: false,
|
|
||||||
requiresPngRender: false,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
outputPath: "/out.pdf",
|
outputPath: "/out.pdf",
|
||||||
extension: PDF,
|
extension: PDF,
|
||||||
|
|
|
||||||
|
|
@ -187,10 +187,10 @@ func Run(ctx context.Context, ms *xmain.State) (err error) {
|
||||||
inputPath = filepath.Join(inputPath, "index.d2")
|
inputPath = filepath.Join(inputPath, "index.d2")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
outputFormat := getExportExtension(outputPath)
|
if filepath.Ext(outputPath) == ".ppt" {
|
||||||
if outputFormat == PPT {
|
|
||||||
return xmain.UsageErrorf("D2 does not support ppt exports, did you mean \"pptx\"?")
|
return xmain.UsageErrorf("D2 does not support ppt exports, did you mean \"pptx\"?")
|
||||||
}
|
}
|
||||||
|
outputFormat := getExportExtension(outputPath)
|
||||||
if outputPath != "-" {
|
if outputPath != "-" {
|
||||||
outputPath = ms.AbsPath(outputPath)
|
outputPath = ms.AbsPath(outputPath)
|
||||||
if *animateIntervalFlag > 0 && !outputFormat.supportsAnimation() {
|
if *animateIntervalFlag > 0 && !outputFormat.supportsAnimation() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue