Skip tags in HTML output?
#57
Closed
opened 4 years ago by basus
·
7 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
I'm currently using a
more
tag in my source files to indicate where to break a file for generating excerpts. I'm currently looking through thedoc
for the source file to find themore
tag and break for the excerpt. But I don't want themore
tag showing up in the HTML output. Is there a way to keep themore
tag in thedoc
, but remove it when generating the HTML?There are several ways to do that. The way I did is to call
decode
at theroot
function, which will recursively visit every node in your document tree. You then can match themore
tag.See an example here: https://github.com/sorawee/my-website/blob/master/rkt/decoders.rkt#L50
Thanks for that pointer. But if I call
decode
on aroot
tag that removesmore
tags, they get removed from the file'sdoc
. I originally thought I wanted themore
to stay in thedoc
, but not be there in the HTML output. But now that I think about it, I could generate the summary as part of expanding the source file to itsdoc
, instead of when making the index. That would probably be more efficient anyway.Seems similar to #58 — ?
I recently noticed that it is possible to update
current-metas
from withinpollen.rkt
, which means you can fiddle with themetas
export for the current page in the same way we’re used to fiddling withdoc
. So for things like excerpts one good approach would be to make/update anexcerpt
meta within your tag functions, and remove the extra tags fromdoc
. Then it’s super easy to grab the excerpt when you want it.So this turned out to be pretty easy to do. I realized that I do
(select* 'root doc)
to get the argument to->html
. But that's just a list of tagged X-expressions, so I can just run it through afilter
before passing it to->html
. For the moment I just have a basic predicate function to hand tofilter
:but this could be easily extended to drop other tags, or do more interesting transformations.
All that being said, I agree with @otherjoel that for the purpose of generating an excerpt, I should generate an
excerpt
meta and havedoc
be something that can be converted without processing to HTML.is there a public function used to do this? as far as I see, we'd have to use hash functions directly, right? (and then things might break if the implementation of metas changes)
metas
will remain a hash.