Added blockquote support

This commit is contained in:
j4nk 2024-03-30 21:46:50 -04:00
parent 9ef7c03a15
commit 99eb5c3b2c
5 changed files with 33 additions and 8 deletions

View File

@ -8,7 +8,7 @@ A language and parser written in Emacs Lisp for my custom extension of Markdown,
- [x] Heading
- [x] Bold
- [x] Italic
- [ ] Blockquote
- [x] Blockquote (no nesting)
- [x] Ordered List
- [x] Unordered List
- [x] Code

View File

@ -1,4 +1,4 @@
<rss version="2.0"><channel><title>RSS Test</title><link>http://example.com</link><description>An example blog for testing RSS capability of md4tj.</description><language>en-US</language><pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate><managingEditor>editor@example.com</managingEditor><webMaster>webmaster@example.com</webMaster><docs>https://www.rssboard.org/rss-specification</docs><generator>md4tj-rss.el</generator><lastBuildDate>Sat, 30 Mar 2024 20:57:14 GMT</lastBuildDate><item><title>Blog Post 2</title><link>https://example.com/blog/blogpost2.html</link><guid>https://example.com/blog/blogpost2.html</guid><description>
<rss version="2.0"><channel><title>RSS Test</title><link>http://example.com</link><description>An example blog for testing RSS capability of md4tj.</description><language>en-US</language><pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate><managingEditor>editor@example.com</managingEditor><webMaster>webmaster@example.com</webMaster><docs>https://www.rssboard.org/rss-specification</docs><generator>md4tj-rss.el</generator><lastBuildDate>Sat, 30 Mar 2024 21:40:13 GMT</lastBuildDate><item><title>Blog Post 2</title><link>https://example.com/blog/blogpost2.html</link><guid>https://example.com/blog/blogpost2.html</guid><description>
&lt;br&gt;

View File

@ -19,10 +19,14 @@
(defun md4tj-util-clean-multiline (line)
"Clean LINE of markdown syntax for ul's, ol's and code's."
(replace-regexp-in-string
"^```" ""
"^```" "" ;; eliminate the 3 backticks for start of code
(replace-regexp-in-string
"^[0-9]+\\. " ""
(replace-regexp-in-string "^- " "" line))))
"^[0-9]+\\. " "" ;; eliminate the numbering for ordered lists
(replace-regexp-in-string
"^- " "" ;; eliminate the dashes for unordered lists
(replace-regexp-in-string
"^>" "" ;; eliminate the right-caret for quotes
line)))))
(defun md4tj-util-escape-chars (line)
"Escape characters in LINE that would be misinterpreted by the browser."
@ -164,6 +168,8 @@
((eq state 'endcode) "</code>\n</pre>\n")
((eq state 'begintable) "<table>") ;; might need to add to this?
((eq state 'endtable) "</table>")
((eq state 'beginquote) "<blockquote>")
((eq state 'endquote) "</blockquote>")
(t "")))
(defun md4tj-next-state (currline prevstate)
@ -176,6 +182,7 @@
((and (not (string-match "[0-9]+\\. " currline)) (or (eq prevstate 'beginol) (eq prevstate 'ol))) 'endol)
((and (string-match "```$" currline) (or (eq prevstate 'code) (eq prevstate 'begincode))) 'endcode)
((and (not (string-match "^|.*|$" currline)) (or (eq prevstate 'begintable) (eq prevstate 'headtable) (eq prevstate 'table))) 'endtable)
((and (not (string-match "^>.*" currline)) (or (eq prevstate 'beginquote) (eq prevstate 'quote))) 'endquote)
(t 'nothing))
;; Begin state (or next line's prevstate)
@ -187,6 +194,8 @@
((and (not (string-match "```$" currline)) (or (eq prevstate 'begincode) (eq prevstate 'code)) 'code))
((and (string-match "^|.*|$" currline) (not (or (eq prevstate 'table) (eq prevstate 'begintable)))) 'begintable)
((and (string-match "^|.*|$" currline) (or (eq prevstate 'begintable) (eq prevstate 'table))) 'table)
((and (string-match "^>.*" currline) (not (or (eq prevstate 'quote) (eq prevstate 'beginquote)))) 'beginquote)
((and (string-match "^>.*" currline) (or (eq prevstate 'beginquote) (eq prevstate 'quote))) 'quote)
(t 'normal))))
(defun md4tj-begin ()
@ -205,6 +214,7 @@
((or (eq state 'beginol) (eq state 'ol)) "</ol>")
((or (eq state 'begincode) (eq state 'code)) "</code>")
((or (eq state 'begintable) (eq state 'table)) "</table>")
((or (eq state 'beginquote) (eq state 'quote)) "</blockquote>")
(t ""))
"</body>\n"
"</html>"))

View File

@ -77,7 +77,7 @@ int main() {
<p>This is a div that has monospace text.</p>
</div>
<p id="lastupdated">Last updated: Sun 31 Mar 2024 00:57 UTC</p>
<p id="lastupdated">Last updated: Sun 31 Mar 2024 01:40 UTC</p>
<br>
@ -127,5 +127,15 @@ int main() {
</ul>
</div>
</body>
<br>
<p>Here is a quote:</p>
<blockquote><p> You miss 100%</p>
<p> of the shots</p>
<p> you don't take</p>
</blockquote></body>
</html>

View File

@ -50,4 +50,9 @@ Content after the table
- This is a div that
- tests proper termination of list
- within it
@@ENDDIV
@@ENDDIV
Here is a quote:
> You miss 100%
> of the shots
> you don't take