showdown icon indicating copy to clipboard operation
showdown copied to clipboard

Is there a makeMarkdown function?

Open PanicIsReal opened this issue 9 years ago • 16 comments

I'm trying to make a quote function to quote a forum post, which is in markup, but when clicking the quote button I'd like to the the markup and convert that forum post into Markdown and put it into the textarea, is there such a function?

PanicIsReal avatar Jan 25 '16 06:01 PanicIsReal

No

tivie avatar Jan 25 '16 08:01 tivie

@tivie I have found this gem.But i have no idea why i can not access it.Does showdown support reversed conversion?

smoleniuch avatar May 17 '18 19:05 smoleniuch

@smoleniuch It's a feature we're developing for version 2.0

tivie avatar May 18 '18 12:05 tivie

Is there a timeline on when 2.0 will be released?

I have a PR ready for showdownjs/ng-showdown that adds makeMarkdown directive to the ng-showdown directive, but it simply needs the latest version of showdown.

PS: I'd love to help contribute to showdown, recently introduced it into my own project and really like the library. Let me know if there's any features for 2.0 I can help work on.

mattkwiecien avatar Jul 01 '18 15:07 mattkwiecien

I think I must be missing something – isn't this project described as "a bidirectional MD to HTML to MD converter"?

charlie-s avatar Aug 06 '18 21:08 charlie-s

@charlie-s I did not find any information about bidirectional flow, can you provide a sample??

Anyway the feature would be very useful.

smoleniuch avatar Aug 07 '18 08:08 smoleniuch

@charlie-s The bidirectional is available in master and develop branches and to the soon to be released version 2.0-alpha-1

tivie avatar Sep 14 '18 19:09 tivie

@smoleniuch @Gacnt @charlie-s @mattkwiecien @DougBeney @jdempster @Blaza @matthew-inamdar @jdhankins @circleart @ryantuck

Just pushed the reverse converter to 1.x branch. You can expect a 1.9.0 release with an [EXPERIMENTAL] reverse parser tomorrow.

Donate

As you know, ShowdownJS is a free library and it will remain free forever. However, maintaining and improving the library costs time and money. If you like my work and find the library useful, please donate through Patreon or directly through paypal!! Your contribution will be greatly appreciated and help us continue to develop this awesome library.

tivie avatar Nov 10 '18 02:11 tivie

version 1.9.0 released

tivie avatar Nov 10 '18 23:11 tivie

I understand that the makeMarkdown function has been released, but it does not work in node... window is not defined Is there some way around this?

sojs-coder avatar May 17 '21 16:05 sojs-coder

@sojs-coder @tivie bumping this. Still encountering window is not defined. Any workarounds here?

image

schroeder-g avatar Mar 03 '22 01:03 schroeder-g

Yes. The master build should be compatible with node. Uses a new dependency, JSDOM, to replace the browser's DOM Parser.

tivie avatar Mar 03 '22 12:03 tivie

It doesn't really document how-to on Node, nor does it automatically pick up JSDOM, nor does it give relevant error message (ReferenceError: window is not defined).

For the quick fix, but well, I really wanted to avoid attaching to globalThis...

import { JSDOM } from 'jsdom'

;(globalThis as any).window = new JSDOM('', {}).window

patarapolw avatar Mar 09 '22 10:03 patarapolw

January 2023. "bidirectional" markdown tool still doesn't convert back to markdown, even ChatGPT is confused.

0xd6438c avatar Jan 06 '23 19:01 0xd6438c

This issue still seems to be present in the npm release.

michaelcpuckett avatar Apr 03 '23 13:04 michaelcpuckett

  const bodyMarkdown = converter.makeMarkdown(
          bodyHtml,
          new JSDOM("", {}).window.document,
        );

this works for me with JSDOM and showdown 2.1.0

andrewlu0 avatar Jan 24 '24 19:01 andrewlu0