Forgot to escape text for RSS, done that now

This commit is contained in:
j4nk 2023-07-11 09:45:51 -04:00
parent 81abca1171
commit 4054cdfdbf
5 changed files with 22 additions and 12 deletions

View File

@ -4,4 +4,4 @@
@@BLOGPOSTDATE 1677804254
# Blog post 1
blog text 1!
[Link to example.com!](https://www.example.com ())
[Link to example.com!](https://www.example.com)

View File

@ -1,21 +1,21 @@
<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>Tue, 11 Jul 2023 09:19:23 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>Tue, 11 Jul 2023 09:45:27 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>
<br>
&lt;br&gt;
<h1>Blog post 2</h1>
&lt;h1&gt;Blog post 2&lt;/h1&gt;
<p>blog text 2 text!</p>
&lt;p&gt;blog text 2 text!&lt;/p&gt;
</description><pubDate>Thu, 02 Mar 2023 19:44:50 EST</pubDate></item><item><title>Blog Post 1</title><link>https://example.com/blog/blogpost1.html</link><guid>https://example.com/blog/blogpost1.html</guid><description>
<br>
&lt;br&gt;
<h1>Blog post 1</h1>
&lt;h1&gt;Blog post 1&lt;/h1&gt;
<p>blog text 1!</p>
&lt;p&gt;blog text 1!&lt;/p&gt;
<p>[Link to example.com!](https://www.example.com ())</p>
&lt;p&gt;&lt;a href=&quot;https://www.example.com&quot;&gt;Link to example.com!&lt;/a&gt;&lt;/p&gt;
</description><pubDate>Thu, 02 Mar 2023 19:44:14 EST</pubDate></item></channel></rss>

View File

@ -13,6 +13,6 @@
<p>blog text 1!</p>
<p>[Link to example.com!](https://www.example.com ())</p>
<p><a href="https://www.example.com">Link to example.com!</a></p>
</body>
</html>

View File

@ -366,6 +366,16 @@
;; End md4tj blog stuff
;; md4tj rss stuff
(defun md4tj-rss-escape-string-for-rss (str)
"Escape STR for RSS."
(replace-regexp-in-string "'" "&apos;"
(replace-regexp-in-string "\"" "&quot;"
(replace-regexp-in-string ">" "&gt;"
(replace-regexp-in-string "<" "&lt;"
(replace-regexp-in-string "&" "&amp;"
(replace-regexp-in-string "'" "&apos;" str)))))))
(defun md4tj-rss-needs-rss ()
"Scans current buffer, returning t if needing rss."
(save-excursion
@ -422,7 +432,7 @@
(md4tj-rss-begin-tag "title") (nth 0 (nth 1 eltfilelist)) (md4tj-rss-end-tag "title")
(md4tj-rss-begin-tag "link") (nth 2 (nth 1 eltfilelist)) (md4tj-rss-end-tag "link")
(md4tj-rss-begin-tag "guid") (nth 2 (nth 1 eltfilelist)) (md4tj-rss-end-tag "guid")
(md4tj-rss-begin-tag "description") (md4tj-parse-to-string (nth 0 eltfilelist)) (md4tj-rss-end-tag "description")
(md4tj-rss-begin-tag "description") (md4tj-rss-escape-string-for-rss (md4tj-parse-to-string (nth 0 eltfilelist))) (md4tj-rss-end-tag "description")
(md4tj-rss-begin-tag "pubDate") (format-time-string "%a, %d %b %Y %H:%M:%S %Z" (string-to-number (nth 1 (nth 1 eltfilelist)))) (md4tj-rss-end-tag "pubDate")
(md4tj-rss-end-tag "item")))

View File

@ -75,7 +75,7 @@ int main() {
<p>This is a div that has monospace text.</p>
</div>
<p id="lastupdated">Last updated: Tue Jul 11 09:19:23 2023</p>
<p id="lastupdated">Last updated: Tue Jul 11 09:45:26 2023</p>
<br>