Closed ghost closed 12 years ago
You can do something like:
(with-temp-buffer
(insert (ob:post-content-html POST))
(let ((html2text-remove-tag-list (loop for tag in html-tag-alist
c-collect-line-comments (car tag))))
(html2text)
(goto-char (point-min))
(loop for x from 0 below 100 do (forward-word))
(buffer-substring-no-properties (point-min) (point))))
Just be sure to (require 'html2text)
and (require 'sgml-mode)
.
OTOH the returned text is just plain text (no HTML formating)
In the last master commits I add ob:get-post-excerpt
function which might do what you want.
It looks great and should do exactly what I want, but it keeps giving me this output: "Lisp error in nil: (void-function ellipsis)".
I did require html2text and sgml-mode, so I am not sure what the problem is.
In the blog_rss template, I replaced the current line to get the post content with " (format "%s" (ob:get-post-excerpt p))".
Not quite there yet. I am getting the following error now: "Lisp error in nil: (error Expected a loop keyword, found c-collect-line-comments)"
Stupid completion :-(
Done now.
Anyway I found that some HTML are not stripped correctly.
Awesome! It is working now.
That is why I don't use automatic auto-completion, preferring triggered hippie + dabbrev.
Note: You are right about the HTML not being fully stripped. This can cause invalid XML. I believe this is a HTML2TEXT problem and not an issue with your code, which is working perfectly, so I will look into it and see what I can come up with.
Yep. Maybe it's time to find a more clever solution.
Can Lisp strip HTML tags and send only a selected number of words to a template, specifically the feed template?