cdaringe / markdown_player

Executable markdown files. Documentation & demonstrations, all in one!
4 stars 0 forks source link

Playing Markdown to include dynamic content such as SQL tables #3

Open shah opened 3 years ago

shah commented 3 years ago

@cdaringe I was curious if markdown_player might support this feature and I'm missing it:

For example: my-markdown.md

# My markdown heading

Introductory text for my document.

## A second heading

Some more text

## The SQL output I care about heading

<!--
'''sql {cmd: psql, args: ["--c", $ARG], capture: "query1"}
select * from table
'''
-->

<!-- { capturedOutput: 'query1', position: 'start' } -->
NOTE to Christopher: somehow I'd like to mark that my output from the above command is itself Markdown 
and should be "included" here from the first SQL. If we can "capture" the output as arbitrary Markdown and 
include it that would be great since I can take SQL output and turn it into a table or anything else. 
When "played" markdown_player would replace everything between start/end of captured output for each 
run but leave the rest of the markdown content as-is.
<!-- { capturedOutput: 'query1', position: 'end' } -->

Some more markdown text.

<!--
'''sql {cmd: psql, args: ["--c", $ARG], capture: "query2"}
select * from another_table
'''
-->

<!-- { capturedOutput: 'query2', position: 'start' } -->
NOTE to Christopher: somehow I'd like to mark that my output from the above command is itself Markdown
and should be "included" here from the second SQL.
<!-- { capturedOutput: 'query2', position: 'end' } -->

Some more markdown text.

Thoughts? :-)

cdaringe commented 3 years ago

greetings!

so, were such a feature to be added:

seems like a useful feature. minimally, defining the language type for the output markdown seems very valuable, and that is currently lacking. perhaps an output: ... field on the input markdown's codefence would be where you/we could experiment w/ such an api?

cdaringe commented 3 years ago

fwiw, i have intent to use this against postgres as well :) i wrote a very mediocre article some time ago that i still present periodically to peers (https://cdaringe.com/protect-bacon-with-rls) where i advocate for DB reflecting APIs with security all at the data layer. i had this lib in mind recently when brushing up on that content. so, i want this feature too :)

shah commented 3 years ago

Got it @cdaringe I'll take a peek to see if I can propose some changes via PRs. Meanwhile, you and I agree on the database being a proper computing platform. Check out my code on that subject here: https://github.com/netspective-studios/pgdcp :-)