Skip to content

Commit

Permalink
Fix vertical bar not handled correctly in page titles (logseq#3227)
Browse files Browse the repository at this point in the history
* fix: Vertical bar (|) not handled correctly in page titles

Co-authored-by: leizhe <[email protected]>
  • Loading branch information
llcc and leizhe authored Nov 22, 2021
1 parent 38052b3 commit e654fde
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/main/frontend/util.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,11 @@
(str prefix new-value)))
s)))

(defonce default-escape-chars "[]{}().+*?|")

(defn replace-ignore-case
[s old-value new-value & [escape-chars]]
(let [escape-chars (or escape-chars "[]{}().+*?")
(let [escape-chars (or escape-chars default-escape-chars)
old-value (if (string? escape-chars)
(reduce (fn [acc escape-char]
(string/replace acc escape-char (str "\\" escape-char)))
Expand All @@ -633,7 +635,7 @@

(defn replace-first-ignore-case
[s old-value new-value & [escape-chars]]
(let [escape-chars (or escape-chars "[]{}().+*?")
(let [escape-chars (or escape-chars default-escape-chars)
old-value (if (string? escape-chars)
(reduce (fn [acc escape-char]
(string/replace acc escape-char (str "\\" escape-char)))
Expand Down
2 changes: 1 addition & 1 deletion src/main/frontend/util/page_property.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
v))))
before (remove nil? (map #(build-property-fn %) [:title :alias :aliases]))
other (reduce (fn [acc elem]
(util/replace-ignore-case acc (str elem "\n*") "" "[]{}().+"))
(util/replace-ignore-case acc (str elem "\n*") "" "[]{}().+|"))
content before)]
(string/join "\n" (remove #(= "" %)
(concat before [other]))))))
Expand Down

0 comments on commit e654fde

Please sign in to comment.