Skip to content

Commit

Permalink
Merge pull request #222 from Badgerati/ruby
Browse files Browse the repository at this point in the history
Add ruby pronunciation support on text
  • Loading branch information
Badgerati authored Nov 21, 2021
2 parents 01fcbec + acc2b94 commit ab636c2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/Tutorials/Elements/Text.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ New-PodeWebCard -Content @(
Which looks like below:

![text](../../../images/text.png)

## Pronunciation

You can add small pronunciation text above displayed text by using `-Pronunciation`:

```powershell
New-PodeWebText -Value '漢' -Pronunciation 'ㄏㄢˋ'
```

(Note: for the above to render properly, use PowerShell 6+)
4 changes: 4 additions & 0 deletions examples/full.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ Start-PodeServer -StatusPageExceptions Show {
New-PodeWebText -Value 'example' -Style Italics
New-PodeWebText -Value ' paragraphs' -Style Bold
)
New-PodeWebParagraph -Elements @(
New-PodeWebText -Value 'Pronuncation example: '
New-PodeWebText -Value '' -Pronunciation 'ㄏㄢˋ'
)
New-PodeWebParagraph -Elements @(
New-PodeWebText -Value "Look, here's a "
New-PodeWebLink -Source 'https://github.com/badgerati/pode' -Value 'link' -NewTab
Expand Down
5 changes: 5 additions & 0 deletions src/Public/Elements.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,10 @@ function New-PodeWebText
[hashtable]
$CssStyle,

[Parameter()]
[string]
$Pronunciation,

[Parameter(ParameterSetName='Paragraph')]
[switch]
$InParagraph
Expand All @@ -1056,6 +1060,7 @@ function New-PodeWebText
Parent = $ElementData
ID = (Get-PodeWebElementId -Tag Txt -Id $Id -RandomToken)
Value = [System.Net.WebUtility]::HtmlEncode($Value)
Pronunciation = [System.Net.WebUtility]::HtmlEncode($Pronunciation)
Style = $Style
InParagraph = $InParagraph.IsPresent
Alignment = $Alignment.ToLowerInvariant()
Expand Down
5 changes: 5 additions & 0 deletions src/Templates/Public/styles/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ button#menu-toggle {
width: 50px;
}

ruby rt {
font-size: 53%;
font-style: normal;
}

.footer.powered-by {
border-width: 1px;
border-style: solid;
Expand Down
4 changes: 4 additions & 0 deletions src/Templates/Views/elements/text.pode
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ $(
}
}

if (![string]::IsNullOrWhiteSpace($data.Pronunciation)) {
$value = "<ruby>$($value) <rt>$($data.Pronunciation)</rt></ruby>"
}

if ($data.InParagraph) {
$value = "<p class='text-$($data.Alignment)'>$($value)</p>"
}
Expand Down

0 comments on commit ab636c2

Please sign in to comment.