diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..5dc46e6 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +* text=auto eol=lf +*.{cmd,[cC][mM][dD]} text eol=crlf +*.{bat,[bB][aA][tT]} text eol=crlf \ No newline at end of file diff --git a/src/constants.jl b/src/constants.jl index 2d66413..84fc2ed 100644 --- a/src/constants.jl +++ b/src/constants.jl @@ -13,4 +13,7 @@ const TITLE_SLIDE_LAYOUT = 1 const DEFAULT_SLIDE_LAYOUT = 2 include_dependency(joinpath(TEMPLATE_DIR, "tableStyles.xml")) -const DEFAULT_TABLE_STYLE_DATA = read(joinpath(TEMPLATE_DIR, "tableStyles.xml")) \ No newline at end of file +const DEFAULT_TABLE_STYLE_DATA = read(joinpath(TEMPLATE_DIR, "tableStyles.xml")) + +include_dependency(joinpath(TEMPLATE_DIR, "no-slides.pptx")) +const DEFAULT_TEMPLATE_DATA = read(joinpath(TEMPLATE_DIR, "no-slides.pptx")) \ No newline at end of file diff --git a/src/write.jl b/src/write.jl index 7b3c71b..de9d75c 100644 --- a/src/write.jl +++ b/src/write.jl @@ -98,6 +98,19 @@ function add_contenttypes!(w::ZipWriter, template::ZipBufferReader) zip_commitfile(w) end +# Support reading a template from file path or from pre-read file data. +function read_template(template_path::AbstractString) + template_path = abspath(template_path) + template_isfile = isfile(template_path) + if !template_isfile + error( + "No file found at template path: $(repr(template_path))", + ) + end + read(template_path) +end +read_template(template_data::AbstractVector{UInt8}) = template_data + """ ```julia Base.write( @@ -137,18 +150,9 @@ function Base.write( p::Presentation; overwrite::Bool=false, open_ppt::Bool=true, - template_path::String=joinpath(TEMPLATE_DIR, "no-slides.pptx"), + template_path::Union{String, Vector{UInt8}}=DEFAULT_TEMPLATE_DATA, ) - - template_path = abspath(template_path) - template_isfile = isfile(template_path) - - if !template_isfile - error( - "No file found at template path: $(repr(template_path))", - ) - end - template_reader = ZipBufferReader(read(template_path)) + template_reader = ZipBufferReader(read_template(template_path)) if !endswith(filepath, ".pptx") filepath *= ".pptx"