-
Notifications
You must be signed in to change notification settings - Fork 0
/
PostProcessing.fs
42 lines (34 loc) · 1.25 KB
/
PostProcessing.fs
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
namespace MarkdownWithFs
open Markdown
module PostProcessing =
let (|SpanNode|_|) span =
match span with
| Strong spans | Emphasis spans | HyperLink (spans, _) ->
Some(box span, spans)
| _ -> None
let SpanNode (span:obj, children) =
match unbox span with
| Strong _ -> Strong children
| Emphasis _ -> Emphasis children
| HyperLink (_, url) -> HyperLink(children, url)
| _ -> invalidArg "" "Incorrect MarkdownSpan"
let (|BlockNode|_|) block =
match block with
| Heading(_, spans) | Paragraph(spans) ->
Some(box block, spans)
| _ -> None
let BlockNode (block:obj, children) =
match unbox block with
| Heading(size, _) -> Heading(size, children)
| Paragraph _ -> Paragraph children
| _ -> invalidArg "" "Incorrect MarkdownBlock"
let (|BlockQuoteNode|_|) blockquote =
match blockquote with
| BlockQuote md ->
Some(box blockquote, md)
| _ -> None
let BlockQuoteNode (blockquote:obj, children) =
match unbox blockquote with
| BlockQuote _ ->
BlockQuote children
| _ -> invalidArg "" "Incorrect BlockQuote block"