Skip to content

Commit 72a66b2

Browse files
feat: OpenXML.Word.Heading.get_Markdown ( Fixes PoshWeb#55 )
1 parent 9e98c94 commit 72a66b2

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
$runs = @($this.r)
2+
$headingLevel = 1
3+
if ($this.pPr.pStyle -match '\d') {
4+
$headingLevel = $matches.0 -as [int]
5+
}
6+
7+
('#' * ($headingLevel)) +
8+
' ' +
9+
$(@(foreach ($run in $runs) {
10+
11+
$runText = $run.t
12+
if ($runText -isnot [string]) {
13+
$runText = $run.t.InnerText
14+
}
15+
16+
if (-not $run.rPr.psobject.properties) {
17+
$runText
18+
}
19+
elseif ($run.rPr.psobject.properties['b'] -and
20+
$run.rPr.psobject.properties['i']
21+
) {
22+
"***$runText***"
23+
}
24+
elseif (
25+
$run.rPr.psobject.properties['b']
26+
) {
27+
"**$runText**"
28+
}
29+
elseif (
30+
$run.rPr.psobject.properties['i']
31+
) {
32+
"*$runText*"
33+
} else {
34+
$runText
35+
}
36+
37+
}
38+
) -join '' -replace '(?<=\w)(?>\*{6}|\*{4})(?=\w)')

0 commit comments

Comments
 (0)