diff --git a/deps/graph-parser/src/logseq/graph_parser/block.cljs b/deps/graph-parser/src/logseq/graph_parser/block.cljs index 3acd5b3a3b..1ed122bfa8 100644 --- a/deps/graph-parser/src/logseq/graph_parser/block.cljs +++ b/deps/graph-parser/src/logseq/graph_parser/block.cljs @@ -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 diff --git a/src/main/frontend/util/property.cljs b/src/main/frontend/util/property.cljs index e6d80da35f..46b8663e9a 100644 --- a/src/main/frontend/util/property.cljs +++ b/src/main/frontend/util/property.cljs @@ -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 @@ -304,7 +313,7 @@ has-properties? (compose-lines) - title? + (and title? first-node-heading?) (cons (first lines) (cons new-property-s (rest lines))) :else