Skip to content

Commit

Permalink
Adds Emphasis tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Hunt committed Dec 29, 2023
1 parent a96d572 commit f461526
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ $manifest = @{
CmdletsToExport = ''
VariablesToExport = ''
AliasesToExport = @('H1', 'Heading1', 'Header1', 'H2', 'Heading2', 'Header2', 'H3', 'Heading3', 'Header3',
'P', 'B', 'A', 'Link', 'Href',
'P', 'B', 'I', 'em', 'A', 'Link', 'Href',
'Table', 'TBody', 'TR', 'TH', 'TD')
}

Expand Down
30 changes: 30 additions & 0 deletions docs/New-Emphasis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# New-Emphasis

Add Emphasis/Italics text.

## Parameters

### Parameter Set 1

- `[ScriptBlock]` **TextBlock** _A scriptblock rendering the text contents._ Mandatory

### Parameter Set 2

- `[String]` **Text** _A string of the text contents._ Mandatory

## Examples

### Example 1

Create a Markdown document with the contents `_My italics text_`

```powershell
New-Document { P { I "My italics text"} }
```
### Example 2

Create an Html document with the contents `<p><em>My italics text</em></p>`

```powershell
New-Document -Type Html/Bootstrap { P { I "My italics text"} }
```
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Helper for formatting web documents.
## Commands

- [New-Document](New-Document.md) _Create a new Document object of a given Type._
- [New-Emphasis](New-Emphasis.md) _Add Emphasis/Italics text._
- [New-Heading1](New-Heading1.md) _Add an H1 Heading._
- [New-Heading2](New-Heading2.md) _Add an H2 Heading._
- [New-Heading3](New-Heading3.md) _Add an H3 Heading._
Expand Down
34 changes: 34 additions & 0 deletions src/public/New-Emphasis.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function New-Emphasis {
<#
.SYNOPSIS
Add Emphasis/Italics text.
.PARAMETER TextBlock
A scriptblock rendering the text contents.
.PARAMETER Text
A string of the text contents.
.EXAMPLE
New-Document { P { I "My italics text"} }
Create a Markdown document with the contents `_My italics text_`
.EXAMPLE
New-Document -Type Html/Bootstrap { P { I "My italics text"} }
Create an Html document with the contents `<p><em>My italics text</em></p>`
#>
[CmdletBinding()]
[Alias('I', 'em')]
param (
[Parameter(Mandatory, Position = 0, ParameterSetName = "ScriptBlock")]
[scriptblock]
$TextBlock,

[Parameter(Mandatory, Position = 0, ParameterSetName = "String")]
[string]
$Text
)

if ($PSBoundParameters.ContainsKey('TextBlock')) {
$Text = $TextBlock.Invoke()
}
$formatter["Emphasis"] -f $Text
}
7 changes: 4 additions & 3 deletions test/Format-Document.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ BeforeAll {
B "bold text cmdlet"
"."
Link "link Text" "https://google.com"
I "emphasis"
}

Table {
Expand Down Expand Up @@ -50,7 +51,7 @@ Describe 'Format-Document' {
[System.Environment]::NewLine,
'01/01/2023 00:00:00',
[System.Environment]::NewLine,
'normal text **bold text cmdlet** . [link Text](https://google.com)',
'normal text **bold text cmdlet** . [link Text](https://google.com) _emphasis_',
[System.Environment]::NewLine,
@'
Expand Down Expand Up @@ -80,7 +81,7 @@ Describe 'Format-Document' {
[System.Environment]::NewLine,
'<p>01/01/2023 00:00:00</p>',
[System.Environment]::NewLine,
'<p>normal text <strong>bold text cmdlet</strong> . <a href="https://google.com">link Text</a></p>',
'<p>normal text <strong>bold text cmdlet</strong> . <a href="https://google.com">link Text</a> <em>emphasis</em></p>',
[System.Environment]::NewLine,
@'
<table class="table table-striped"><tbody>
Expand Down Expand Up @@ -109,7 +110,7 @@ Describe 'Format-Document' {
[System.Environment]::NewLine,
'<p>01/01/2023 00:00:00</p>',
[System.Environment]::NewLine,
'<p>normal text <strong>bold text cmdlet</strong> . <a href="https://google.com">link Text</a></p>',
'<p>normal text <strong>bold text cmdlet</strong> . <a href="https://google.com">link Text</a> <em>emphasis</em></p>',
[System.Environment]::NewLine,
@'
<table><tbody>
Expand Down

0 comments on commit f461526

Please sign in to comment.