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

Support pretty printing Markdown #419

Open
axieum opened this issue Mar 29, 2020 · 6 comments
Open

Support pretty printing Markdown #419

axieum opened this issue Mar 29, 2020 · 6 comments
Labels
do not close Issue which won't close due to inactivity enhancement New functionality or behavior
Milestone

Comments

@axieum
Copy link

axieum commented Mar 29, 2020

Description
Support pretty printing (beautifying) markdown content.

Example
In my use case, I am using Blade to render a Markdown file, comments in said Blade file render as blank lines (and other issues), and as such results in loosely formatted Markdown.

@colinodell colinodell added the enhancement New functionality or behavior label Mar 29, 2020
@colinodell
Copy link
Member

Being able to beautify Markdown would basically require us to parse the Markdown to an AST and then render it back out to Markdown instead of HTML. (And if we did that, we'd be halfway towards creating an HTML-to-Markdown converter which would replace https://github.com/thephpleague/html-to-markdown - something I would like to eventually do)

Unfortunately, I don't see this as something we'll be implementing in v1 (and not on the current roadmap for v2), but I do like this idea so I'll keep this open for now :)

Thanks for the suggestion!

@colinodell colinodell added the do not close Issue which won't close due to inactivity label Mar 29, 2020
@colinodell colinodell added this to the v3.0 milestone Sep 20, 2020
@ss-gxp
Copy link

ss-gxp commented Oct 13, 2020

I need to translate md documents via a translation API.
It would be great to translate the text nodes and rebuild the document with a markdown renderer.

@markhalliwell
Copy link
Contributor

I need to translate md documents via a translation API.
It would be great to translate the text nodes and rebuild the document with a markdown renderer.

You can, theoretically, already do this by listening for a DocumentParsedEvent event and then walking over the document and looking for Text nodes.

This issue is more about rendering the AST (after its been parsed) back into CommonMark.

@ss-gxp
Copy link

ss-gxp commented Oct 13, 2020

Yes, I'm talking about AST. The task of automatically changing the markdown document (translation into another language, in my case, but not limited to it) is solved by parsing into AST tree, then processing the nodes in some way, and rendering back to the markdown.

I just wanted to further emphasize the importance of this issue. Because adds flexibility to the library and uses are limited only by imagination. I apologize if I was initially incomprehensible.

@colinodell
Copy link
Member

I've successfully created a very basic proof-of-concept (with minimal changes to the existing parsing/rendering logic) that converts Markdown -> AST -> Markdown with ~98% accuracy in my limited tests. There are some bugs though, and plenty of edge cases I haven't even attempted to explore yet, but my approach seems promising. If all goes well I might be able to bundle this in with #511 and #431 since they have similar implementation requirements.

Don't hold your breath yet, as I don't have enough confidence to determine whether this can drop in 2.0 or needs to wait for 3.0, but we'll see what happens 🤞

@colinodell colinodell modified the milestones: v3.0, v2.1 Sep 12, 2021
@colinodell colinodell modified the milestones: v2.1, v2.2 Dec 5, 2021
@colinodell colinodell modified the milestones: v2.2, v2.3 Jan 22, 2022
@colinodell colinodell modified the milestones: v2.3, v2.4 Apr 7, 2022
@weph
Copy link

weph commented Feb 11, 2023

Is there anything I can do to help you with this one? @colinodell

@colinodell colinodell modified the milestones: v2.4, v3.0 Feb 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not close Issue which won't close due to inactivity enhancement New functionality or behavior
Projects
None yet
Development

No branches or pull requests

5 participants