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

enhance: remove blank line for some blocks when outputing to md/org

Related to #2937
Tienson Qin 4 лет назад
Родитель
Сommit
431814f577
3 измененных файлов с 15 добавлено и 6 удалено
  1. 1 1
      package.json
  2. 10 1
      src/main/frontend/modules/file/core.cljs
  3. 4 4
      yarn.lock

+ 1 - 1
package.json

@@ -88,7 +88,7 @@
         "ignore": "^5.1.8",
         "is-svg": "4.2.2",
         "jszip": "^3.5.0",
-        "mldoc": "1.0.7",
+        "mldoc": "1.0.8",
         "path": "^0.12.7",
         "pixi-graph-fork": "^0.1.6",
         "posthog-js": "^1.10.2",

+ 10 - 1
src/main/frontend/modules/file/core.cljs

@@ -14,10 +14,19 @@
   (let [lines (string/split-lines content)]
     (string/join (str "\n" spaces-tabs) lines)))
 
+(defn- allowed-block-as-title?
+  "Allowed to be in the first line of a block (a.k.a block title)"
+  [title body]
+  (and (not (seq title))
+       (contains?
+        #{"Quote" "Table" "Drawer" "Property_Drawer" "Footnote_Definition" "Custom" "Export" "Src" "Example"}
+        (ffirst body))))
+
 (defn transform-content
   [{:block/keys [format pre-block? title content unordered body heading-level left page scheduled deadline parent] :as block} level {:keys [heading-to-list?]}]
   (let [content (or content "")
         heading-with-title? (seq title)
+        allowed-block-as-title? (allowed-block-as-title? title body)
         first-block? (= left page)
         pre-block? (and first-block? pre-block?)
         markdown? (= format :markdown)
@@ -60,7 +69,7 @@
                               markdown-top-heading?
                               ""
 
-                              heading-with-title?
+                              (or heading-with-title? allowed-block-as-title?)
                               " "
 
                               (string/blank? new-content)

+ 4 - 4
yarn.lock

@@ -6382,10 +6382,10 @@ mkdirp@^1.0.3:
   resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
   integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
 
[email protected].7:
-  version "1.0.7"
-  resolved "https://registry.yarnpkg.com/mldoc/-/mldoc-1.0.7.tgz#b2034f29973eb278ac003003149c4b0220fa480e"
-  integrity sha512-XbPTNJpgx/OslszztQshe5T7QUHSuKXG+dqOXaU5R3O3U6sFgpPYBx6CNgmVZqAwxrnhdQQV6IM3E8ETGYzEyA==
[email protected].8:
+  version "1.0.8"
+  resolved "https://registry.yarnpkg.com/mldoc/-/mldoc-1.0.8.tgz#5f66ec8ba89011dcdd8de941c2db0a08ad2295f8"
+  integrity sha512-az1elZi2tJQ/JymyL9USlnRXeN3ggb2ukhReAdPITB2e3QlhXLC4i41d8KJQUb7zCTvssCYV+F3yjQzqeGnzwQ==
   dependencies:
     yargs "^12.0.2"