Просмотр исходного кода

Add two editable org built-in properties

Also ported old filetags property tests from b991599244be141ec4a6943d8b940ac3945e2b0c.
Gabriel Horner 3 лет назад
Родитель
Сommit
42b7f5d189

+ 3 - 1
deps/graph-parser/src/logseq/graph_parser/property.cljs

@@ -33,7 +33,9 @@
 (defn editable-built-in-properties
   "Properties used by logseq that user can edit"
   []
-  (into #{:title :icon :template :template-including-parent :public :filters :exclude-from-graph-view}
+  (into #{:title :icon :template :template-including-parent :public :filters :exclude-from-graph-view
+          ;; org-mode only
+          :macro :filetags}
         editable-linkable-built-in-properties))
 
 (defn hidden-built-in-properties

+ 23 - 1
deps/graph-parser/test/logseq/graph_parser/mldoc_test.cljs

@@ -67,7 +67,7 @@
 " md-config {})))
       "Src example with leading whitespace"))
 
-(deftest properties-test
+(deftest md-properties-test
   (are [x y] (= [["Properties" y] nil]
                 (first (gp-mldoc/->edn x md-config {})))
 
@@ -98,6 +98,28 @@
          (first (gp-mldoc/->edn "term
 : definition" md-config {})))))
 
+(defn- parse-properties
+  [text]
+  (->> (gp-mldoc/->edn text (gp-mldoc/default-config :org) {})
+       (filter #(= "Properties" (ffirst %)))
+       ffirst
+       second))
+
+(deftest org-properties-test
+  []
+  (testing "just title"
+    (let [content "#+TITLE:   some title   "
+          props (parse-properties content)]
+      (is (= "some title   " (:title props)))))
+
+  (testing "filetags"
+    (let [content "#+FILETAGS:   :tag1:tag2:@tag:
+#+TAGS: tag3
+body"
+          props (parse-properties content)]
+      (is ["@tag" "tag1" "tag2"] (sort (:filetags props)))
+      (is ["@tag" "tag1" "tag2" "tag3"] (sort (:tags props))))))
+
 (deftest ^:integration test->edn
   (let [graph-dir "test/docs"
         _ (docs-graph-helper/clone-docs-repo-if-not-exists graph-dir)