diff --git a/README.md b/README.md index 95e8c92..98aa0aa 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,8 @@ Any custom map provided will the merged to following the default map used by the :list {:ol {:numbered true} :ul {:symbol "• "}} :paragraph {} + :quote {:style :italic + :color [64 64 64]} :spacer {:allow-extra-line-breaks? true :single-value 0 :extra-starting-value 0} @@ -69,6 +71,7 @@ Any custom map provided will the merged to following the default map used by the - [line](#line) - [list](#list) - [paragraph](#paragraph) +- [quote](#quote) - [spacer](#spacer) #### anchor @@ -201,6 +204,15 @@ is equivalent to "doc.pdf") ``` +#### quote +```clojure +user=> (markdown->clj-pdf {} "> This is a blockquote") +[:paragraph {:style :italic :color [64 64 64]} "This is a blockquote"] + +user=> (markdown->clj-pdf {:quote {:style :bold :indent 20} "> Quote with custom styling") +[:paragraph {:style :bold :indent 20 :color [64 64 64]} "Quote with custom styling"] +``` + #### spacer ```clojure diff --git a/project.clj b/project.clj index 74cb786..3540d0a 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject clj-pdf-markdown "0.2.1" +(defproject clj-pdf-markdown "0.2.2-SNAPSHOT" :description "Library for rendering markdown to clj-pdf data-structure syntax." :url "https://github.com/leontalbot/clj-pdf-markdown" :license {:name "Eclipse Public License" diff --git a/src/clj_pdf_markdown/core.clj b/src/clj_pdf_markdown/core.clj index fc59cd1..bd3ba9a 100644 --- a/src/clj_pdf_markdown/core.clj +++ b/src/clj_pdf_markdown/core.clj @@ -21,6 +21,8 @@ :list {:ol {:numbered true} :ul {:symbol "• "}} :paragraph {} + :quote {:style :italic + :color [64 64 64]} :spacer {:allow-extra-line-breaks? true :single-value 0 :extra-starting-value 0} @@ -170,7 +172,7 @@ (def render-derivals {:LineBreak [:HardLineBreak :SoftLineBreak] - :Literal [:BlockQuote :FencedCodeBlock :IndentedCodeBlock :Code]}) + :Literal [:FencedCodeBlock :IndentedCodeBlock :Code]}) (defn make-hierarchy-from-derivals [derivals] (reduce (fn [hier [child parent]] (derive hier child parent)) @@ -261,6 +263,11 @@ (defmethod render :HtmlInline [pdf-config node] (->> node .getLiteral (html-tag->clj-pdf pdf-config))) +(defmethod render :BlockQuote [pdf-config node] + (->> node + (render-children* pdf-config) + (into [:paragraph (:quote pdf-config)]))) + (defmethod render :Literal [pdf-config node] (.getLiteral node)) diff --git a/test/clj_pdf_markdown/core_test.clj b/test/clj_pdf_markdown/core_test.clj index ac265f7..95bbee4 100644 --- a/test/clj_pdf_markdown/core_test.clj +++ b/test/clj_pdf_markdown/core_test.clj @@ -93,6 +93,19 @@ (is (= [[:paragraph {} "This is simple text"]] (markdown->clj-pdf {:wrap {:unwrap-singleton? false}} "This is simple text")))) + (testing "blockquote" + (is (= [:paragraph {:style :italic :color [64 64 64]} "This is a quote"] + (markdown->clj-pdf {} "> This is a quote"))) + + (is (= [:paragraph {:style :bold :color [64 64 64]} "Styled quote"] + (markdown->clj-pdf {:quote {:style :bold}} "> Styled quote"))) + + (is (= [:paragraph {:style :italic, :color [64 64 64]} + [:paragraph {} "This is a quote" [:spacer 0] + "with multiple lines" [:spacer 0] + [:phrase {:style :italic} "and markup!"]]] + (markdown->clj-pdf {} "> This is a quote\n> with multiple lines\n> *and markup!*")))) + (testing "spacer" (is (= [:paragraph {} "This is" [:spacer 0] "a spacer."] (markdown->clj-pdf {} "This is\na spacer.")))