Skip to content

Commit 02fadca

Browse files
Merge pull request #37 from StartAutomating/lexmark
MarkX 0.1.1
2 parents 025c8ca + a0d93d5 commit 02fadca

22 files changed

Lines changed: 1113 additions & 131 deletions

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
## MarkX 0.1.1:
2+
3+
* MarkX Help (#26)
4+
* MarkX now accepts commands / help (#27)
5+
* MarkX.Headings gets heading elements (#29)
6+
* MarkX.Lexicon gets lexicons in Markdown (#25)
7+
* MarkX.YamlHeader support (#32, #33)
8+
* Allowing piped markdown file input (#34)
9+
* MarkX.Code gets code within markdown (#30)
10+
* MarkX.CodeBlock gets code blocks within markdown (#31)
11+
* MarkX.ToString can now stringify any property (#35)
12+
* MarkX formatting (#36)
13+
14+
---
15+
116
## MarkX 0.1:
217

318
* `Get-MarkX` ( #1, #4 )

Commands/Get-MarkX.ps1

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,57 @@
11
function Get-MarkX {
2-
[Alias('MarkX','Markdown','Get-Markdown')]
2+
<#
3+
.SYNOPSIS
4+
Gets MarkX
5+
.DESCRIPTION
6+
Gets MarkX - Markdown as XML
7+
8+
This allows us to query, extract, and customize markdown.
9+
.EXAMPLE
10+
# 'Hello World' In Markdown / MarkX
11+
'# Hello World' | MarkX
12+
.EXAMPLE
13+
# MarkX is aliased to Markdown
14+
# 'Hello World' as Markdown as XML
15+
'# Hello World' | Markdown | Select -Expand XML
16+
.EXAMPLE
17+
# We can generate tables by piping in objects
18+
@{n1=1;n2=2}, @{n1=2;n3=3} | MarkX
19+
.EXAMPLE
20+
# Make a TimesTable in MarkX
21+
@(
22+
"#### TimesTable"
23+
foreach ($rowN in 1..9) {
24+
$row = [Ordered]@{}
25+
foreach ($colN in 1..9) {
26+
$row["$colN"] = $colN * $rowN
27+
}
28+
$row
29+
}
30+
) | Get-MarkX
31+
.EXAMPLE
32+
# We can pipe a command into MarkX
33+
# This will get the command help as Markdown
34+
Get-Command Get-MarkX | MarkX
35+
.EXAMPLE
36+
# We can pipe help into MarkX
37+
Get-Help Get-MarkX | MarkX
38+
.EXAMPLE
39+
# We can get code from markdown
40+
Get-Help Get-MarkX |
41+
MarkX |
42+
Select-Object -ExpandProperty Code
43+
#>
44+
[Alias('MarkX','Markdown','Get-Markdown')]
345
param()
446

547
$allInput = @($input) + $(if ($args) {
648
$args
7-
})
49+
})
850

9-
[PSCustomObject]@{
10-
PSTypeName = 'MarkX'
11-
Markdown = $allInput
12-
YamlHeader = $yamlheader
13-
}
51+
52+
$markx = New-Object PSObject -Property @{
53+
PSTypeName = 'MarkX'
54+
}
55+
$markx.Input = $allInput
56+
$markx
1457
}

MarkX.format.ps1xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!-- Generated with EZOut 2.0.6: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
2+
<Configuration>
3+
<ViewDefinitions>
4+
<View>
5+
<Name>MarkX</Name>
6+
<ViewSelectedBy>
7+
<TypeName>MarkX</TypeName>
8+
</ViewSelectedBy>
9+
<TableControl>
10+
<TableHeaders>
11+
<TableColumnHeader>
12+
</TableColumnHeader>
13+
</TableHeaders>
14+
<TableRowEntries>
15+
<TableRowEntry>
16+
<Wrap />
17+
<TableColumnItems>
18+
<TableColumnItem>
19+
<PropertyName>Markdown</PropertyName>
20+
</TableColumnItem>
21+
</TableColumnItems>
22+
</TableRowEntry>
23+
</TableRowEntries>
24+
</TableControl>
25+
</View>
26+
</ViewDefinitions>
27+
</Configuration>

MarkX.ps1

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
77
"@ | MarkX
88

9+
@"
10+
11+
[![MarkX PowerShell Gallery](https://img.shields.io/powershellgallery/dt/MarkX)](https://www.powershellgallery.com/packages/MarkX/)
12+
13+
"@ | MarkX
914

1015
@'
1116
@@ -226,3 +231,91 @@ $(& $GetMarkdownTableData)
226231
227232
"@ | MarkX
228233

234+
235+
$lexiconMarkdown = @'
236+
237+
238+
### Markdown Lexicons
239+
240+
Since we can extra tables and data Markdown, we can also get any data of a particular known shape.
241+
242+
The first special shape MarkX supports is an [at protocol lexicon](https://atproto.com/guides/lexicon)
243+
244+
MarkX current supports lexicon type definitions. It will support query and procedure definitions in the future.
245+
246+
A type definition consists of a namespace identifier, a description, and a series of properties.
247+
248+
#### com.example.happy.birthday
249+
> An example lexicon to record birthday messages
250+
251+
|Property|Type|Description|
252+
|-|-|-|
253+
|`$type` | `[string]` | The type of the object. Must be `com.example.happy.birthday` |
254+
|**`message`**| `[string]` | A birthday message |
255+
|`forUri` | `[uri]` | A link |
256+
|`birthday` | `[datetime]` | The birthday |
257+
|`createdAt` | `[datetime]` | The time the record was created |
258+
259+
'@ | MarkX
260+
261+
$lexiconMarkdown
262+
263+
264+
$lexiconJson = $lexiconMarkdown.Lexicon | ConvertTo-Json -Depth 5
265+
266+
$lexiconMarkdownExample = @'
267+
268+
269+
To extract out a lexicon from the text above, we can:
270+
271+
~~~PowerShell
272+
$lexiconMarkdown.Lexicon | ConvertTo-Json -Depth 5
273+
~~~
274+
275+
Which gives us:
276+
277+
'@ + @"
278+
279+
~~~json
280+
$lexiconJson
281+
~~~
282+
283+
As you can see, we can take rich data within Markdown and process it into lexicons (or anything else we might want)
284+
"@
285+
286+
$lexiconMarkdownExample | MarkX
287+
288+
289+
$selfHelp = {Get-Help Get-MarkX | MarkX}
290+
291+
$markdownHelp = @"
292+
293+
### Markdown Help
294+
295+
PowerShell commands generally contain help.
296+
297+
We can pipe Get-Help into MarkX to get help as markdown
298+
299+
~~~PowerShell
300+
$selfHelp
301+
~~~
302+
303+
When we run this, we get:
304+
305+
"@
306+
307+
. $selfHelp
308+
309+
310+
$InSummary = @"
311+
312+
## In Summary
313+
314+
MarkX is a simple and powerful tool.
315+
It allows us to turn many objects into Markdown, and turn Markdown into many objects.
316+
317+
Please pay around and see what you can do.
318+
319+
"@
320+
321+
$InSummary | MarkX

MarkX.psd1

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'MarkX.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.1'
15+
ModuleVersion = '0.1.1'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()
@@ -36,7 +36,7 @@ Description = 'MarkX - Markdown, XML, and PowerShell'
3636
TypesToProcess = @('MarkX.types.ps1xml')
3737

3838
# Format files (.ps1xml) to be loaded when importing this module
39-
# FormatsToProcess = @()
39+
FormatsToProcess = @('MarkX.format.ps1xml')
4040

4141
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
4242
FunctionsToExport = 'Get-MarkX'
@@ -63,31 +63,22 @@ PrivateData = @{
6363

6464
# ReleaseNotes of this module
6565
ReleaseNotes = @'
66-
## MarkX 0.1:
67-
68-
* `Get-MarkX` ( #1, #4 )
69-
* Docs
70-
* Sponsorship ( #20 )
71-
* Security ( #19 )
72-
* Contributing ( #18 )
73-
* Code of conduct ( #17 )
74-
* README (generated with MarkX) (#16)
75-
* Extended Types
76-
* `MarkX.get_HTML` ( #14 )
77-
* `MarkX.ToString()` ( #12 )
78-
* `MarkX.get_DataSet` ( #13 )
79-
* `MarkX.get_Images` (#11)
80-
* `MarkX.get_Links` (#10)
81-
* `MarkX.get_Table` ( #9 )
82-
* `MarkX.get_InnerText` ( #8 )
83-
* `MarkX.get_XML` ( #7 )
84-
* `MarkX.get/set_Markdown` ( #6 )
85-
* `MarkX.Sync` ( #5 )
86-
* `MarkX.ToTable` ( #22 )
87-
* MarkX build ( #2, #3 )
88-
* MarkX Action ( #21 )
89-
* MarkX Tests ( #15 )
90-
66+
## MarkX 0.1.1:
67+
68+
* MarkX Help (#26)
69+
* MarkX now accepts commands / help (#27)
70+
* MarkX.Headings gets heading elements (#29)
71+
* MarkX.Lexicon gets lexicons in Markdown (#25)
72+
* MarkX.YamlHeader support (#32, #33)
73+
* Allowing piped markdown file input (#34)
74+
* MarkX.Code gets code within markdown (#30)
75+
* MarkX.CodeBlock gets code blocks within markdown (#31)
76+
* MarkX.ToString can now stringify any property (#35)
77+
* MarkX formatting (#36)
78+
79+
---
80+
81+
Additional release notes in [CHANGELOG](https://github.com/StartAutomating/MarkX/blob/main/CHANGELOG.md)
9182
'@
9283

9384
# Prerelease string of this module

0 commit comments

Comments
 (0)