Skip to content

Commit adcbe94

Browse files
committed
Fixing issue with escaping quotes in title. Updated README and fixed
blogger2cryogen script to compute correct path for jar.
1 parent a6bbbcd commit adcbe94

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ describes the steps how to do it.
3838
### Importing into Cryogen
3939

4040
Make sure to install
41-
[cryogen-html](https://github.com/sanel/cryogen-html) plugin first,
42-
either in your running Cryogen blog or freshly created. This plugin
43-
will give your blog ability to render HTML posts, without additional
44-
conversion.
41+
[cryogen-html](https://github.com/sanel/cryogen-html) plugin
42+
first; you can install it in your existing Cryogen blog or the fresh
43+
one. This plugin will give your blog ability to render HTML posts
44+
without additional conversion.
4545

4646
Inside `<YOUR-BLOG>/resources/templates` create folder `html` with:
4747

bin/blogger2cryogen

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
#!/bin/sh
2+
# Part of blogger2cryogen project.
3+
# See https://github.com/sanel/blogger2cryogen for more details.
24

3-
java -jar target/blogger2cryogen-*-standalone.jar $@
5+
script=`realpath $0`
6+
script_path="`dirname $script`/../"
7+
8+
java -jar $script_path/target/blogger2cryogen-*-standalone.jar $@

src/blogger2cryogen/core.clj

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
(ns blogger2cryogen.core
1+
(ns
2+
^{:author "Sanel Zukan"
3+
:doc "Utility to migrate Blogger posts to Cryogen static site generator."}
4+
blogger2cryogen.core
25
(:gen-class)
36
(:require [clojure.zip :as zip]
47
[clojure.data.zip.xml :as zx]
@@ -37,6 +40,11 @@
3740
(when-let [^String name (-> s (.split "/") last)]
3841
(first (.split name "\\."))))
3942

43+
(defn- escape-dquotes
44+
"Escape double quotes. Mainly to fix title so we don't get malformed metadata."
45+
[^String s]
46+
(.replaceAll s "\"" "\\\\\""))
47+
4048
(defn- tidy-html
4149
"Pass html string through JTidy for fixing it up if necessary."
4250
[^String s]
@@ -73,7 +81,9 @@
7381
(defn- do-dump
7482
"Actual content creator."
7583
[path title content tags]
76-
(let [header (format "{:title \"%s\"\n :layout :post\n :tags %s\n :toc true}\n\n" title (vec tags))]
84+
(let [header (format "{:title \"%s\"\n :layout :post\n :tags %s\n :toc true}\n\n"
85+
(escape-dquotes title)
86+
(vec tags))]
7787
(spit path (str header content))
7888
(println "Wrote" path)))
7989

@@ -106,15 +116,14 @@
106116
(if-let [i (first nodes)]
107117
(let [zipper (zip/xml-zip i)
108118
term (first (zx/xml-> zipper :category (zx/attr :term)))]
109-
;; only take int accout posts, not comments or other stuff
119+
;; only take into accout posts, not comments or other stuff
110120
(when (post? term)
111121
(let [;; tags are list so we can accept multiple tags
112122
tags (next (zx/xml-> zipper :category (zx/attr :term)))
113123
date (first (zx/xml-> zipper :published zx/text))
114124
link (first (zx/xml-> zipper :link (zx/attr= :rel "alternate") (zx/attr :href)))
115125
content (first (zx/xml-> zipper :content zx/text))
116126
title (first (zx/xml-> zipper :title zx/text))]
117-
118127
(do-dump
119128
(create-filename posts-dir date link)
120129
title

0 commit comments

Comments
 (0)