- Use
cdto navigate to the project root - Run
cabal run Haskell-Markdown-HTML - When prompted, type the name of an input Markdown file
- When prompted, type the name of an output HTML file
- The program will output a converted HTML file (If the Markdown filename was invalid then no output file will be made)
Cabal looks for app/Main.hs, which then looks for src/Proj.hs's processMarkdownFile method. You could also just cd to src, run ghci Proj.hs, and then use the markdownToHTML method to convert Markdown in the CLI.
- Use
cdto navigate to the project root - Run
cabal run Haskell-Markdown-HTML-test - All the tests will be ran, and the results will be outputted to the terminal
Cabal looks for test/Main.hs, which then looks for src/Proj.hs's markdownToHTML method.
-
src/Proj.hs - Contains the core logic for parsing Markdown and converting it to HTML:
MarkdownElementdata type for representing different Markdown elements.- Parsers for headers, paragraphs, lists, links, and bold.
markdownToHTMLfunction to convert Markdown to HTML.processMarkdownFilefunction to handle file I/O operations.validateMarkdownto check syntax errors andsuggestFixfor suggestions
-
app/Main.hs - The main application entry point:
- Uses
processMarkdownFilefromProj.hsto read Markdown input, convert it, and write HTML output.
- Uses
-
test/Main.hs - Contains the test suite:
- Uses HUnit for testing the
markdownToHTMLfunction fromProj.hs.
- Uses HUnit for testing the
- src/Proj.hs - Understand the core functionality including parsing and conversion logic.
- app/Main.hs - See how the conversion process is initiated.
- test/Main.hs - Review the test cases to understand expected behaviors.
This project uses:
- Parsec - For parsing Markdown syntax.
- HUnit - For unit testing.
Make sure these libraries are installed or included in your cabal file.