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

Writing markdown from parsed representation #68

Open
winny- opened this issue Jul 27, 2017 · 1 comment
Open

Writing markdown from parsed representation #68

winny- opened this issue Jul 27, 2017 · 1 comment

Comments

@winny-
Copy link

winny- commented Jul 27, 2017

This might be beyond the scope of this library: is it possible to read in markdown, manipulate it, and write the modified markdown to file? I mainly want to do this to manage a long README.md with a table of contents, and lexically sorted subsections.

@greghendershott
Copy link
Owner

greghendershott commented Jul 27, 2017

I think it's probably out of scope because:

I think it's not too difficult to write an xexpr->markdown function that uses match to recursively walk an x-expression and produce something.

Here's a small example of an xexpr->markdown that emits "lite" markdown (for use in HTML metadata, and intentionally eliminating block elements).


If you wanted to make an xexpr->markdown that emits "full" markdown, and submit it as a PR, I'd consider taking it -- however I'd be nervous:

  1. "Full" markdown likely means many corner cases.

  2. People might expect exact round-tripping -- (check-equal? x (xexpr->markdown (parse-markdown x))) -- for all possible x, but I think that's impossible (or at least not practically worthwhile) to make true. (One simple example: Both _em_ and <em>em</em> are valid markdown and both will parse to (em () "em"). That direction is "lossy".)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants