From 60a4e2f84ea5ee044b9d7c8d254e2cde8b3e1e08 Mon Sep 17 00:00:00 2001 From: Alan Longstaff Date: Wed, 17 Mar 2021 22:32:04 +0000 Subject: [PATCH 1/2] Update New-HTMLText.ps1 Removed ")" exclusion from $FindMe - any string in [text](url) format should now match, regardless of number of brackets in url. No longer require lazy matching for $LinkURL - it should always end in ")" which can then be excluded. Should fix #200 --- Public/New-HTMLText.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Public/New-HTMLText.ps1 b/Public/New-HTMLText.ps1 index 8ffb1f7a..d0a0b632 100644 --- a/Public/New-HTMLText.ps1 +++ b/Public/New-HTMLText.ps1 @@ -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) } From ac77f88546a227f969c1672e3891f0dc64958961 Mon Sep 17 00:00:00 2001 From: Przemyslaw Klys Date: Wed, 17 Mar 2021 23:49:08 +0100 Subject: [PATCH 2/2] Added example --- Examples/Example-Texts/Example-Texts01.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Examples/Example-Texts/Example-Texts01.ps1 b/Examples/Example-Texts/Example-Texts01.ps1 index 2d085d37..f1ca475c 100644 --- a/Examples/Example-Texts/Example-Texts01.ps1 +++ b/Examples/Example-Texts/Example-Texts01.ps1 @@ -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)." + ) } \ No newline at end of file