Skip to content

Commit d59b291

Browse files
committed
Enable a fence block to also be ```powershell
1 parent 95c92d6 commit d59b291

4 files changed

Lines changed: 37 additions & 2 deletions

File tree

‎ConvertMarkdownToNoteBook.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
$inCodeBlock = $false
6969

7070
switch ($chapters.$chapter) {
71-
'```ps' {
71+
{ $_ -eq '```ps' -or $_ -eq '```powershell' } {
7272
Add-NotebookMarkdown -markdown (-join $markDown)
7373
$code = @()
7474
$inCodeBlock = $true

‎PowerShellNotebook.psd1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
RootModule = 'PowerShellNoteBook.psm1'
55

66
# Version number of this module.
7-
ModuleVersion = '1.0.5'
7+
ModuleVersion = '1.0.6'
88

99
# ID used to uniquely identify this module
1010
GUID = '2ab0cb25-b339-4726-8a2a-349ca1114bd4'

‎__tests__/ConvertToMarkdownToNotebook.tests.ps1‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,30 @@ Describe "Test Convert-MarkdownToPowerShellNoteBook" {
5252

5353
$psnb.cells[3].cell_type | should be markdown
5454
}
55+
56+
It "Check the PowerShell fence block NB content" {
57+
$sourceMD = "$PSScriptRoot\samplemarkdown\demoPowerShellFenceBlock.md"
58+
$nbFile = "$PSScriptRoot\samplemarkdown\demoPowerShellFenceBlock.ipynb"
59+
60+
Convert-MarkdownToNoteBook -filename $sourceMD
61+
62+
(Test-Path $nbFile) | should be $true
63+
64+
$psnb = Get-Content $nbFile | ConvertFrom-Json
65+
66+
$psnb.cells.count | should be 4
67+
68+
$psnb.cells[0].cell_type | should be markdown
69+
$psnb.cells[0].source | should beexactly '# Chapter 1'
70+
71+
$psnb.cells[1].cell_type | should be markdown
72+
$psnb.cells[1].source.trim() | should beexactly 'This is `addition`'
73+
74+
$psnb.cells[2].cell_type | should be code
75+
$psnb.cells[2].source.trim() | should beexactly "40 + 2"
76+
$psnb.cells[2].outputs.text.trim() | should beexactly "42"
77+
78+
$psnb.cells[3].cell_type | should be markdown
79+
Remove-Item $nbFile -ErrorAction SilentlyContinue
80+
}
5581
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!-- chapter start -->
2+
3+
This is `addition`
4+
5+
```powershell
6+
40 + 2
7+
```
8+
9+
<!-- chapter end -->

0 commit comments

Comments
 (0)