Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Examples/Example-Texts/Example-Texts01.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ New-HTML -TitleText 'My title' -Online -FilePath $PSScriptRoot\Example-Texts01.h
New-HTMLListItem -Text '[Link2](https://evotec.xyz) SomeText'
New-HTMLListItem -Text '[Link2](https://evotec.xyz) SomeText (TestingText in brackets) and more [more test in brackets] (and more)'
}
New-HTMLText -Text @(
"This is a string with [SomeURL](https://evotec.xyz) and this isn't. "
"This is more complicated [URL](https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn535495(v=ws.11)) with double () and it doesn't work properly "
"More URLs in one line [SomeURL](https://evotec.xyz) and and [SomeURL](https://evotec.xyz)."
)
}
4 changes: 2 additions & 2 deletions Public/New-HTMLText.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ function New-HTMLText {

$newSpanTextSplat.LineBreak = $LineBreak
New-HTMLSpanStyle @newSpanTextSplat {
$FindMe = [regex]::Matches($Text[$i], "\[[^\]]+\]\([^)]+\)")
$FindMe = [regex]::Matches($Text[$i], "\[[^\]]+\]\(\S+\)")
if ($FindMe) {
foreach ($find in $FindMe) {
$LinkName = ([regex]::Match($Find.value, "[^\[]+(?=\])")).Value
$LinkURL = ([regex]::Match($Find.value, "(?<=\().+?(?=\))")).Value
$LinkURL = ([regex]::Match($Find.value, "(?<=\().+(?=\))")).Value
$Link = New-HTMLAnchor -HrefLink $LinkURL -Text $LinkName
$Text[$i] = $Text[$i].Replace($find.value, $Link)
}
Expand Down