question: parsing
Closed this issue · 2 comments
Can I have access to the pagraphs of a parsed md file? I would like to retrive (without rendering) the first paragraph of a file.
Hi Alexandre,
Can I have access to the pagraphs of a parsed md file? I would like to retrive (without rendering) the first paragraph of a file.
Sure. You can have cl-markdown parse something and not render it by using the format argument to markdown
. This will return a document instance. You can get at the paragraphs of a document using the chunks
accessor. chunks
is a cl-container:container so you get at its items using item-at:
(let ((document (markdown "
a b c
d e
1 2 3
4 5" :format :none)))
(item-at (chunks document) 0))
==> #<chunk *nil/0 1 lines line-is-not-empty-p line-is-empty-p>
A chunk has various properties including its lines
(lines *)
==> ("a b c d e ")
HTH,
Gary Warren King, metabang.com
Cell: (413) 559 8738
Fax: (206) 338-4052
gwkkwg on Skype * garethsan on AIM * gwking on twitter
Nice. thank you.