showdown icon indicating copy to clipboard operation
showdown copied to clipboard

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

Open TRIAEIOU opened this issue 2 years ago • 7 comments

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 avatar Apr 15 '22 18:04 TRIAEIOU

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?

tivie avatar Apr 16 '22 14:04 tivie

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.

TRIAEIOU avatar Apr 16 '22 19:04 TRIAEIOU

I haven't received any email @TRIAEIOU

tivie avatar Apr 28 '22 07:04 tivie

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 avatar Apr 28 '22 13:04 TRIAEIOU

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?

TRIAEIOU avatar May 03 '22 14:05 TRIAEIOU

Yeah. It was in the spam folder.

tivie avatar May 08 '22 01:05 tivie

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

irtazahere avatar Dec 07 '22 08:12 irtazahere