diff --git a/CHANGELOG.md b/CHANGELOG.md
index b4923b8..451ac6a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,14 @@
+## MarkX 0.1.3:
+
+* Property Improvement:
+ * Late binding MarkX.DataSet (#44)
+* New Properties:
+ * MarkX.Liquid ( #45 )
+ * MarkX.LiquidPattern ( #46 )
+
+---
+
+
## MarkX 0.1.2:
Minor performance improvements:
diff --git a/MarkX.psd1 b/MarkX.psd1
index 42fc14a..466c622 100644
--- a/MarkX.psd1
+++ b/MarkX.psd1
@@ -12,7 +12,7 @@
RootModule = 'MarkX.psm1'
# Version number of this module.
-ModuleVersion = '0.1.2'
+ModuleVersion = '0.1.3'
# Supported PSEditions
# CompatiblePSEditions = @()
@@ -63,12 +63,13 @@ PrivateData = @{
# ReleaseNotes of this module
ReleaseNotes = @'
-## MarkX 0.1.2:
+## MarkX 0.1.3:
-Minor performance improvements:
-
-* Directly using Markdig (#38)
-* Preferring `[IO.File]::Exists` (#42)
+* Property Improvement:
+ * Late binding MarkX.DataSet (#44)
+* New Properties:
+ * MarkX.Liquid ( #45 )
+ * MarkX.LiquidPattern ( #46 )
---
diff --git a/MarkX.types.ps1xml b/MarkX.types.ps1xml
index 0a99c26..91a647a 100644
--- a/MarkX.types.ps1xml
+++ b/MarkX.types.ps1xml
@@ -210,94 +210,7 @@ $this |
if (-not $this.'#XML') { return }
-$tables = $this.'#XML' | Select-Xml //table
-filter innerText {
- $in = $_
- if ($in -is [string]) { "$in" }
- elseif ($in.innerText) { "$($in.innerText)" }
- elseif ($in.'#text') { "$($in.'#text')" }
-}
-
-function bestType {
- $allIn = @($input) + @(if ($args) { $args})
- switch ($true) {
- { $allIn -as [float[]] } {
- [float]; break
- }
- { $allIn -as [double[]] } {
- [double]; break
- }
- { $allIn -as [long[]] } {
- [long]; break
- }
- { $allIn -as [ulong[]] } {
- [uint32]; break
- }
- { $allIn -as [decimal[]] } {
- [decimal]; break
- }
- { $allIn -as [timespan[]] } {
- [timespan]; break
- }
- { $allIn -as [DateTime[]] } {
- [DateTime]; break
- }
- default {
- [string]
- }
- }
-}
-
-$markdownData = [Data.DataSet]::new('MarkX')
-$tableNumber = 0
-foreach ($table in $tables) {
- $tableNumber++
- $markdownDataTable = $markdownData.Tables.Add("MarkdownTable$tableNumber")
-
- [string[]]$PropertyNames = @( $table.Node.thead.tr.th | innerText )
-
- # We want to upcast our datatable as much as possible
- # so we need to collect the rows first
- $TableDictionary = [Ordered]@{}
- $propertyIndex = 0
- foreach ($property in $propertyNames) {
- $TableDictionary[$property] = @(
- foreach ($row in $table.Node.tbody.tr) {
- @($row.td)[$propertyIndex] | innerText
- }
- )
- $propertyIndex++
- }
-
- # Now that we have all of the data collected,
- $markdownDataTable.Columns.AddRange(@(
- foreach ($property in $propertyNames) {
- $propertyIndex = 0
- $bestType = $TableDictionary[$property] | bestType
- [Data.DataColumn]::new($property, $bestType, '', 'Attribute')
- }
- [Data.DataColumn]::new('tr', [xml.xmlelement], '', 'Hidden')
- ))
-
- foreach ($row in $table.Node.tbody.tr) {
- $propertyValues = @(
- $row.td | innerText
- $row
- )
- $null = $markdownDataTable.Rows.Add($propertyValues)
- }
-
- $previous = $table.Node.PreviousSibling
- if ($previous.LocalName -eq 'blockquote') {
- $markdownDataTable.ExtendedProperties.Add("description", $previous.InnerText)
- $previous = $previous.PreviousSibling
- }
- if ($previous.LocalName -match 'h[1-6]') {
- $markdownDataTable.TableName = $previous.InnerText
- }
-}
-
-$this | Add-Member NoteProperty '#DataSet' $markdownData -Force
+$this.psobject.Properties.Remove('#DataSet')
@@ -474,7 +387,99 @@ return $codeByLanguage
DataSet
- return $this.'#DataSet'
+ if ($this.'#DataSet') {return $this.'#DataSet' }
+
+$tables = $this.'#XML' | Select-Xml //table
+filter innerText {
+ $in = $_
+ if ($in -is [string]) { "$in" }
+ elseif ($in.innerText) { "$($in.innerText)" }
+ elseif ($in.'#text') { "$($in.'#text')" }
+}
+
+function bestType {
+ $allIn = @($input) + @(if ($args) { $args})
+ switch ($true) {
+ { $allIn -as [float[]] } {
+ [float]; break
+ }
+ { $allIn -as [double[]] } {
+ [double]; break
+ }
+ { $allIn -as [long[]] } {
+ [long]; break
+ }
+ { $allIn -as [ulong[]] } {
+ [uint32]; break
+ }
+ { $allIn -as [decimal[]] } {
+ [decimal]; break
+ }
+ { $allIn -as [timespan[]] } {
+ [timespan]; break
+ }
+ { $allIn -as [DateTime[]] } {
+ [DateTime]; break
+ }
+ default {
+ [string]
+ }
+ }
+}
+
+$markdownData = [Data.DataSet]::new('MarkX')
+$tableNumber = 0
+foreach ($table in $tables) {
+ $tableNumber++
+ $markdownDataTable = $markdownData.Tables.Add("MarkdownTable$tableNumber")
+
+ [string[]]$PropertyNames = @( $table.Node.thead.tr.th | innerText )
+
+ # We want to upcast our datatable as much as possible
+ # so we need to collect the rows first
+ $TableDictionary = [Ordered]@{}
+ $propertyIndex = 0
+ foreach ($property in $propertyNames) {
+ $TableDictionary[$property] = @(
+ foreach ($row in $table.Node.tbody.tr) {
+ @($row.td)[$propertyIndex] | innerText
+ }
+ )
+ $propertyIndex++
+ }
+
+ # Now that we have all of the data collected,
+ $markdownDataTable.Columns.AddRange(@(
+ foreach ($property in $propertyNames) {
+ $propertyIndex = 0
+ $bestType = $TableDictionary[$property] | bestType
+ [Data.DataColumn]::new($property, $bestType, '', 'Attribute')
+ }
+ [Data.DataColumn]::new('tr', [xml.xmlelement], '', 'Hidden')
+ ))
+
+ foreach ($row in $table.Node.tbody.tr) {
+ $propertyValues = @(
+ $row.td | innerText
+ $row
+ )
+ $null = $markdownDataTable.Rows.Add($propertyValues)
+ }
+
+ $previous = $table.Node.PreviousSibling
+ if ($previous.LocalName -eq 'blockquote') {
+ $markdownDataTable.ExtendedProperties.Add("description", $previous.InnerText)
+ $previous = $previous.PreviousSibling
+ }
+ if ($previous.LocalName -match 'h[1-6]') {
+ $markdownDataTable.TableName = $previous.InnerText
+ }
+}
+
+$this | Add-Member NoteProperty '#DataSet' $markdownData -Force
+
+return $this.'#DataSet'
+
@@ -653,6 +658,55 @@ $markdownData = $this.DataSet
}
+
+ Liquid
+
+ <#
+.SYNOPSIS
+ Get Liquid
+.DESCRIPTION
+ Get Liquid within the Markdown
+#>
+if ($this.LiquidPattern -is [regex]) {
+ return $this.LiquidPattern.Matches("$($this.Markdown)")
+}
+
+
+
+
+ LiquidPattern
+
+ <#
+.SYNOPSIS
+ Get the Liquid Pattern
+.DESCRIPTION
+ Gets the regular expression pattern used to match Liquid tags.
+#>
+param()
+$liquidPattern = @(
+ '(?>'
+ '\{\%\s{0,}'
+ '(?<tag>[^\%]+)'
+ '\s{0,}\%}'
+
+ '|'
+
+ '(?<noescape>\{{3})'
+ '(?<expression>[^\}]+)'
+ '\}{3}'
+
+ '|'
+
+ '\{{2}'
+ '(?<expression>[^\}]+)'
+ '\}{2}'
+ ')'
+) -join ''
+
+return [Regex]::new($liquidPattern)
+
+
+
Markdown
@@ -670,7 +724,15 @@ $this.Input = $Markdown
Table
- $this.XML | Select-Xml -XPath '//table' | Select-Object -ExpandProperty Node
+ <#
+.SYNOPSIS
+ Gets any tables
+.DESCRIPTION
+ Gets any tables present in the markdown
+#>
+$this.XML |
+ Select-Xml -XPath '//table' |
+ Select-Object -ExpandProperty Node
diff --git a/Types/MarkX/Sync.ps1 b/Types/MarkX/Sync.ps1
index fad0730..f1d1fe9 100644
--- a/Types/MarkX/Sync.ps1
+++ b/Types/MarkX/Sync.ps1
@@ -174,91 +174,4 @@ $this |
if (-not $this.'#XML') { return }
-$tables = $this.'#XML' | Select-Xml //table
-filter innerText {
- $in = $_
- if ($in -is [string]) { "$in" }
- elseif ($in.innerText) { "$($in.innerText)" }
- elseif ($in.'#text') { "$($in.'#text')" }
-}
-
-function bestType {
- $allIn = @($input) + @(if ($args) { $args})
- switch ($true) {
- { $allIn -as [float[]] } {
- [float]; break
- }
- { $allIn -as [double[]] } {
- [double]; break
- }
- { $allIn -as [long[]] } {
- [long]; break
- }
- { $allIn -as [ulong[]] } {
- [uint32]; break
- }
- { $allIn -as [decimal[]] } {
- [decimal]; break
- }
- { $allIn -as [timespan[]] } {
- [timespan]; break
- }
- { $allIn -as [DateTime[]] } {
- [DateTime]; break
- }
- default {
- [string]
- }
- }
-}
-
-$markdownData = [Data.DataSet]::new('MarkX')
-$tableNumber = 0
-foreach ($table in $tables) {
- $tableNumber++
- $markdownDataTable = $markdownData.Tables.Add("MarkdownTable$tableNumber")
-
- [string[]]$PropertyNames = @( $table.Node.thead.tr.th | innerText )
-
- # We want to upcast our datatable as much as possible
- # so we need to collect the rows first
- $TableDictionary = [Ordered]@{}
- $propertyIndex = 0
- foreach ($property in $propertyNames) {
- $TableDictionary[$property] = @(
- foreach ($row in $table.Node.tbody.tr) {
- @($row.td)[$propertyIndex] | innerText
- }
- )
- $propertyIndex++
- }
-
- # Now that we have all of the data collected,
- $markdownDataTable.Columns.AddRange(@(
- foreach ($property in $propertyNames) {
- $propertyIndex = 0
- $bestType = $TableDictionary[$property] | bestType
- [Data.DataColumn]::new($property, $bestType, '', 'Attribute')
- }
- [Data.DataColumn]::new('tr', [xml.xmlelement], '', 'Hidden')
- ))
-
- foreach ($row in $table.Node.tbody.tr) {
- $propertyValues = @(
- $row.td | innerText
- $row
- )
- $null = $markdownDataTable.Rows.Add($propertyValues)
- }
-
- $previous = $table.Node.PreviousSibling
- if ($previous.LocalName -eq 'blockquote') {
- $markdownDataTable.ExtendedProperties.Add("description", $previous.InnerText)
- $previous = $previous.PreviousSibling
- }
- if ($previous.LocalName -match 'h[1-6]') {
- $markdownDataTable.TableName = $previous.InnerText
- }
-}
-
-$this | Add-Member NoteProperty '#DataSet' $markdownData -Force
+$this.psobject.Properties.Remove('#DataSet')
diff --git a/Types/MarkX/get_DataSet.ps1 b/Types/MarkX/get_DataSet.ps1
index ef8b5e5..d81f29b 100644
--- a/Types/MarkX/get_DataSet.ps1
+++ b/Types/MarkX/get_DataSet.ps1
@@ -1 +1,92 @@
-return $this.'#DataSet'
\ No newline at end of file
+if ($this.'#DataSet') {return $this.'#DataSet' }
+
+$tables = $this.'#XML' | Select-Xml //table
+filter innerText {
+ $in = $_
+ if ($in -is [string]) { "$in" }
+ elseif ($in.innerText) { "$($in.innerText)" }
+ elseif ($in.'#text') { "$($in.'#text')" }
+}
+
+function bestType {
+ $allIn = @($input) + @(if ($args) { $args})
+ switch ($true) {
+ { $allIn -as [float[]] } {
+ [float]; break
+ }
+ { $allIn -as [double[]] } {
+ [double]; break
+ }
+ { $allIn -as [long[]] } {
+ [long]; break
+ }
+ { $allIn -as [ulong[]] } {
+ [uint32]; break
+ }
+ { $allIn -as [decimal[]] } {
+ [decimal]; break
+ }
+ { $allIn -as [timespan[]] } {
+ [timespan]; break
+ }
+ { $allIn -as [DateTime[]] } {
+ [DateTime]; break
+ }
+ default {
+ [string]
+ }
+ }
+}
+
+$markdownData = [Data.DataSet]::new('MarkX')
+$tableNumber = 0
+foreach ($table in $tables) {
+ $tableNumber++
+ $markdownDataTable = $markdownData.Tables.Add("MarkdownTable$tableNumber")
+
+ [string[]]$PropertyNames = @( $table.Node.thead.tr.th | innerText )
+
+ # We want to upcast our datatable as much as possible
+ # so we need to collect the rows first
+ $TableDictionary = [Ordered]@{}
+ $propertyIndex = 0
+ foreach ($property in $propertyNames) {
+ $TableDictionary[$property] = @(
+ foreach ($row in $table.Node.tbody.tr) {
+ @($row.td)[$propertyIndex] | innerText
+ }
+ )
+ $propertyIndex++
+ }
+
+ # Now that we have all of the data collected,
+ $markdownDataTable.Columns.AddRange(@(
+ foreach ($property in $propertyNames) {
+ $propertyIndex = 0
+ $bestType = $TableDictionary[$property] | bestType
+ [Data.DataColumn]::new($property, $bestType, '', 'Attribute')
+ }
+ [Data.DataColumn]::new('tr', [xml.xmlelement], '', 'Hidden')
+ ))
+
+ foreach ($row in $table.Node.tbody.tr) {
+ $propertyValues = @(
+ $row.td | innerText
+ $row
+ )
+ $null = $markdownDataTable.Rows.Add($propertyValues)
+ }
+
+ $previous = $table.Node.PreviousSibling
+ if ($previous.LocalName -eq 'blockquote') {
+ $markdownDataTable.ExtendedProperties.Add("description", $previous.InnerText)
+ $previous = $previous.PreviousSibling
+ }
+ if ($previous.LocalName -match 'h[1-6]') {
+ $markdownDataTable.TableName = $previous.InnerText
+ }
+}
+
+$this | Add-Member NoteProperty '#DataSet' $markdownData -Force
+
+return $this.'#DataSet'
diff --git a/Types/MarkX/get_Liquid.ps1 b/Types/MarkX/get_Liquid.ps1
new file mode 100644
index 0000000..fef0767
--- /dev/null
+++ b/Types/MarkX/get_Liquid.ps1
@@ -0,0 +1,9 @@
+<#
+.SYNOPSIS
+ Get Liquid
+.DESCRIPTION
+ Get Liquid within the Markdown
+#>
+if ($this.LiquidPattern -is [regex]) {
+ return $this.LiquidPattern.Matches("$($this.Markdown)")
+}
diff --git a/Types/MarkX/get_LiquidPattern.ps1 b/Types/MarkX/get_LiquidPattern.ps1
new file mode 100644
index 0000000..b37c73f
--- /dev/null
+++ b/Types/MarkX/get_LiquidPattern.ps1
@@ -0,0 +1,28 @@
+<#
+.SYNOPSIS
+ Get the Liquid Pattern
+.DESCRIPTION
+ Gets the regular expression pattern used to match Liquid tags.
+#>
+param()
+$liquidPattern = @(
+ '(?>'
+ '\{\%\s{0,}'
+ '(?[^\%]+)'
+ '\s{0,}\%}'
+
+ '|'
+
+ '(?\{{3})'
+ '(?[^\}]+)'
+ '\}{3}'
+
+ '|'
+
+ '\{{2}'
+ '(?[^\}]+)'
+ '\}{2}'
+ ')'
+) -join ''
+
+return [Regex]::new($liquidPattern)
diff --git a/Types/MarkX/get_Table.ps1 b/Types/MarkX/get_Table.ps1
index 67d86b1..31bb18a 100644
--- a/Types/MarkX/get_Table.ps1
+++ b/Types/MarkX/get_Table.ps1
@@ -1 +1,9 @@
-$this.XML | Select-Xml -XPath '//table' | Select-Object -ExpandProperty Node
\ No newline at end of file
+<#
+.SYNOPSIS
+ Gets any tables
+.DESCRIPTION
+ Gets any tables present in the markdown
+#>
+$this.XML |
+ Select-Xml -XPath '//table' |
+ Select-Object -ExpandProperty Node
\ No newline at end of file