diff --git a/FDOM.Core/Common.fs b/FDOM.Core/Common.fs index 1217a5e..727ce34 100644 --- a/FDOM.Core/Common.fs +++ b/FDOM.Core/Common.fs @@ -91,6 +91,11 @@ module DOM = and FootnoteBlock = { Name: string Paragraphs: ParagraphBlock } + + and BlockQuoteBlock = + { + Content: BlockContent list + } and BlockContent = | Header of HeaderBlock @@ -100,6 +105,7 @@ module DOM = | Image of ImageBlock | Table of TableBlock | FootNote of FootnoteBlock + | BlockQuote of BlockQuoteBlock member bc.GetRawText() = match bc with @@ -255,7 +261,6 @@ module DOM = let createSpan style text = InlineContent.Span { Style = style; Content = text } - let createLink style text url = InlineContent.Link { Style = style diff --git a/FDOM.Core/Parsing.fs b/FDOM.Core/Parsing.fs index 706a196..17d09ed 100644 --- a/FDOM.Core/Parsing.fs +++ b/FDOM.Core/Parsing.fs @@ -56,6 +56,8 @@ module BlockParser = | Image of Text: string | Table of Text: string | InlineMetadata of Text: string + | Footnote of Text: string + | BlockQuote of Text: string | Empty [] @@ -120,7 +122,7 @@ module BlockParser = let tryParseParagraph (formatter: Line list -> string) (input: Input) curr = match input.TryGetLine curr with | None -> Error() - | Some l when l.Type <> LineType.Text -> Error() + | Some l when l.Type <> LineType.Text && l.Type <> LineType.IndentedText -> Error() | _ -> // This looks for text or indented text because paragraph lines could start with a space. let lines, next = input.TryGetUntilNotTypesOrEnd(curr, [ LineType.Text; LineType.IndentedText ]) @@ -219,6 +221,11 @@ module BlockParser = match input.TryGetLine curr with | None -> Error() | Some l when l.Type <> LineType.Footnote -> Error() + | Some l -> + + + + Ok (BlockToken.Header) let tryParseBlockQuote (input: Input) curr = @@ -264,6 +271,8 @@ module BlockParser = handler ([], 0) +open BlockParser + /// The inline parse takes block tokens and creates a DOM. module InlineParser = @@ -477,7 +486,6 @@ module Processing = (Style.references [ lang |> Option.map (fun l -> $"language-{l}") |> Option.defaultValue "" ]) [ DOM.InlineContent.Text { Content = value } ] - let createImageBlock (value: string) = // Split the image into parts. @@ -505,7 +513,6 @@ module Processing = img Style.none url title altText height width - let createListItem (value: string) = li Style.none (InlineParser.parseInlineContent value) @@ -636,6 +643,8 @@ module Processing = (p Style.none [ DOM.InlineContent.Text { Content = "" } ], remainingBlocks.Tail) | BlockParser.BlockToken.Empty _ -> (p Style.none [ DOM.InlineContent.Text { Content = "" } ], remainingBlocks.Tail) + | BlockToken.Footnote text -> failwith "todo" + | BlockToken.BlockQuote text -> failwith "todo" handler (append processedBlocks newBlock, newRemainingBlocks)