Comments (5)
You could parse the contents of the ul
tag function as markdown. See related example.
from pollen-users.
Thanks, that’s a nice idea! Now that I’m thinking about it, I could also run my own small list-parser, to be able to extend it with additional bullet point types. However, what I didn’t understand from the issue you’ve linked, nor from the discussion on the old mailing list, is whether it is possible to use pollen tags inside that kind of environment (and additionaly how to do it).
◊parse-list{
- first item
- second,
◊bold{multiline}
item
- first item
- second,
multiline
item
}
from pollen-users.
The tricky issue is how you transmit the result of a tag function, which is an X-expression, through a block of Markdown, which doesn’t know anything about X-expressions. @otherjoel had a clever idea to convert the X-expression to HTML, which will pass through the Markdown parser intact.
Another idea is to make your bold
tag function behave differently within a parse-list
— it could emit the Markdown-compliant **multiline**
rather than '(strong "multiline")
.
from pollen-users.
The idea with HTML is a good one, thanks.
from pollen-users.
For posterity, here is the original example of reapplying tag functions with eval
:
"test.html.pm"
#lang pollen
Hello _world_!
"pollen.rkt"
#lang racket
(require (only-in markdown parse-markdown)
pollen/decode pollen/tag txexpr/stx
(prefix-in pt: pollen/top))
(provide (all-defined-out))
(define-tag-function (em attrs elems)
`(my-em ,attrs "--Never a dull moment!--" ,@elems))
(define (reapply-tags stx)
(with-syntax ([XEXPR (let loop ([stx stx])
(if (stx-txexpr? stx)
(with-syntax ([TAG (stx-txexpr-tag stx)]
[ATTRS (stx-txexpr-attrs stx)]
[ELEMS (map loop (stx-txexpr-elements stx))])
#'(TAG 'ATTRS . ELEMS))
stx))])
#'(let-syntax ([#%top (make-rename-transformer #'pt:#%top)])
XEXPR)))
(define (root . xs)
(define marked-down (decode-elements xs #:string-proc parse-markdown))
(eval (reapply-tags `(body ,@marked-down))))
What happens here:
-
Here, the source is not a
pollen/markdown
dialect. Rather, the Markdown parsing happens in theroot
function (this is just for the sake of the example — IRL you wouldn’t do it this way — you’d just attachparse-markdown
to certain tags) -
The result of this parse is an X-expression that looks like this:
'(body (p () "Hello " (em () "world") "!"))
-
Then we
reapply-tags
by using this X-expression as a parse tree and passing it througheval
. -
In principle you can do this as many times as you want, thereby extending what would ordinarily be one runtime evaluation into more.
-
There may be a way to do this at compile time too — say, by running
parse-markdown
as part of a macro rather than a tag function, but that may incur other difficulties I’m not considering for now.
from pollen-users.
Related Issues (20)
- render index.ptree with subdirectories changes directory (though not project root) HOT 8
- Is parallel mode known to crash a lot? HOT 1
- decode-elements with decode-paragraphs inserts spurious <p> when nesting lists? HOT 2
- multiple text arguments? HOT 5
- serialising txexprs? HOT 2
- Beautiful Racket Racket docs HOT 1
- Classic tangle/weave support a la org/babel-mode HOT 2
- Add source tag to default block-tags HOT 3
- Importing text from other sources HOT 2
- One source file → multiple outputs of same type? HOT 6
- Having a hard time with maps HOT 4
- Metadata on pagenodes (?) / how to render link traversal HOT 5
- Filling templates multiple times, à la mail-merge -- maybe a non-use case? HOT 3
- Inserting html comment with pollen command HOT 4
- splitf-txexpr: how to use the resulting txexpr HOT 2
- Windows: Set Pollen environment variable HOT 2
- execute shell command via preprocessor?
- Mildy Dynamic Websites
- opinions sought: costs & benefits of switching to self-hosted Git server? HOT 17
- Could not find MANIFEST for package source HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pollen-users.