iainbrighton / PScribo

PowerShell documentation framework
MIT License
231 stars 35 forks source link

Paragraph -NoNewLine parameter not working #75

Closed tpcarman closed 2 years ago

tpcarman commented 6 years ago

When using Paragraph -NoNewLine, text is still moved to a new line

$Username = $env:USERNAME
$Date = Get-Date -Format D
Document NoNewLine {
    Paragraph "Username: "
    Paragraph $Username -NoNewLine
    Paragraph "Date: "
    Paragraph $Date -NoNewLine
} | Export-Document -Format Word -Path $env:TEMP -Verbose -PassThru | Invoke-Item
iainbrighton commented 6 years ago

I think I've got to the bottom of this and the solution is not easy. Plain text output is not affected, but HTML output suffers the same fate. Here's a summary:

A solution to this is to add another parameter set to the Paragraph function to accept a script block for each "run":

Document ParagraphRuns {
    Paragraph {
        Run "This is the first part of a paragraph"
        Run "This will append the second part of a paragraph"
    }
}

Would this proposal work? This won't break existing functionality, but would probably require dropping (or deprecating) the -NoNewLine parameter on the Paragraph function.

Note: I don't think that Run would be a good choice of function name, but would like some suggestions!

iainbrighton commented 6 years ago

Not that it helps, but it seems I did know about this already 😊.

image

iainbrighton commented 4 years ago

@tpcarman This functionality is now available in the dev branch if you want to take it for a spin. You will need to use the new Paragraph { } implementation for it to work (the old implementation will remain for compatibility and ease of use). See Example38.ps1 for more details.