-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPocketMarkdown.ps1
More file actions
54 lines (49 loc) · 1.26 KB
/
PocketMarkdown.ps1
File metadata and controls
54 lines (49 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
filter Get-PocketMarkdown {
<#
.SYNOPSIS
Gets Pocket Markdown
.DESCRIPTION
Gets [pckt.blog](https://pckt.blog) content as markdown.
#>
[Alias('PocketMarkdown')]
param()
$in = $_
$mySelf = $MyInvocation.MyCommand.ScriptBlock
@(switch ($in.'$type') {
blog.pckt.content {
$in.items | . $mySelf
}
blog.pckt.block.codeBlock {
[Environment]::NewLine
@(
"~~~$($in.attrs.language)"
$in.plainText
"~~~"
) -join [Environment]::NewLine
[Environment]::NewLine
}
blog.pckt.block.text {
if ($in.plainText) {
$in.plainText
[Environment]::NewLine
}
if ($in.content) {
$in.content | . $myself
}
}
blog.pckt.block.heading {
if ($in.level -as [int]) {
"#" * ($in.level -as [int])
}
if ($in.content) {
$in.content | . $myself
}
}
blog.pckt.block.hardBreak {
[Environment]::NewLine
}
default {
$in
}
}) -join ''
}