 ---
 # Hello there
 
-This be ___markdown___.")
+This --- be ___markdown___.")
 
 (def js-content "(function somejs() { console.log('foo'); })();")
 

        (p/markdown)
        (testing "markdown"
          (value-test :path "2017-01-01-test.md"
                      :value-fn #(meta= % :content "<h1><a href=\"#hello-there\" name=\"hello-there\"></a>Hello there</h1>\n<p>This be <strong><em>markdown</em></strong>.</p>")
                      :msg "`markdown` should set `:content` metadata on markdown file"))

        (p/ttr)

          (file-exists? :path "2017-01-01-test.md"
                        :negate? true
                        :msg "`draft` should remove files"))))

(deftesttask with-arguments-test []
  (comp (add-txt-file :path "test.md" :content md-content)
        (boot/with-pre-wrap fileset
          (pm/set-global-meta fileset {:base-url "http://example.com/"
                                       :site-title "Test Title"
                                       :description "Test Desc"}))
        (p/markdown :meta {:markdown-set :metadata} :options {:extensions {:smarts true}})
        (testing "markdown"
          (value-test :path "test.md"
                      :value-fn #(meta= % :content "<h1><a href=\"#hello-there\" name=\"hello-there\"></a>Hello there</h1>\n<p>This &mdash; be <strong><em>markdown</em></strong>.</p>")
                      :msg "`markdown` should set `:content` metadata on markdown file"))

        (p/ttr :filterer :markdown-set)
        (testing "ttr"
          (value-test :path "test.md"
                      :value-fn #(meta= % :ttr 1)
                      :msg "`ttr` should set `:ttr` metadata"))

        (p/word-count :filterer :markdown-set)
        (testing "word-count"
          (value-test :path "test.md"
                      :value-fn #(meta= % :word-count 8)
                      :msg "`word-count` should set `:word-count` metadata"))

        (p/gravatar :source-key :email :target-key :gravatar :filterer :markdown-set)
        (testing "gravatar"
          (value-test :path "test.md"
                      :value-fn
                      #(meta= % :gravatar "http://www.gravatar.com/avatar/a1a361f6c96acb1e31ad4b3bbf7aa444")
                      :msg "`gravatar` should set `:gravatar` metadata"))

        (p/build-date :filterer :markdown-set)
        (testing "build-date"
          (key-test :path "test.md"
                    :key :date-build
                    :msg "`build-date` should set `:date-build` metadata"))

        (p/slug :filterer :markdown-set :slug-fn (fn [filename] (->> (str/split filename #"\.")
                                                                     drop-last
                                                                     str/join
                                                                     str/lower-case)))

        (testing "slug"
          (value-test :path "test.md"
                      :value-fn #(meta= % :slug "test")
                      :msg "`slug` should set `:slug` metadata"))

        (p/permalink :filterer :markdown-set :permalink-fn (fn [_] "/foo.html"))
        (testing "permalink"
          (value-test :path "test.md"
                      :value-fn #(meta= % :permalink "/foo.html")
                      :msg "`permalink` should set `:permalink` metadata"))

        (p/canonical-url :filterer :markdown-set)
        (testing "canonical-url"
          (value-test :path "test.md"
                      :value-fn #(meta= % :canonical-url "http://example.com/foo.html")
                      :msg "`canonical-url` should set `:canonical-url` metadata"))

        (p/sitemap :filterer :markdown-set :filename "test.xml" :out-dir "foo" :url "http://bar.com/")
        (testing "sitemap"
          (file-exists? :path "foo/test.xml"
                        :msg "`sitemap` should write test.xml"))

        (p/rss :filterer :markdown-set
               :filename "test.rss"
               :out-dir "foo"
               :base-url "http://bar.com/"
               :site-title "Test Site"
               :description "Here we go a-testing")
        (testing "rss"
          (file-exists? :path "foo/test.rss"
                        :msg "`rss` should write test.rss"))

        (p/atom-feed :filterer :markdown-set
                     :filename "test-atom.xml"
                     :out-dir "foo"
                     :base-url "http://bar.com/"
                     :site-title "Test Site"
                     :subtitle "Sub-test"
                     :description "Here we go a-testing")
        (testing "atom-feed"
          (file-exists? :path "foo/test-atom.xml"
                        :msg "`atom-feed` should write test-atom.xml"))

        (p/render :renderer 'io.perun-test/render
                  :filterer :markdown-set
                  :out-dir "bar"
                  :meta {:set-by-render true})

        (add-txt-file :path "test.js" :content js-content)
        (add-txt-file :path "baz.html" :content "<body></body>")
        (p/inject-scripts :scripts #{"test.js"} :filter #{#"foo"})
        (p/inject-scripts :scripts #{"test.js"} :remove #{#"baz"})
        (testing "inject-scripts"
          (boot/with-pass-thru fileset
            (is (.contains (slurp (boot/tmp-file (boot/tmp-get fileset "bar/foo.html")))
                           (str "<script>" js-content "</script>"))
                "`inject-scripts` should alter the contents of an included file")
            (is (not (.contains (slurp (boot/tmp-file (boot/tmp-get fileset "baz.html")))
                                (str "<script>" js-content "</script>")))
                "`inject-scripts` should not alter the contents of a removed file")))))
