Skip to content

Commit

Permalink
fix slide properties
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Mar 5, 2015
1 parent d8d9c01 commit 8508c31
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 6 deletions.
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### 0.6.1 - 05.03.2015
### 0.6.2 - 05.03.2015
* Fix slide properties

### 0.6.0 - 05.03.2015
Expand Down
19 changes: 14 additions & 5 deletions src/FsReveal/Markdown.fs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,20 @@ let getPresentation (doc : LiterateDocument) =
match slide.SlideData with
| Simple(paragraphs) -> wrappedInSection slide.Properties paragraphs
| Nested(listOfParagraphs) ->
let x =
listOfParagraphs
|> List.collect (wrappedInSection slide.Properties)
x
//|> wrappedInSection slide.Properties
let inner =
[for paragraphs in listOfParagraphs ->
[for p in paragraphs do
match p with
| HorizontalRule('-') ->
let attributes = properties |> Seq.map (fun kv -> sprintf "%s=\"%s\"" kv.Key kv.Value)
yield InlineBlock("</section>")
yield InlineBlock(sprintf "<section %s>" (String.Join(" ", attributes)))
| _ -> yield p
]]

inner
|> List.collect (wrappedInSection slide.Properties)


let extractSlide paragraphs =
// sub-section is separated by ---
Expand Down
46 changes: 46 additions & 0 deletions tests/FsReveal.Tests/SectionsSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,49 @@ let ``can generate sections from markdown without properties``() =
match slide.SlideData with
| SlideData.Nested x -> ()
| _ -> failwith "subslides not parsed"

let normalizeLineBreaks (text:string) = text.Replace("\r\n","\n").Replace("\n","\n")


let testTemplate ="{slides}"


let expectedOutput = """<section >
<h3>Slide 1</h3>
</section>
<section >
<h3>Slide 2</h3>
</section>
<section author="Karlkim Suwanmongkol" description="Introduction to FsReveal" theme="Night" title="FsReveal" transition="default">
<h4>Slide 2.1</h4>
</section>
<section author="Karlkim Suwanmongkol" description="Introduction to FsReveal" theme="Night" title="FsReveal" transition="default">
<h4>Sldie 2.2</h4>
</section>
<section >
<h3>Slide 3</h3>
</section>
"""

[<Test>]
let ``can generate html sections from markdown``() =
let presentation = FsReveal.GetPresentationFromMarkdown md
Formatting.GenerateHTML testTemplate presentation
|> normalizeLineBreaks
|> shouldEqual (normalizeLineBreaks expectedOutput)

0 comments on commit 8508c31

Please sign in to comment.