Skip to content

Commit a09ada4

Browse files
committed
final simple features of markdown?
1 parent c2272ed commit a09ada4

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/Parser.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ parseHtmlTags text
518518
-- Handle plain text until a special character
519519
parsePlainText :: Text -> [MDElement]
520520
parsePlainText text =
521-
let (content, rest) = T.break (`elem` ['*', '_', '~', '<']) text
521+
let (content, rest) = T.break (`elem` ['*', '_', '~', '<', '!', '[', '`']) text
522522
in PlainText content : parseInline rest
523523

524524
isCodeBlockStart :: Text -> Bool
@@ -535,11 +535,11 @@ parseCodeBlock _ = (CodeBlock T.empty, [])
535535

536536
parseInlineCode :: Text -> [MDElement]
537537
parseInlineCode text
538-
| T.isPrefixOf (T.pack "``") text =
539-
let (content, rest) = T.breakOn (T.pack "``") (T.drop 2 text)
540-
in if T.isPrefixOf (T.pack "``") rest
541-
then InlineCode (T.strip content) : parseInline (T.drop 2 rest)
542-
else PlainText (T.pack "``") : parseInline (T.drop 2 text)
538+
| T.isPrefixOf (T.pack "```") text =
539+
let (content, rest) = T.breakOn (T.pack "```") (T.drop 3 text)
540+
in if T.isPrefixOf (T.pack "```") rest
541+
then InlineCode (T.strip content) : parseInline (T.drop 3 rest)
542+
else PlainText (T.pack "```") : parseInline (T.drop 2 text)
543543
| T.isPrefixOf (T.pack "`") text =
544544
let (content, rest) = T.breakOn (T.pack "`") (T.drop 1 text)
545545
in if T.isPrefixOf (T.pack "`") rest

test/output.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ <h2 id="9f9a76a951506992fc919b8ae3f5ae15">Заголовок второго ур
203203
src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/48/Markdown-mark.svg/1920px-Markdown-mark.svg.png"
204204
alt="Изображение title="Логотип Markdown"" />
205205
</p>
206-
<p>Функция `print (x)` выводит содержимое переменной ```x```.</p>
206+
<p>
207+
Функция <code>print (x)</code> выводит содержимое переменной <code>x</code>.
208+
</p>
207209
<pre><code>#include &lt;stdio.h&gt;
208210
int main() {
209211
printf(&quot;Hello, World!&quot;);

0 commit comments

Comments
 (0)