Back

escape-html (clj)

(source)

function

(escape-html text)
Change special characters into HTML character entities.

Examples

hiccup
(ns hiccup.util_test
  (:require [clojure.test :refer :all]
            [hiccup.util :refer :all])
  (:import java.net.URI))

(deftest test-escaped-chars
  (is (= (escape-html "\"") """))
  (is (= (escape-html "<") "&lt;"))
  (is (= (escape-html ">") "&gt;"))
  (is (= (escape-html "&") "&amp;"))
  (is (= (escape-html "foo") "foo"))
  (is (= (escape-html "'") "&apos;"))
  (is (= (binding [*html-mode* :sgml] (escape-html "'")) "&#39;")))
weavejester/hiccup
(ns hiccup.core
  "Library for rendering a tree of vectors into a string of HTML.
  Pre-compiles where possible for performance."
  {:deprecated "2.0"}
  (:require [hiccup2.core :as hiccup2]
            [hiccup.util :as util]))

(def ^{:deprecated 2.0} h
  "Escape strings within the [[html]] macro."
  util/escape-html)
weavejester/hiccup
(ns hiccup.util_test
  (:require [clojure.test :refer :all]
            [hiccup.util :refer :all])
  (:import java.net.URI))

(deftest test-escaped-chars
  (is (= (escape-html "\"") "&quot;"))
  (is (= (escape-html "<") "&lt;"))
  (is (= (escape-html ">") "&gt;"))
  (is (= (escape-html "&") "&amp;"))
  (is (= (escape-html "foo") "foo"))
  (is (= (escape-html "'") "&apos;"))
  (is (= (binding [*html-mode* :sgml] (escape-html "'")) "&#39;")))
hatemogi/hangul-coding.org
(ns 한글코딩.뷰
  (:use [미생.기본]
        [hiccup.core]
        [hiccup.page])
  (:require [hiccup.util :refer [escape-html]]
            [clojure.string :as s]
            [ring.util.response :as 응답]))

(함수 마크다운 [파일명]
  [:div.마크다운 {:data-markdown true :data-option "신뢰"}
   (-> (str "resources/public" 파일명) slurp escape-html)])