Skip to content

Commit aef9cd1

Browse files
Merge pull request #96 from StartAutomating/EZ-Hyperlinks
EZOut 1.9.8
2 parents 7e3594a + 49cf978 commit aef9cd1

File tree

9 files changed

+212
-94
lines changed

9 files changed

+212
-94
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 1.9.8:
2+
3+
* Format-RichText now supports -Hyperlink (Fixes #93)
4+
* Format-RichText now outputs a single string (Fixes #95)
5+
6+
---
7+
18
## 1.9.7:
29
* Format-RichText now unbolds bright colors (Fixes #88)
310
* Now Blogging with GitPub (Fixes #89)

EZOut.format.ps1xml

Lines changed: 80 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-16"?>
2-
<!-- Generated with EZOut 1.9.7: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
2+
<!-- Generated with EZOut 1.9.8: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
33
<Configuration>
44
<SelectionSets>
55
<SelectionSet>
@@ -984,12 +984,13 @@ if ($Request -or $Host.UI.SupportsHTML) {
984984
if (-not ($canUseANSI -or $canUseHTML)) { return $false}
985985
return $true
986986
})]
987+
[OutputType([string])]
987988
param(
988989
# The input object
989990
[Parameter(ValueFromPipeline)]
990991
[PSObject]
991992
$InputObject,
992-
993+
993994
# The foreground color
994995
[string]$ForegroundColor,
995996

@@ -1024,6 +1025,12 @@ if ($Request -or $Host.UI.SupportsHTML) {
10241025

10251026
# If set, will invert text
10261027
[switch]$Invert,
1028+
1029+
# If provided, will create a hyperlink to a given uri
1030+
[Alias('Hyperlink', 'Href')]
1031+
[uri]
1032+
$Link,
1033+
10271034
# If set, will not clear formatting
10281035
[switch]$NoClear
10291036
)
@@ -1039,8 +1046,10 @@ if ($Request -or $Host.UI.SupportsHTML) {
10391046
$standardColors = 'Black', 'Red', 'Green', 'Yellow', 'Blue','Magenta', 'Cyan', 'White'
10401047
$brightColors = 'BrightBlack', 'BrightRed', 'BrightGreen', 'BrightYellow', 'BrightBlue','BrightMagenta', 'BrightCyan', 'BrightWhite'
10411048

1049+
$allOutput = @()
1050+
10421051
$n =0
1043-
$cssClasses = @()
1052+
$cssClasses = @()
10441053
$colorAttributes =
10451054
@(:nextColor foreach ($hc in $ForegroundColor,$BackgroundColor) {
10461055
$n++
@@ -1217,6 +1226,17 @@ if ($Request -or $Host.UI.SupportsHTML) {
12171226
if ($canUseHTML) { "border-bottom: 3px double;"}
12181227
elseif ($canUseANSI) {'' +$esc + "[21m" }
12191228
}
1229+
1230+
if ($Hyperlink) {
1231+
if ($canUseHTML) {
1232+
# Hyperlinks need to be a nested element
1233+
# so we will not add it to style attributes for HTML
1234+
}
1235+
elseif ($canUseANSI) {
1236+
# For ANSI,
1237+
'' + $esc + ']8m;;' + $Hyperlink + $esc + '\'
1238+
}
1239+
}
12201240

12211241
)
12221242

@@ -1226,61 +1246,76 @@ if ($Request -or $Host.UI.SupportsHTML) {
12261246
if ($styleAttributes) { " style='$($styleAttributes -join ';')'"}
12271247
)$(
12281248
if ($cssClasses) { " class='$($cssClasses -join ' ')'"}
1229-
)&gt;"
1249+
)&gt;" + $(
1250+
if ($Hyperlink) {
1251+
"&lt;a href='$hyperLink'&gt;"
1252+
}
1253+
)
12301254
} elseif ($canUseANSI) {
12311255
$styleAttributes -join ''
12321256
}
12331257
}
12341258

12351259
process {
1236-
if ($header) {
1237-
"$header" + "$(if ($inputObject) { $inputObject | Out-String})".Trim()
1238-
}
1239-
elseif ($inputObject) {
1240-
($inputObject | Out-String).Trim()
1241-
}
1260+
$allOutput +=
1261+
if ($header) {
1262+
"$header" + "$(if ($inputObject) { $inputObject | Out-String})".Trim()
1263+
}
1264+
elseif ($inputObject) {
1265+
($inputObject | Out-String).Trim()
1266+
}
12421267
}
12431268

12441269
end {
12451270

12461271
if (-not $NoClear) {
1247-
if ($canUseHTML) {
1248-
"&lt;/span&gt;"
1249-
}
1250-
elseif ($canUseANSI) {
1251-
if ($Bold -or $Faint -or $colorAttributes -match '\[1;') {
1252-
"$esc[22m"
1253-
}
1254-
if ($Italic) {
1255-
"$esc[23m"
1256-
}
1257-
if ($Underline -or $doubleUnderline) {
1258-
"$esc[24m"
1259-
}
1260-
if ($Blink) {
1261-
"$esc[25m"
1262-
}
1263-
if ($Invert) {
1264-
"$esc[27m"
1265-
}
1266-
if ($hide) {
1267-
"$esc[28m"
1268-
}
1269-
if ($Strikethru) {
1270-
"$esc[29m"
1271-
}
1272-
if ($ForegroundColor) {
1273-
"$esc[39m"
1274-
}
1275-
if ($BackgroundColor) {
1276-
"$esc[49m"
1272+
$allOutput +=
1273+
if ($canUseHTML) {
1274+
if ($Hyperlink) {
1275+
"&lt;/a&gt;"
1276+
}
1277+
"&lt;/span&gt;"
12771278
}
1278-
1279-
if (-not ($Underline -or $Bold -or $Invert -or $ForegroundColor -or $BackgroundColor)) {
1280-
'' + $esc + '[0m'
1279+
elseif ($canUseANSI) {
1280+
if ($Bold -or $Faint -or $colorAttributes -match '\[1;') {
1281+
"$esc[22m"
1282+
}
1283+
if ($Italic) {
1284+
"$esc[23m"
1285+
}
1286+
if ($Underline -or $doubleUnderline) {
1287+
"$esc[24m"
1288+
}
1289+
if ($Blink) {
1290+
"$esc[25m"
1291+
}
1292+
if ($Invert) {
1293+
"$esc[27m"
1294+
}
1295+
if ($hide) {
1296+
"$esc[28m"
1297+
}
1298+
if ($Strikethru) {
1299+
"$esc[29m"
1300+
}
1301+
if ($ForegroundColor) {
1302+
"$esc[39m"
1303+
}
1304+
if ($BackgroundColor) {
1305+
"$esc[49m"
1306+
}
1307+
1308+
if ($Hyperlink) {
1309+
"$esc]8;;$esc\"
1310+
}
1311+
1312+
if (-not ($Underline -or $Bold -or $Invert -or $ForegroundColor -or $BackgroundColor)) {
1313+
'' + $esc + '[0m'
1314+
}
12811315
}
1282-
}
12831316
}
1317+
1318+
$allOutput -join ''
12841319
}
12851320
</ScriptBlock>
12861321
</ExpressionBinding>
@@ -1615,6 +1650,7 @@ $BackgroundColor
16151650

16161651
# If set, will create a link. The -InputObject will be used as the link content
16171652
[Parameter(ValueFromPipelineByPropertyName)]
1653+
[Alias('Hyperlink', 'Href')]
16181654
[string]
16191655
$Link,
16201656

EZOut.psd1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@{
22
ModuleToProcess = 'EZOut.psm1'
3-
ModuleVersion = '1.9.7'
3+
ModuleVersion = '1.9.8'
44
GUID = 'cef786f0-8a0b-4a5d-a2c6-b433095354cd'
55
Author = 'James Brundage'
66
CompanyName = 'Start-Automating'
@@ -65,6 +65,14 @@
6565

6666
Tags = '.ps1xml', 'Format','Output','Types', 'Colorized'
6767
ReleaseNotes = @'
68+
## 1.9.8:
69+
70+
* Format-RichText now supports -Hyperlink (Fixes #93)
71+
* Format-RichText now outputs a single string (Fixes #95)
72+
73+
---
74+
75+
6876
## 1.9.7:
6977
* Format-RichText now unbolds bright colors (Fixes #88)
7078
* Now Blogging with GitPub (Fixes #89)

Format-Markdown.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ function Format-Markdown
5757

5858
# If set, will create a link. The -InputObject will be used as the link content
5959
[Parameter(ValueFromPipelineByPropertyName)]
60+
[Alias('Hyperlink', 'Href')]
6061
[string]
6162
$Link,
6263

0 commit comments

Comments
 (0)