Skip to content

Issu with New-HTMLMarkdown #402

@Rapidhands

Description

@Rapidhands

Hi Klys,
I've teste your sample in this page https://evotec.xyz/unlocking-seamless-html-report-creation-harness-the-power-of-markdown-with-pswritehtml-powershell-module/ using one of my mardown file.
This markdown file has some powershell code and some console output in it.
Here a sample :

  • Avoid repeated calls to a function. Calling a function can be an expensive operation. If you calling a function in a long running tight loop, consider moving the loop inside the function.

Demo :

$ranGen = New-Object System.Random
$RepeatCount = 10000

Measure-MyScript -Name "Basic for-loop" -Unit ms -Repeat 10 -ScriptBlock {
    for ($i = 0; $i -lt $RepeatCount; $i++) {
        $Null = $ranGen.Next()
    }
}

# wraps the random number generator in a function that's called in a tight loop
Measure-MyScript -Name "Wrapped in a function" -Unit ms -Repeat 10 -ScriptBlock {
    function Get-RandNum_Core {
        param ($ranGen)
        $ranGen.Next()
    }

    for ($i = 0; $i -lt $RepeatCount; $i++) {
        $Null = Get-RandNum_Core $ranGen
    }
}
# The function is only called once but the code still generates 10000 random numbers. 
Measure-MyScript -Name "For-loop in a function" -Unit ms -Repeat 10 -ScriptBlock {
    function Get-RandNum_All {
        param ($ranGen)
        for ($i = 0; $i -lt $RepeatCount; $i++) {
            $Null = $ranGen.Next()
        }
    }

    Get-RandNum_All $ranGen
}
name                    Avg                   Min                   Max
----                    ---                   ---                   ---
Basic for-loop          8,1763 Milliseconds   7,1114 Milliseconds   9,1556 Milliseconds
Wrapped in a function   157,3784 Milliseconds 148,9869 Milliseconds 165,9685 Milliseconds
For-loop in a function  5,4158 Milliseconds   4,7084 Milliseconds   7,1147 Milliseconds

The display in the html file is weird. The powershell block code is fragmented.

2023-09-03_21-14

Another point : In the beginning of the screenshot, I've a check box
2023-09-03_21-16
The display is weird too. I'm using "Markdown Checkboxes" extension in VSCode to do this.

regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions