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

Feature: resolving HTML - MD - HTML differences - open PR for core or make extensions? #913

Open
TRIAEIOU opened this issue Apr 15, 2022 · 7 comments
Assignees

Comments

@TRIAEIOU
Copy link

TRIAEIOU commented Apr 15, 2022

Hi,

First off, thanks for the excellent work on showdown!

I am using showdown to edit HTML documents in MD, in this use case it would be preferable that the result of cycling through makemarkdown and makehtml would return HTML that resembles (but understandably not identical to) the original, which is not currently the case. I have modified the core source to meet those requirements (a lot of them on the makemarkdown side). My question is how to contribute in a way that is inline with the showdown team's design intent? Would you prefer me opening suggestion PR's for the different changes or opening a PR for implementing event dispatching on the makemarkdown side and then implement the changes in extensions?

Overview of changes:

  • Add option and implementation /^superscript^ "round trip",
  • Add option and implement brInsteadOfP: which outputs <br /> instead of <p></p>.
  • Add option (alt. modify simpleLineBreaks) and implement so that empty lines from the HTML (empty <p></p> or <br>) are not stripped and retained through the cycle (i.e. foo<br><br><br>bar is rendered with 2 empty lines in MD and when parsed back to HTML results in foo<br><br><br>bar
  • Implement HTML->MD underline.
  • Implement headerless tables round trip (handling <table><tbody><tr><td></td></tr></tbody></table> round trip)., credit to Jhuix (https://github.com/jhuix) for some of the code.
  • Fixing incorrect makemarkdown from text not enclosed in tag prior to list/table<table or ul/ol tag>... (current implementation lacks an \n before the table/list in this case).

All of the above could be implemented as extensions if event triggers were implemented on the makemarkdown side at subparser level (including makemarkdown/node.js to add new tags).

What is the team's thoughts?

Again, thanks for the great work!

@TRIAEIOU TRIAEIOU reopened this Apr 15, 2022
@tivie
Copy link
Member

tivie commented Apr 16, 2022

Hey @TRIAEIOU . Thank you!

I agree that, for most parts, makemarkdown and makehtml cycles should produce the same input->output as much as possible.

If you wish to contribute, that would be awesome and really appreciated.

The event system is currently being refactored/implemented (in both makemarkdown and makehtml). Have a look at https://github.com/showdownjs/showdown/tree/event_refactor

I believe it makes sense to implement the event dispatch system on makemarkdown side first and then discuss how to proceed with your suggested changes. Can I contact you through email?

@TRIAEIOU
Copy link
Author

I believe it makes sense to implement the event dispatch system on makemarkdown side first and then discuss how to proceed with your suggested changes. Can I contact you through email?

Of course - I've sent a contact email to your profile email address.

@tivie
Copy link
Member

tivie commented Apr 28, 2022

I haven't received any email @TRIAEIOU

@TRIAEIOU
Copy link
Author

I haven't received any email @TRIAEIOU

Strange, have resent it to the gmail address in your profile, it hasn't found it way to your spam box @tivie?

@TRIAEIOU
Copy link
Author

TRIAEIOU commented May 3, 2022

Ok, I've toyed around a little with event_refactor branch (https://github.com/TRIAEIOU/showdown): and experimentally inserted some event dispatchers on the makemarkdown side and creating listeners for them. Is there any documentation on the design intent around the event system such as categories of intent (.onStart vs .onCapture) event input/output types on the makemarkdown side etc.?

Btw, if you still haven't received any email, could you confirm what your email address is?

@tivie tivie self-assigned this May 8, 2022
@tivie
Copy link
Member

tivie commented May 8, 2022

Yeah. It was in the spam folder.

@irtazahere
Copy link

Hi @tivie Any update on this? I am using showdown to make markdown from html but i am experiencing a weird behaviour when using tag inside an tag.

Code:
converter.makeMarkdown('<em><u>Text</u></em>')

Output:

*<u>Text</u>

*

the extra line being added after <u> tag getting closed is causing the italic effect to go away

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

No branches or pull requests

3 participants