diff --git a/d2cli/main.go b/d2cli/main.go index 9f5f7484f..dc9f0e229 100644 --- a/d2cli/main.go +++ b/d2cli/main.go @@ -35,7 +35,7 @@ import ( "oss.terrastruct.com/d2/lib/pdf" pdflib "oss.terrastruct.com/d2/lib/pdf" "oss.terrastruct.com/d2/lib/png" - "oss.terrastruct.com/d2/lib/ppt" + "oss.terrastruct.com/d2/lib/pptx" "oss.terrastruct.com/d2/lib/textmeasure" "oss.terrastruct.com/d2/lib/version" @@ -368,7 +368,7 @@ func compile(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, rende if user, err := user.Current(); err != nil { username = user.Username } - p := ppt.NewPresentation(rootName, rootName, rootName, username, version.Version) + p := pptx.NewPresentation(rootName, rootName, rootName, username, version.Version) err := renderPPTX(ctx, ms, p, plugin, renderOpts, outputPath, page, diagram, nil) if err != nil { return nil, false, err @@ -759,7 +759,7 @@ func renderPDF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, opt return svg, nil } -func renderPPTX(ctx context.Context, ms *xmain.State, presentation *ppt.Presentation, plugin d2plugin.Plugin, opts d2svg.RenderOpts, outputPath string, page playwright.Page, diagram *d2target.Diagram, boardPath []string) error { +func renderPPTX(ctx context.Context, ms *xmain.State, presentation *pptx.Presentation, plugin d2plugin.Plugin, opts d2svg.RenderOpts, outputPath string, page playwright.Page, diagram *d2target.Diagram, boardPath []string) error { var currBoardPath []string // Root board doesn't have a name, so we use the output filename if diagram.Name == "" { diff --git a/lib/ppt/pptx.go b/lib/pptx/pptx.go similarity index 99% rename from lib/ppt/pptx.go rename to lib/pptx/pptx.go index 34fbe6ab4..825c34da1 100644 --- a/lib/ppt/pptx.go +++ b/lib/pptx/pptx.go @@ -1,4 +1,4 @@ -package ppt +package pptx import ( "archive/zip" diff --git a/lib/ppt/presentation.go b/lib/pptx/presentation.go similarity index 77% rename from lib/ppt/presentation.go rename to lib/pptx/presentation.go index 81775135c..63cf860ce 100644 --- a/lib/ppt/presentation.go +++ b/lib/pptx/presentation.go @@ -1,4 +1,13 @@ -package ppt +// pptx is a package to create slide presentations in pptx (Microsoft Power Point) format. +// A `.pptx` file is just a bunch of zip compressed `.xml` files following the Office Open XML (OOXML) format. +// To see its content, you can just `unzip .pptx -d `. +// With this package, it is possible to create a `Presentation` and add `Slide`s to it. +// Then, when saving the presentation, it will generate the required `.xml` files, compress them and write to the disk. +// Note that this isn't a full implementation of the OOXML format, but a wrapper around it. +// There's a base template with common files to the presentation and then when saving, the package generate only the slides and relationships. +// The base template and slide templates were generated using https://python-pptx.readthedocs.io/en/latest/ +// For more information about OOXML, check http://officeopenxml.com/index.php +package pptx import ( "archive/zip" @@ -9,11 +18,6 @@ import ( "os" ) -// TODO: comments / references / assumptions -// TODO: update core files with metadata -// TODO: links? -// TODO: appendix? - type Presentation struct { Title string Description string diff --git a/lib/ppt/template.pptx b/lib/pptx/template.pptx similarity index 100% rename from lib/ppt/template.pptx rename to lib/pptx/template.pptx