MartinPacker / md2pptx

Markdown To PowerPoint converter
MIT License
222 stars 35 forks source link

formatTitle function is resizing and repositioning the title box #82

Closed liteman closed 3 years ago

liteman commented 3 years ago

I have configured a Slide Title on the Title and Content layout - it is positioned around slide graphics. The formatTitle() function is flattening the title box which causes the content placeholder to move up the slide.

Ideally, if a title box is found - the dimensions should not be modified.

local fix was to comment out assignments to title.top/left/width


def formatTitle(presentation, slide, titleText, titleFontSize):
    # Find title
    title = findTitleShape(slide)

    if titleText == " ":
        deleteSimpleShape(title)

        return (marginBase, None, "<No title>")

    # Do not resize or reposition the template title
    #title.top = marginBase
    #title.left = marginBase
    #title.width = presentation.slide_width - marginBase * 2

    # Figure out how many lines title will need (ignoring overflow)
    #titleLineCount = len(titleText.split("<br/>"))

    # Add the title text to the first paragraph
    flattenedTitle = addFormattedText(title.text_frame.paragraphs[0], titleText)
MartinPacker commented 3 years ago

Thanks for this. I would like to create a metadata item to govern this. Then you needn't keep patching the code...

Philosophically what I'm trying to do with this code is automate the tidying up of a presentation. In the docs I describe the "origin story" - reworking a surly, higgledy piggledy presentation. Part of that was fonts ' colours and part of that was automating the placement of items. (This latter becomes even more important when there are multiple non-title elements on a slide.)

I have a question: Is it a title / section slide you want a "don't reposition" semantic for? Or is it all slide titles - including ones with content?

I'm not even sure my title repositioning code gets it quite right anyway so am more than happy to reopen this bit of the code. Might be a few days, though.

I assume you're OK with metadata to control md2pptx. Otherwise we have a much bigger problem. :-( :-)

liteman commented 3 years ago

Ideally, Title and Content placeholders do not move and are not resized. Though just stopping the Title box modification fixed my content-related issues as well.

metadata controls make sense to me -- thank you!

MartinPacker commented 3 years ago

OK. Not going to do keeping content fixed as there are so many use cases where that would be wrong. For example, where you have 2 tables on one slide - and you're probably not going to make a template slide like that.

Question: Is it ALL titles you want nailed in place? Or just Title Slide and Section Slide?

And glad metadata works for you. I assume this need not be "dynamic". The same setting applies for the whole presentation. (Not hard to offer dynamic but it seems overkill - unless someone tells me it's not.)

liteman commented 3 years ago

Yes, all titles. My use-case doesn't require it to be dynamic. I want to preserve the title placement from all of my template layouts.

MartinPacker commented 3 years ago

All titles is simpler. :-) I don't need to code "what slide type is this?" I'm considering syntax:

AdjustTitles: False

for your use case. Default would be True. Of course this is all case insensitive.

MartinPacker commented 3 years ago

Went with AdjustTitles: no - in keeping with other boolean metadata items.

MartinPacker commented 3 years ago

Pushed. Documentation to follow.

MartinPacker commented 3 years ago

Docs done and pushed. I'd like to fix Issue 84 and any bugs from this before releasing 2.2.1 and closing this.

MartinPacker commented 3 years ago

fixed in v2.2.1.