code.doc.parse
code-form
added in 3.0
(code-form nav symbol)converts a form zipper into a code string
(-> (nav/parse-string “(fact (+ 1 1) \n => 2)”) (code-form ’fact)) => “(+ 1 1) \n => 2”
directive-line?
added in 4.1
(directive-line? line)checks if a markdown line is an embedded code.doc directive
fact-caption
added in 3.0
(fact-caption nav)extracts the leading string caption from a fact/facts form, if present
(-> (nav/parse-string “(fact "hello world" (+ 1 1) \n => 2)”) (fact-caption)) => “hello world”
fact-code-string
added in 3.0
(fact-code-string nav symbol)returns the code body of a fact/facts form, stripping the leading caption string if present
(-> (nav/parse-string “(fact "hello world" (+ 1 1) \n => 2)”) (fact-code-string ’fact)) => “(+ 1 1) \n => 2”
(-> (nav/parse-string “(facts (+ 1 1) \n => 2)”) (fact-code-string ’facts)) => “(+ 1 1) \n => 2”
is-code-form
added in 3.0
(is-code-form nav)converts the is form into a string
(is-code-form (nav/parse-string “(is (= (+ 1 1) 2))”)) => “(+ 1 1)\n=> 2”
(is-code-form (nav/parse-string “(is true)”)) => “true”
markdown-code-block
added in 4.1
(markdown-code-block lang lines)creates a markdown fenced code block element
markdown-paragraph
added in 4.1
(markdown-paragraph lines)creates a markdown paragraph element
merge-current
added in 3.0
(merge-current output current)if not whitespace, then merge output
parse-attribute
added in 3.0
(parse-attribute nav)coverts an attribute zipper into an element
(-> (nav/parse-string “{:title "hello world"}”) (parse-attribute)) => {:type :attribute, :title “hello world”}
parse-code
added in 3.0
(parse-code nav)coverts a code zipper into an element
(-> (nav/parse-root “(+ 1 1) (+ 2 2)”) (nav/down) (parse-code)) => {:type :code, :indentation 0, :code “(+ 1 1)”}
parse-code-directive
added in 3.0
(parse-code-directive nav)coverts an code directive zipper into an element
(-> (nav/parse-string “:code {:language :ruby} "1 + 1 == 2"”) (parse-code-directive)) => {:type :block, :indentation 0 :code “1 + 1 == 2” :language :ruby}
parse-comment-form
added in 3.0
(parse-comment-form nav)convert a comment zipper into an element
(-> (nav/parse-string “(comment (+ 1 1) \n => 2)”) (parse-comment-form)) => {:type :block :indentation 2 :code “(+ 1 1) \n => 2”}
parse-deftest-form
added in 3.0
(parse-deftest-form nav)converts the deftest form into an element
(-> (nav/parse-string “(deftest hello)”) (parse-deftest-form)) => {:type :test, :source {:row 1, :col 1, :end-row 1, :end-col 16}}
parse-directive
added in 3.0
(parse-directive nav)converts a directive zipper into an element
(-> (nav/parse-string “:chapter {:title "hello world"}”) (parse-directive)) => {:type :chapter :title “hello world”}
(binding namespace ’example.core (-> (nav/parse-string “:ns {:title "hello world"}”) (parse-directive))) => {:type :ns, :title “hello world”, :ns ’example.core}
parse-fact-form
added in 3.0
(parse-fact-form nav)convert a fact zipper into an element
(-> (nav/parse-string “(fact (+ 1 1) \n => 2)”) (parse-fact-form)) => {:type :test :indentation 2 :code “(+ 1 1) \n => 2”}
(-> (nav/parse-string “(fact "hello world" (+ 1 1) \n => 2)”) (parse-fact-form)) => {:type :test :indentation 2 :caption “hello world” :code “(+ 1 1) \n => 2”}
parse-facts-form
added in 3.0
(parse-facts-form nav)converts a facts zipper into an element
(-> (nav/parse-string “(facts (+ 1 1) \n => 2)”) (parse-facts-form)) => {:type :test :indentation 2 :code “(+ 1 1) \n => 2”}
(-> (nav/parse-string “(facts "hello world" (+ 1 1) \n => 2)”) (parse-facts-form)) => {:type :test :indentation 2 :caption “hello world” :code “(+ 1 1) \n => 2”}
parse-frontmatter
added in 4.1
(parse-frontmatter lines)parses edn frontmatter wrapped by --- markers
parse-inner
added in 3.0
(parse-inner nav f output current opts)parses the inner form of the fact and comment function
parse-is-form
added in 3.0
(parse-is-form nav)converts an is form into an element (-> (nav/parse-string “(is (= (+ 1 1) 2))”) (parse-is-form)) => {:type :block, :indentation 2, :code “(+ 1 1)\n=> 2”}
parse-loop
added in 3.0
(parse-loop nav opts)(parse-loop nav opts current output)the main loop for the parser
(-> (nav/parse-root “(ns example.core) :chapter {:title "hello"} (+ 1 1) (+ 2 2)”) (nav/down) (parse-loop {}))
=> (contains-in [{:type :ns-form, :indentation 0, :ns ’example.core, :code “(ns example.core)”} {:type :chapter, :title “hello”} {:type :code, :indentation 0, :code (contains “(+ 1 1)” “(+ 2 2)” :gaps-ok)}])
parse-markdown
added in 3.0
(parse-markdown content)parses markdown content into code.doc elements
parse-markdown-directive
added in 4.1
(parse-markdown-directive line)parses an embedded directive line inside markdown
parse-ns-form
added in 3.0
(parse-ns-form nav)converts a ns zipper into an element
(-> (nav/parse-string “(ns example.core)”) (parse-ns-form)) => {:type :ns-form :indentation 0 :meta {} :ns ’example.core :code “(ns example.core)”}
parse-paragraph
added in 3.0
(parse-paragraph nav)converts a string zipper into an element
(-> (nav/parse-string “"this is a paragraph"”) (parse-paragraph)) => {:type :paragraph :text “this is a paragraph”}
parse-whitespace
added in 3.0
(parse-whitespace nav)coverts a whitespace zipper into an element
(-> (nav/parse-root “1 2 3”) (nav/down) (nav/right*) (parse-whitespace)) => {:type :whitespace, :code " "}
wrap-line-info
added in 3.0
(wrap-line-info f)helper to add the line information to the parser (used by parse-loop)