import Foundation import HelderCore import Testing @Suite struct MarkdownSpeechTests { private func speech(_ markdown: String) -> String { MarkdownSpeech.plainText(MarkdownParser.parse(markdown)) } @Test func eachBlockIsItsOwnSentence() { #expect(speech("# Title\n\nFirst paragraph\n\nSecond one!") == "Title.\nFirst paragraph.\nSecond one!") } @Test func inlineMarkupIsStrippedAndLinksKeepTheirText() { #expect(speech("Some **bold**, *soft*, ~~old~~ and `code` in [the docs](https://x.com).") == "Some bold, soft, old and code in the docs.") } @Test func listItemsQuotesAndTableRowsAreRead() { #expect(speech("- one\n- two:\n\n> quoted") == "one.\ntwo:\nquoted.") #expect(speech("| Name | Role |\n|---|---|\n| Ann | dev |") == "Name, Role.\nAnn, dev.") } @Test func codeBlocksAndRulesAreSkipped() { #expect(speech("Before\n\n```php\necho 1;\n```\n\n---\n\nAfter") == "Before.\nAfter.") #expect(speech("```\nonly code\n```").isEmpty) } @Test func aDollarSignIsSpokenAsDollar() { #expect(MarkdownSpeech.spoken("echo $user") == "echo dollar user") #expect(MarkdownSpeech.spoken("$ x") == "dollar x") #expect(MarkdownSpeech.spoken("a$$") == "a dollar dollar") } @Test func aDollarBeforeADigitAndTextWithoutDollarStay() { #expect(MarkdownSpeech.spoken("It costs $5.") == "It costs $5.") #expect(MarkdownSpeech.spoken("No money here.") == "No money here.") } }