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

Is there a makeMarkdown function? #233

Open
PanicIsReal opened this issue Jan 25, 2016 · 16 comments
Open

Is there a makeMarkdown function? #233

PanicIsReal opened this issue Jan 25, 2016 · 16 comments

Comments

@PanicIsReal
Copy link

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?

@tivie
Copy link
Member

tivie commented Jan 25, 2016

No

@tivie tivie closed this as completed Feb 1, 2016
@smoleniuch
Copy link

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

@tivie
Copy link
Member

tivie commented May 18, 2018

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

@tivie tivie reopened this May 18, 2018
@mattkwiecien
Copy link

mattkwiecien commented Jul 1, 2018

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.

@charlie-s
Copy link

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

@smoleniuch
Copy link

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

Anyway the feature would be very useful.

@tivie
Copy link
Member

tivie commented Sep 14, 2018

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

tivie added a commit that referenced this issue Nov 10, 2018
Showdown now supports a simple HTML to Markdown converter.

**Usage:**

```
var conv = new showdown.Converter();
var md = conv.makeMarkdown('<a href="/url">a link</a>');
```

Closes #388, #233
@tivie
Copy link
Member

tivie commented Nov 10, 2018

@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
Copy link
Member

tivie commented Nov 10, 2018

version 1.9.0 released

@sojs-coder
Copy link

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?

@schroeder-g
Copy link

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

image

@tivie
Copy link
Member

tivie commented Mar 3, 2022

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

@tivie tivie reopened this Mar 3, 2022
@patarapolw
Copy link

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

@0xd6438c
Copy link

0xd6438c commented Jan 6, 2023

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

@michaelcpuckett
Copy link

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

@andrewlu0
Copy link

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

this works for me with JSDOM and showdown 2.1.0

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