Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion deps/graph-parser/src/logseq/graph_parser/block.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,12 @@
(get-in properties [:properties :id]))]
;; guard against non-string custom-ids
(when-let [custom-id (and (string? custom-id) (string/trim custom-id))]
(some-> custom-id parse-uuid)))
;; mldoc's Property_Drawer may include trailing content after the
;; id value (e.g. when the block has content on subsequent lines).
;; Take only the first line so parse-uuid can match the UUID.
;; See https://github.com/logseq/og/issues/35
(let [custom-id (-> custom-id (string/split-lines) first string/trim)]
(some-> custom-id parse-uuid))))
(d/squuid)))

(defn get-page-refs-from-properties
Expand Down
11 changes: 10 additions & 1 deletion src/main/frontend/util/property.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,15 @@
(when (string? content)
(let [ast (content/get-ast content format)
title? (content/has-title? content format)
;; Whether the first AST node is a real heading (as opposed to
;; Paragraph/Raw_Html/Hiccup which block-with-title? also matches).
;; Only real headings should have the property inserted after the
;; title line. For Paragraph/Raw_Html/Hiccup (e.g. HTML blocks),
;; the property must go at the very first line so that mldoc can
;; parse it as a Property_Drawer. Otherwise the property ends up on
;; the second line and is never recognized.
;; See https://github.com/logseq/og/issues/35
first-node-heading? (= "Heading" (ffirst (map first ast)))
has-properties? (or (and title?
(or (mldoc/properties? (second ast))
(mldoc/properties? (second
Expand Down Expand Up @@ -304,7 +313,7 @@
has-properties?
(compose-lines)

title?
(and title? first-node-heading?)
(cons (first lines) (cons new-property-s (rest lines)))

:else
Expand Down
Loading