# HTML to Markdown and rebake

**URL:** https://meta.discourse.org/t/html-to-markdown-and-rebake/131255
**Category:** Support
**Created:** [October 17, 2019, 1:30pm UTC](https://meta.discourse.org/t/html-to-markdown-and-rebake/131255 "2019-10-17T13:30:18Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Mike\_Gehrhardt](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mike_gehrhardt/32/143214_2.png) [@Mike\_Gehrhardt](https://meta.discourse.org/u/Mike_Gehrhardt)
#### Post date: [October 17, 2019, 1:30pm UTC](https://meta.discourse.org/t/html-to-markdown-and-rebake/131255/1 "2019-10-17T13:30:19Z")

</div>

I need your help on a problem. We have a lot of topics stored as HTML in the database (raw\_data) but it’s HTML that is “migrated” from an other system. It was done before we brought the website and would’ve never ever done it this way. What we want to achieve is to convert the HTML-String containing `<div>, <link>, <br />, <span>, <blockquote>,<small> but no <p> and something that is no HTML like [quote][/quote]` into Markdown and than rebake the posts, to get them into discourse style HTML so that they where optimized by discourse (e. g. crawler view). At the moment the plain old HTML content is used (cooked\_method=2) wich leads to many crawling issues and soft404 in Google Search Console.  
We have to do this for about 4-5Mio posts, so it will be very expensive job.

Any ideas?

Best, Mike

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [October 21, 2019, 1:24am UTC](https://meta.discourse.org/t/html-to-markdown-and-rebake/131255/2 "2019-10-21T01:24:49Z")

</div>

We have a built in HTML → Markdown convertor library, it is not perfect but it does the job for the quote function.

You could pass all the posts through that I guess, but what you are describing here, to me, sounds like a large amount of custom work. I would recommend reaching out the the community on #Marketplace and putting a $$$ value on the job.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 21, 2019, 2:10am UTC](https://meta.discourse.org/t/html-to-markdown-and-rebake/131255/3 "2019-10-21T02:10:01Z")

</div>

That’s the kind of thing that I do. You can email [Jay@literatecomputing.com](mailto:Jay@literatecomputing.com).

---

<div class="post-metadata">

### Author: ![louquillio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/louquillio/32/117675_2.png) [@louquillio](https://meta.discourse.org/u/louquillio)
#### Post date: [October 7, 2020, 2:12am UTC](https://meta.discourse.org/t/html-to-markdown-and-rebake/131255/4 "2020-10-07T02:12:23Z")

</div>

> [@sam](#):
>
> We have a built in HTML → Markdown convertor library, it is not perfect but it does the job for the quote function.

Actually, I like your html2markdown parser very much and would like to put it to use outside of Discourse, for my daily work. Any tips on extracting it into a textarea dingus?

There’s no shortage of html2markdown parsers. Heck, [Aaron Swartz wrote one](https://github.com/aaronsw/html2text).

The difference is that I trust yours to do what I want — no more, no less.

Thanks.

LQ
