FIT2102 Programming Paradigms
Overview
Students will create a parser for a subset of the Markdown specification using functional
programming techniques in Haskell.
Demonstrate understanding of functional programming, including documentation of design
decisions.
Exercises (24 marks)
Part A: (12 marks): Parsing Markdown
Parse markdown string into Algebraic Data Type (ADT).
Define own ADT and functions to parse requirements.
ADT should have enough info for HTML conversion.
Add deriving Show to ADT and custom types.
Export markdownParser :: Parser ADT and convertADTHTML :: ADT -> String .
Example scripts:
Run stack test to parse Markdown and save output.
Use npm run dev with stack run main to test in real-time.
Part A - Details
Aside - Text Modifiers (2 marks)
Italic Text: _italics_
Bold Text: **bold**
Strikethrough: ~~strikethrough~~
Link: [link text](URL)
Inline Code: `code`
Footnotes: [^ℤ+] (e.g., [^1] , [^2] )
No whitespace inside [ and ] .
No nested modifiers.
Text inside modifiers can have whitespace (excluding new lines).
Images (0.5 marks)
![Alt Text](URL "Caption Text")
Alt Text, URL, Caption Text don't consider text modifiers.
At least one non-newline whitespace between URL and caption text.
No spaces after ! and before [ .
Footnote References (0.5 marks)
[^2-^]: text (ignore leading whitespace before text).
Free Text (1 mark)
Any text not following other types, may contain modifiers.
Headings (1 mark)
# Heading 1 to ###### Heading 6
Alternative syntax: Heading 1 followed by ====== for level 1, Heading 2 followed by ------
for level 2.
Headings may have modifiers.
Blockquotes (1 mark)
Start with > at the beginning of a line.
Ignore leading whitespace after > and before text.
Text inside can have modifiers.
No nested block quotes.
Code (1 mark)
Starts and ends with three backticks (```), with optional language identifier.
Code block should not consider text modifiers.
Ordered Lists (2 marks)
Starts with number 1, followed by . and at least one whitespace.
Can have sublists with 4 spaces before each item.
Items may contain text modifiers.
Don't handle unordered lists.
Tables (3 marks)
Use pipes | to separate columns and dashes - to separate header and content rows.
Compulsory beginning and ending pipes.
Each row must have the same amount of columns.
Cells may contain text with modifiers, ignore leading and trailing whitespace.
Part B: (6 marks): HTML Conversion
Convert ADT to HTML representation.
Indent HTML with 4 spaces to reflect tree structure.
HTML must be a self-contained webpage with appropriate tags.
Part B - Details
Text Modifiers (1 mark)
Italics: <em>italics</em>
Bold: <strong>bold</strong>
Strikethrough: <del>strikethrough</del>
Link: <a href="URL">link text</a>
Inline Code: <code>code</code>
Footnotes: <sup><a id="fn1ref" href="#fn1">1</a></sup>
Images (0.5 marks)
<img src="URL" alt="Alt Text" title="Caption Text">
Footnote References (0.5 marks)
<p id="fn1">My reference.</p>
咨询 Alpha 小助手,获取更多课业帮助