Skip to content

Commit 539cfab

Browse files
committed
feat: ✨ Add Bionic text conversion functionality
- Introduced `ConvertTo-Bionic` function to convert text input to Bionic text format, aiding readability for users with dyslexia or ADHD. - Implemented `Get-WordFixationLength` function to determine fixation lengths based on predefined points. - Updated documentation for `ConvertTo-Bionic` with usage examples and parameter descriptions. - Removed deprecated `GetHelloWorld` functions and their associated documentation. - Added test fixture `test.txt` for validating Bionic text conversion.
1 parent 0c18716 commit 539cfab

11 files changed

Lines changed: 432 additions & 84 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
{
2-
"name": "PowerShell",
3-
"dockerFile": "Dockerfile",
4-
"customizations": {
5-
"vscode": {
6-
"settings": {
7-
"terminal.integrated.profiles.linux": {
8-
"bash": {
9-
"path": "usr/bin/bash",
10-
"icon": "terminal-bash"
11-
},
12-
"zsh": {
13-
"path": "usr/bin/zsh"
14-
},
15-
"pwsh": {
16-
"path": "/usr/bin/pwsh",
17-
"icon": "terminal-powershell"
18-
}
19-
},
20-
"terminal.integrated.defaultProfile.linux": "pwsh"
21-
},
22-
"extensions": ["ms-vscode.powershell", "davidanson.vscode-markdownlint"]
23-
}
24-
},
25-
"postCreateCommand": "pwsh -c './build.ps1 -Task Init -Bootstrap'"
2+
"name": "PowerShell",
3+
"dockerFile": "Dockerfile",
4+
"customizations": {
5+
"vscode": {
6+
"settings": {
7+
"terminal.integrated.profiles.linux": {
8+
"bash": {
9+
"path": "usr/bin/bash",
10+
"icon": "terminal-bash"
11+
},
12+
"zsh": {
13+
"path": "usr/bin/zsh"
14+
},
15+
"pwsh": {
16+
"path": "/usr/bin/pwsh",
17+
"icon": "terminal-powershell"
18+
}
19+
},
20+
"terminal.integrated.defaultProfile.linux": "pwsh"
21+
},
22+
"extensions": ["ms-vscode.powershell", "davidanson.vscode-markdownlint"]
23+
}
24+
},
25+
"postCreateCommand": "pwsh -c './build.ps1 -Task Init -Bootstrap'"
2626
}
2727

