Nanopass will take as input a sequence of tokens, but really it takes as input an existing abstract syntax tree (ast), in other words a sequence of tokens that are already structured. As far as I know, It can not be used as tokenizer or parser such as building an ast from a sequence of bytes or characters or even strings. Nanopass grammars are high level constructs compared for instance to a yacc / lex grammars. Those will produce an AST. nanopass can consume that ast and produce another ast.
Like I wrote above, nanopass needs a structured input. Think a hierarchical set of tokens. With a markdown abstract syntax tree, you may be able to produce html or even pdf or ps. I guess it will be an interesting project to get started with nanopass. Mind the fact that any markdown syntax tree will map in a almost trivial way to html. For example, the following markdown code:
### Hello *schemer*!
Can be represented with the following ast:
(subsubsubsection "hello " (bold "schemer") "!")
With a search and replace you can produce the following sxml:
(h3 "hello " (b "schemer") "!")
That can itself be translated into html with a few lines of code. To go further down that rabbit hole, one can imagine taking as input the ast of tex document and produce an html page. That would be definitely more involving.
I think it is better to think about nanopass framework as abstract syntax tree transformer. if you prefer a macro transformer. In this regard, nanopass is an improvement over define-macro, syntax-rule or even syntax-case.
Best regards,
Massimiliano Gubinelli
I hope I answered your question.
Do not hesitate to ask more questions :-)
All the best,
Amirouche