emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/markdown-mode 054ff99a4d 1/7: Escape minimal set of charac


From: ELPA Syncer
Subject: [nongnu] elpa/markdown-mode 054ff99a4d 1/7: Escape minimal set of characters in title
Date: Tue, 11 Apr 2023 22:01:44 -0400 (EDT)

branch: elpa/markdown-mode
commit 054ff99a4d0d2339c1474324c539ea753e5e5acf
Author: Mark A. Hershberger <mah@nichework.com>
Commit: Shohei YOSHIDA <syohex@gmail.com>

    Escape minimal set of characters in title
    
    Fixes cfclrk/markdown-xwidget#9
---
 markdown-mode.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/markdown-mode.el b/markdown-mode.el
index 6bdf03abb2..77fb02a036 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -7445,6 +7445,12 @@ Standalone XHTML output is identified by an occurrence of
               stylesheet-path)
           "\"  />"))
 
+(defun markdown-escape-title (title)
+  "Escape a minimum set of characters in TITLE so they don't clash with html."
+  (string-replace ">" "&gt;"
+    (string-replace "<" "&lt;"
+      (string-replace "&" "&amp;" title))))
+
 (defun markdown-add-xhtml-header-and-footer (title)
   "Wrap XHTML header and footer with given TITLE around current buffer."
   (goto-char (point-min))
@@ -7453,7 +7459,7 @@ Standalone XHTML output is identified by an occurrence of
           "\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\";>\n\n"
           "<html xmlns=\"http://www.w3.org/1999/xhtml\";>\n\n"
           "<head>\n<title>")
-  (insert title)
+  (insert (markdown-escape-title title))
   (insert "</title>\n")
   (unless (= (length markdown-content-type) 0)
     (insert



reply via email to

[Prev in Thread] Current Thread [Next in Thread]