.vscode/tasks.json

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,42 @@
22
// See https://go.microsoft.com/fwlink/?LinkId=733558
33
// for the documentation about the tasks.json format
44
"version": "2.0.0",
5-
65
// Start PowerShell (pwsh on *nix)
76
"windows": {
87
"options": {
98
"shell": {
10-
"executable": "powershell.exe",
11-
"args": [ "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command" ]
9+
"executable": "pwsh.exe",
10+
"args": [
11+
"-NoProfile",
12+
"-ExecutionPolicy",
13+
"Bypass",
14+
"-Command"
15+
]
1216
}
1317
}
1418
},
1519
"linux": {
1620
"options": {
1721
"shell": {
1822
"executable": "/usr/bin/pwsh",
19-
"args": [ "-NoProfile", "-Command" ]
23+
"args": [
24+
"-NoProfile",
25+
"-Command"
26+
]
2027
}
2128
}
2229
},
2330
"osx": {
2431
"options": {
2532
"shell": {
2633
"executable": "/usr/local/bin/pwsh",
27-
"args": [ "-NoProfile", "-Command" ]
34+
"args": [
35+
"-NoProfile",
36+
"-Command"
37+
]
2838
}
2939
}
3040
},
31-
3241
"tasks": [
3342
{
3443
"label": "Clean",
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Define fixation points
2+
$script:FIXATION_POINTS = @(
3+
@(0, 4, 12, 17, 24, 29, 35, 42, 48),
4+
@(1, 2, 7, 10, 13, 14, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49),
5+
@(1, 2, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49),
6+
@(0, 2, 4, 5, 6, 8, 9, 11, 14, 15, 17, 18, 20, 0, 21, 23, 24, 26, 27, 29, 30, 32, 33, 35, 36, 38, 39, 41, 42, 44, 45, 47, 48),
7+
@(0, 2, 3, 5, 6, 7, 8, 10, 11, 12, 14, 15, 17, 19, 20, 21, 23, 24, 25, 26, 28, 29, 30, 32, 33, 34, 35, 37, 38, 39, 41, 42, 43, 44, 46, 47, 48)
8+
)
9+
10+
function Get-WordFixationLength {
11+
<#
12+
.SYNOPSIS
13+
Determines the fixation length of a word based on its size and the fixation size parameter.
14+
15+
.DESCRIPTION
16+
This function calculates the fixation length of a word by comparing its size to predefined fixation points.
17+
It returns the index of the first fixation point that is greater than or equal to the word size.
18+
19+
.PARAMETER Word
20+
The word for which to determine the fixation length.
21+
22+
.PARAMETER FixationSize
23+
The fixation size to use for the calculation. This should be an integer value.
24+
25+
.EXAMPLE
26+
Get-WordFixationLength -Word "example" -FixationSize 3
27+
28+
This will return the index of the fixation point for the word "example" with a fixation size of 3.
29+
#>
30+
param (
31+
[string]$Word,
32+
[int]$FixationSize
33+
)
34+
$WordSize = $Word.Length
35+
$Points = $script:FIXATION_POINTS[$FixationSize]
36+
37+
foreach ($Point in $Points) {
38+
if ($WordSize -le $Point) {
39+
return [array]::IndexOf($Points, $Point)
40+
}
41+
}
42+
}

Accessibility/Private/GetHelloWorld.ps1

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
function ConvertTo-Bionic {
2+
<#
3+
.SYNOPSIS
4+
Convert text input to Bionic text format.
5+
6+
.DESCRIPTION
7+
Helps some users with dyslexia or ADHD to read text by converting it to a Bionic text format.
8+
9+
.PARAMETER InputFilePath
10+
Path to the input file containing text to be converted.
11+
12+
.PARAMETER InputText
13+
Text to be converted to Bionic text format.
14+
15+
.PARAMETER FixationLength
16+
The length of the fixation point for the Bionic text conversion. Default is 3.
17+
18+
.EXAMPLE
19+
ConvertTo-Bionic -InputFilePath "C:\path\to\input.txt"
20+
21+
Converts the text in the specified file to Bionic text format and saves it to a new file.
22+
23+
.EXAMPLE
24+
ConvertTo-Bionic "Lorem ipsum dolor sit."
25+
26+
Converts the provided text to Bionic text format and outputs it to the console.
27+
28+
.EXAMPLE
29+
Get-Content .\README.md -Raw | ConvertTo-Bionic
30+
31+
Converts the content of the README.md file to Bionic text format and outputs it to the console.
32+
33+
.NOTES
34+
https://www.oxfordlearning.com/what-is-bionic-reading-and-why-should-you-use-it/
35+
#>
36+
[CmdletBinding()]
37+
param (
38+
[Parameter(
39+
Mandatory = $true,
40+
ParameterSetName = 'Text',
41+
ValueFromPipeline = $true,
42+
Position = 0
43+
)]
44+
[string]$InputText,
45+
[Parameter(Mandatory = $true, ParameterSetName = 'File')]
46+
[string]$InputFilePath,
47+
[int]$FixationLength = 3
48+
49+
)
50+
begin {
51+
if ($PSBoundParameters.ContainsKey('InputFilePath')) {
52+
if (-not (Test-Path $InputFilePath)) {
53+
Write-Error "Input file does not exist: $InputFilePath"
54+
return
55+
}
56+
$text = Get-Content -Path $InputFilePath -Raw
57+
} elseif ($PSBoundParameters.ContainsKey('InputText')) {
58+
$text = $InputText
59+
}
60+
$result = ""
61+
}
62+
process {
63+
if ($_ -is [string]) {
64+
$text = $_
65+
}
66+
$prev = 0
67+
68+
# Match words using regex
69+
$words = [regex]::Matches($text, '\p{L}(\p{L}|\p{Nd})*', [System.Text.RegularExpressions.RegexOptions]::IgnoreCase)
70+
71+
foreach ($match in $words) {
72+
$start = $match.Index
73+
$end = $start + $match.Value.Length - (Get-WordFixationLength -Word $match.Value -FixationSize ($FixationLength - 1))
74+
$result += $text.Substring($prev, $start - $prev)
75+
if ($start -ne $end) {
76+
$result += "$($PSStyle.Bold)$($text.Substring($start, $end - $start))$($PSStyle.BoldOff)"
77+
}
78+
$prev = $end
79+
}
80+
}
81+
end {
82+
return $result + $text.Substring($prev)
83+
}
84+
}

Accessibility/Public/Get-HelloWorld.ps1

Lines changed: 0 additions & 22 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## [0.1.0] Unreleased
9-
8+
## [0.1.0] Initial
9+
10+
### Added
11+
12+
- Added new function ConvertTo-Bionic.

docs/en-US/ConvertTo-Bionic.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
external help file: Accessibility-help.xml
3+
Module Name: Accessibility
4+
online version:
5+
schema: 2.0.0
6+
---
7+
8+
# ConvertTo-Bionic
9+
10+
## SYNOPSIS
11+
Convert text input to Bionic text format.
12+
13+
## SYNTAX
14+
15+
### Text
16+
```
17+
ConvertTo-Bionic [-InputText] <String> [-FixationLength <Int32>] [-ProgressAction <ActionPreference>]
18+
[<CommonParameters>]
19+
```
20+
21+
### File
22+
```
23+
ConvertTo-Bionic -InputFilePath <String> [-FixationLength <Int32>] [-ProgressAction <ActionPreference>]
24+
[<CommonParameters>]
25+
```
26+
27+
## DESCRIPTION
28+
Helps some users with dyslexia or ADHD to read text by converting it to a Bionic text format.
29+
30+
## EXAMPLES
31+
32+
### EXAMPLE 1
33+
```
34+
ConvertTo-Bionic -InputFilePath "C:\path\to\input.txt"
35+
```
36+
37+
Converts the text in the specified file to Bionic text format and saves it to a new file.
38+
39+
### EXAMPLE 2
40+
```
41+
ConvertTo-Bionic "Lorem ipsum dolor sit."
42+
```
43+
44+
Converts the provided text to Bionic text format and outputs it to the console.
45+
46+
### EXAMPLE 3
47+
```
48+
Get-Content .\README.md -Raw | ConvertTo-Bionic
49+
```
50+
51+
Converts the content of the README.md file to Bionic text format and outputs it to the console.
52+
53+
## PARAMETERS
54+
55+
### -InputText
56+
Text to be converted to Bionic text format.
57+
58+
```yaml
59+
Type: String
60+
Parameter Sets: Text
61+
Aliases:
62+
63+
Required: True
64+
Position: 1
65+
Default value: None
66+
Accept pipeline input: True (ByValue)
67+
Accept wildcard characters: False
68+
```
69+
70+
### -InputFilePath
71+
Path to the input file containing text to be converted.
72+
73+
```yaml
74+
Type: String
75+
Parameter Sets: File
76+
Aliases:
77+
78+
Required: True
79+
Position: Named
80+
Default value: None
81+
Accept pipeline input: False
82+
Accept wildcard characters: False
83+
```
84+
85+
### -FixationLength
86+
The length of the fixation point for the Bionic text conversion.
87+
Default is 3.
88+
89+
```yaml
90+
Type: Int32
91+
Parameter Sets: (All)
92+
Aliases:
93+
94+
Required: False
95+
Position: Named
96+
Default value: 3
97+
Accept pipeline input: False
98+
Accept wildcard characters: False
99+
```
100+
101+
### -ProgressAction
102+
{{ Fill ProgressAction Description }}
103+
104+
```yaml
105+
Type: ActionPreference
106+
Parameter Sets: (All)
107+
Aliases: proga
108+
109+
Required: False
110+
Position: Named
111+
Default value: None
112+
Accept pipeline input: False
113+
Accept wildcard characters: False
114+
```
115+
116+
### CommonParameters
117+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
118+
119+
## INPUTS
120+
121+
## OUTPUTS
122+
123+
## NOTES
124+
https://www.oxfordlearning.com/what-is-bionic-reading-and-why-should-you-use-it/
125+
126+
## RELATED LINKS

0 commit comments

Comments
 (0)