Skip to content

Commit e94d0ca

Browse files
authored
Merge pull request #56 from dfinke/add-ConvertTo-DIB
updated with ConvertTo-Dib
2 parents 0aa5bbb + 007426e commit e94d0ca

File tree

5 files changed

+34
-12
lines changed

5 files changed

+34
-12
lines changed

ConvertToDib.ps1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
function ConvertTo-Dib {
2+
<#
3+
.Synopsis
4+
#>
5+
6+
param(
7+
[Parameter(ValueFromPipelineByPropertyName)]
8+
$FullName
9+
)
10+
11+
Process {
12+
if ($FullName.EndsWith('.ipynb')) {
13+
$dibName = $FullName.Replace('.ipynb', '.dib')
14+
15+
foreach ($block in Get-NotebookContent $FullName) {
16+
$prefix = $null
17+
if ($block.Type -eq 'markdown') {
18+
$prefix = "#!markdown`n"
19+
}
20+
21+
$prefix + $block.Source | Add-Content $dibName -Encoding utf8
22+
}
23+
}
24+
}
25+
}

PowerShellNotebook.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ For detailed instructions and examples, click through the "Project Site" link or
6868
'ConvertFrom-IPYNB',
6969
'ConvertFrom-NotebookToMarkdown',
7070
'ConvertFrom-NotebookToHTML',
71+
'ConvertTo-Dib',
7172
'ConvertTo-PowerShellNoteBook',
7273
'ConvertTo-SQLNoteBook',
7374
'Export-NotebookToPowerShellScript',

PowerShellNotebook.psm1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
. $PSScriptRoot\ConvertFrom-IPYNB.ps1
22
. $PSScriptRoot\ConvertFromNotebookToMarkdown.ps1
33
. $PSScriptRoot\ConvertMarkdownToNoteBook.ps1
4+
. $PSScriptRoot\ConvertToDib.ps1
45
. $PSScriptRoot\ConvertToPowerShellNoteBook.ps1
56
. $PSScriptRoot\ConvertToSQLNoteBook.ps1
67
. $PSScriptRoot\ExportAsPowerShellNotebook.ps1
@@ -11,8 +12,8 @@
1112
. $PSScriptRoot\GetNotebookContent.ps1
1213
. $PSScriptRoot\GetNotebookDisplayData.ps1
1314
. $PSScriptRoot\GetParameterInsertionIndex.ps1
14-
. $PSScriptRoot\InvokeExecuteNotebook.ps1
1515
. $PSScriptRoot\InvokePowerShellNotebook.ps1
16+
. $PSScriptRoot\InvokeExecuteNotebook.ps1
1617
. $PSScriptRoot\New-InteractiveNotebook.ps1
1718
. $PSScriptRoot\NewCodeCell.ps1
1819
. $PSScriptRoot\NewGistNotebook.ps1

README.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,12 @@ This module includes the function `Invoke-PowerShellNotebook` which enables you
55
## Continuous Integration Status
66
</br>
77

8-
|Actions||
8+
|GitHub Actions||
99
|---|---|
1010
|[![.github/workflows/ci.yml](https://github.com/dfinke/PowerShellNotebook/workflows/.github/workflows/ci.yml/badge.svg)](https://github.com/dfinke/PowerShellNotebook/actions)|
1111

1212
</br>
1313

14-
|Environment||
15-
|---|---|
16-
| Windows | [![Build Status](https://dougfinke.visualstudio.com/PowerShellNotebook/_apis/build/status/dfinke.PowerShellNotebook?branchName=master&jobName=Windows)](https://dougfinke.visualstudio.com/PowerShellNotebook/_build/latest?definitionId=22&branchName=master)
17-
| Windows (Core) | [![Build Status](https://dougfinke.visualstudio.com/PowerShellNotebook/_apis/build/status/dfinke.PowerShellNotebook?branchName=master&jobName=WindowsPSCore)](https://dougfinke.visualstudio.com/PowerShellNotebook/_build/latest?definitionId=22&branchName=master)
18-
| Ubuntu | [![Build Status](https://dougfinke.visualstudio.com/PowerShellNotebook/_apis/build/status/dfinke.PowerShellNotebook?branchName=master&jobName=Ubuntu)](https://dougfinke.visualstudio.com/PowerShellNotebook/_build/latest?definitionId=22&branchName=master)
19-
| macOS | [![Build Status](https://dougfinke.visualstudio.com/PowerShellNotebook/_apis/build/status/dfinke.PowerShellNotebook?branchName=master&jobName=macOS)](https://dougfinke.visualstudio.com/PowerShellNotebook/_build/latest?definitionId=22&branchName=master)
20-
21-
</br></br>
22-
2314
# Parameterizing a PowerShell Notebook
2415

2516
To parameterize your notebook designate a cell with the tag `parameters`. This is easy using `Azure Data Studio`.

changelog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v 2.9.4
2+
3+
- Added `ConvertTo-Dib`. Converts an `ipynb` file to a `dib` file.
4+
15
## DF 2.9.3
26

37
- Add `-DotNetInteractive` in `ConvertTo-PowerShellNoteBook`
@@ -10,7 +14,7 @@
1014
- `Open-InteractiveNotebook` - Open a local notebook or from remote source
1115

1216
## Check out the 'How To Use' short video
13-
[![PowerShellNotebook](http://img.youtube.com/vi/DAI77tPY-p0/2.jpg)](http://www.youtube.com/watch?v=DAI77tPY-p0 "PowerShellNotebook")
17+
[![PowerShellNotebook](http://img.youtube.com/vi/DAI77tPY-p0/1.jpg)](http://www.youtube.com/watch?v=DAI77tPY-p0 "PowerShellNotebook")
1418

1519
## JO'N May 2021
1620
- Merged DF's code with my additions from late 2020 - see below ...

0 commit comments

Comments
 (0)