Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Escape parentheses in href before parsing cliki markup

  • Loading branch information...
commit 874ac09c0722adc60de6777e09f6f033e328d4ed 1 parent 83ca395
@vsedach authored
Showing with 13 additions and 1 deletion.
  1. +13 −1 src/markup.lisp
View
14 src/markup.lisp
@@ -36,10 +36,22 @@
(defun generate-html-from-markup (markup)
#H[<div id="article">]
- (princ (parse-cliki-markup (sanitize:clean markup +cliki-tags+))
+ (princ (parse-cliki-markup
+ (escape-parens-in-href-links
+ (sanitize:clean markup +cliki-tags+)))
*html-stream*)
#H[</div>])
+(defun escape-parens-in-href-links (markup)
+ (ppcre:regex-replace-all
+ #?/(href|HREF)="(.*?)"/
+ markup
+ (lambda (match href url)
+ (declare (ignore match href))
+ (format nil "href=\"~A\""
+ (cl-ppcre:regex-replace-all "\\(|\\)" url #'uri-encode :simple-calls t)))
+ :simple-calls t))
+
(defun parse-cliki-markup (markup)
(loop for prefix in '("_" "_H" "\\*" "\\/" "_P")
for formatter in '(pprint-article-link format-hyperspec-link pprint-category-link format-category-list format-package-link)
Please sign in to comment.
Something went wrong with that request. Please try again.