Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do you have any interest in supporting markdown literary programming? #1

Open
linpengcheng opened this issue Feb 28, 2019 · 3 comments
Labels
enhancement? Possible enhancement

Comments

@linpengcheng
Copy link

Do you have any interest in supporting markdown literary programming?

Markdown Literary programming that don't break the syntax of any programming language

@gpoore
Copy link
Owner

gpoore commented Feb 28, 2019

That looks like an interesting approach to literate programming. I can see how putting the markdown in the comments of code could have some advantages.

Unfortunately, that isn't really a good fit for what I'm trying to do. For now, I'm focusing only on markdown documents that contain executable code, possibly with multiple programming languages in a single document. So supporting markdown literary programming isn't something I can pursue, at least at this point.

@piccolbo
Copy link

piccolbo commented Mar 11, 2019

If I understand @linpengcheng 's request, you may be interested in project pweave. The command pypublish will look for markdown in special comments prefixed by #' and consider anything in between a chunk. Chunk options are provided with #+. The liveness of that project has been questioned, but the main dev seems to address at least bugs. This is for python, for the equivalent in R see https://yihui.name/rlp/. In theory that project supports a long list of languages but I am not sure how much traction it has outside R. I understand @gpoore focus, but the ability to intersperse markdown throughout a project, mixing development and documentation, is very powerful. For instance, I have been able to turn tests into documentation, which means less work and reduced possibility of stale docs. See for instance the examples for project altair_recipes. This is not traditional literate programming in the sense that program output can be included in the output document. Maybe a way to achieve this without broadening this project would be to create a preprocessor that turns a literate program into a markdown file and then push that through codebraid. The easy way is to find all the special comments, remove the prefix and turn everything in between into code chunks. The correct way is to parse the program, find comments and then do the above. The latter unfortunately is language-dependent. Consider the following literate program in python:

#' This is a special *markdown* comment followed bye a code chunk

print*('''
#' This is a special *markdown* comment followed bye a code chunk
)
'''

A compromise could be to disallow the above at least initially, then one could write a trivial parser that is language independent. This based on the languages I know, on top of my mind. If the prefix is configurable (say #' or #% or #%% as used in other languages), this could have some legs, but it's never as clean as parsing.
Another possibility is to program in markdown and then use the tangling operation to turn the markdown into executable code as part of a build operation. I find that option less desirable because of the wealth of tools available for source code (syntax check, error detection etc)

@gpoore
Copy link
Owner

gpoore commented Mar 11, 2019

@piccolbo I hope to add "tangling" support for extracting executable code in the near future. That's on my list of planned features. Like you said, it does have some major limitations. Eventually, I want to add support for other parsers beyond Pandoc, and at that point it might be possible to create something like a plugin system for extracting comments from code. For now, though, I'm sticking with Pandoc Markdown so I can focus on refining the code execution and output processing side of things.

@gpoore gpoore added the enhancement? Possible enhancement label Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement? Possible enhancement
Projects
None yet
Development

No branches or pull requests

3 participants