Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## MarkX 0.1.2:

Minor performance improvements:

* Directly using Markdig (#38)
* Preferring `[IO.File]::Exists` (#42)

---

## MarkX 0.1.1:

* MarkX Help (#26)
Expand Down
20 changes: 7 additions & 13 deletions MarkX.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'MarkX.psm1'

# Version number of this module.
ModuleVersion = '0.1.1'
ModuleVersion = '0.1.2'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -63,18 +63,12 @@ PrivateData = @{

# ReleaseNotes of this module
ReleaseNotes = @'
## MarkX 0.1.1:

* MarkX Help (#26)
* MarkX now accepts commands / help (#27)
* MarkX.Headings gets heading elements (#29)
* MarkX.Lexicon gets lexicons in Markdown (#25)
* MarkX.YamlHeader support (#32, #33)
* Allowing piped markdown file input (#34)
* MarkX.Code gets code within markdown (#30)
* MarkX.CodeBlock gets code blocks within markdown (#31)
* MarkX.ToString can now stringify any property (#35)
* MarkX formatting (#36)
## MarkX 0.1.2:

Minor performance improvements:

* Directly using Markdig (#38)
* Preferring `[IO.File]::Exists` (#42)

---

Expand Down
15 changes: 10 additions & 5 deletions MarkX.types.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<Name>Sync</Name>
<Script>
$currentRows = @()

$allMarkdown = @(:nextInput foreach ($md in $this.Input) {
if ($md -isnot [string]) {
# If the markdown was a file
Expand Down Expand Up @@ -141,7 +142,10 @@ $allMarkdown = @(:nextInput foreach ($md in $this.Input) {
}

if ($md -match '(?&gt;\.md|markdown)$' -and
(Test-Path $md -ErrorAction Ignore)
(
[IO.File]::Exists("$md") -or
(Test-Path $md -ErrorAction Ignore)
)
) {
$md = Get-Content -Raw $md
}
Expand All @@ -167,7 +171,7 @@ $allMarkdown = @(foreach ($md in $allMarkdown) {
if ($md -match '^---') {
$null, $yamlheader, $restOfMakdown = $md -split '---', 3
if ($yamlheader) {
$yamlHeaders+= $yamlheader
$yamlHeaders+= $yamlheader
}
$restOfMakdown
} else {
Expand All @@ -191,11 +195,12 @@ $Markdown = $this.'#Markdown'

if (-not $Markdown) { return }

$mdPipelineBuilder = [Markdig.MarkdownPipelineBuilder]::new()
$mdPipeline = [Markdig.MarkdownExtensions]::UsePipeTables($mdPipelineBuilder).Build()

$this |
Add-Member NoteProperty '#HTML' (
$Markdown |
ConvertFrom-Markdown |
Select-Object -ExpandProperty Html
[Markdig.Markdown]::ToHtml($markdown, $mdPipeline)
) -Force

$this |
Expand Down
15 changes: 10 additions & 5 deletions Types/MarkX/Sync.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
$currentRows = @()

$allMarkdown = @(:nextInput foreach ($md in $this.Input) {
if ($md -isnot [string]) {
# If the markdown was a file
Expand Down Expand Up @@ -105,7 +106,10 @@ $allMarkdown = @(:nextInput foreach ($md in $this.Input) {
}

if ($md -match '(?>\.md|markdown)$' -and
(Test-Path $md -ErrorAction Ignore)
(
[IO.File]::Exists("$md") -or
(Test-Path $md -ErrorAction Ignore)
)
) {
$md = Get-Content -Raw $md
}
Expand All @@ -131,7 +135,7 @@ $allMarkdown = @(foreach ($md in $allMarkdown) {
if ($md -match '^---') {
$null, $yamlheader, $restOfMakdown = $md -split '---', 3
if ($yamlheader) {
$yamlHeaders+= $yamlheader
$yamlHeaders+= $yamlheader
}
$restOfMakdown
} else {
Expand All @@ -155,11 +159,12 @@ $Markdown = $this.'#Markdown'

if (-not $Markdown) { return }

$mdPipelineBuilder = [Markdig.MarkdownPipelineBuilder]::new()
$mdPipeline = [Markdig.MarkdownExtensions]::UsePipeTables($mdPipelineBuilder).Build()

$this |
Add-Member NoteProperty '#HTML' (
$Markdown |
ConvertFrom-Markdown |
Select-Object -ExpandProperty Html
[Markdig.Markdown]::ToHtml($markdown, $mdPipeline)
) -Force

$this |
Expand Down
Loading