Skip to content

Conversation

@Lunanuuu
Copy link

@Lunanuuu Lunanuuu commented Jul 30, 2024

Description

Add the convertHtmlToMarkdown function to convert HTML content into Markdown format to increase the quality of the Discord Webhook feature.

  1. Anchor Tags (<a>): Converts links to Markdown links

    • Example: <a href="https://www.example.com">Example</a> becomes [Example](https://www.example.com)
  2. Headings (<h1> to <h6>): Converts HTML headings to Markdown headings, with a maximum of three # characters

    • Example: <h1>Title</h1> becomes # Title
  3. Unordered Lists (<ul> and <li>): Converts unorderd lists to Markdown lists with dashes

    • Example: <ul><li>Item 1</li><li>Item 2</li></ul> becomes - Item 1 - Item 2
  4. Ordered Lists (<ol> and <li>): Converts ordered lists to numbered Markdown lists

    • Example: <ol><li>First item</li><li>Second item</li></ol> becomes 1. First item 2. Second item
  5. Bold Text (<strong>): Converts bold/strong text to markdown bold text

    • Example: <strong>bold</strong> becomes **bold**
  6. Italic Text (<i>): Converts italic text to Markdown italic text

    • Example: <i>italic</i> becomes *italic*
  7. Blockquotes (<blockquote>): Converts blockquotes to Markdown blockquotes

    • Example: <blockquote>text</blockquote> becomes > text
  8. Code (<code>): Converts code tags to Markdown code

    • Example: <code>code</code> becomes `code`
  9. Horizontal Rules (<hr>): Converts horizontal rules to Markdown horizontal rules

    • Example: <hr> becomes --- (Discord does not yet support horizontal rules, but I think it's likely that they will be added in the future)

Screenshots of my tests:
Screenshot 1
Screenshot 2
Screenshot 4
Screenshot 3

Lunanuuu added 2 commits July 30, 2024 14:09
### Description

Add the `convertHtmlToMarkdown` function to convert HTML content into Markdown format to increase the quality of the Discord Webhook feature.

1. **Anchor Tags (`<a>`)**: Converts links to Markdown links
   - Example: `<a href="https://www.example.com">Example</a>` becomes `[Example](https://www.example.com)`

2. **Headings (`<h1>` to `<h6>`)**: Converts HTML headings to Markdown headings, with a maximum of three `#` characters
   - Example: `<h1>Title</h1>` becomes `# Title`

3. **Unordered Lists (`<ul>` and `<li>`)**: Converts unorderd lists to Markdown lists with dashes
   - Example: 
     ```html
     <ul>
       <li>Item 1</li>
       <li>Item 2</li>
     </ul>
     ```
     becomes
     ```
     - Item 1
     - Item 2
     ```

4. **Ordered Lists (`<ol>` and `<li>`)**: Converts ordered lists to numbered Markdown lists
   - Example:
     ```html
     <ol>
       <li>First item</li>
       <li>Second item</li>
     </ol>
     ```
     becomes
     ```
     1. First item
     2. Second item
     ```

5. **Bold Text (`<strong>`)**: Converts bold/strong text to markdown bold text
   - Example: `<strong>bold</strong>` becomes `**bold**`

6. **Italic Text (`<i>`)**: Converts italic text to Markdown italic text
   - Example: `<i>italic</i>` becomes `*italic*`

7. **Blockquotes (`<blockquote>`)**: Converts blockquotes to Markdown blockquotes
   - Example: `<blockquote>text</blockquote>` becomes `> text`

8. **Code (`<code>`)**: Converts code tags to Markdown code
   - Example: `<code>code</code>` becomes `` `code` ``

9. **Horizontal Rules (`<hr>`)**: Converts horizontal rules to Markdown horizontal rules
   - Example: `<hr>` becomes `---` (Discord does not yet support horizontal rules, but I think it's likely that they will be added in the future)

Screenshots of my tests:
![Screenshot 1](https://www.skydinse.net/storage/img/changelog-plugin-update-1.png)
![Screenshot 2](https://www.skydinse.net/storage/img/changelog-plugin-update-2.png)
![Screenshot 3](https://www.skydinse.net/storage/img/changelog-plugin-update-3.png)
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

Successfully merging this pull request may close these issues.

1 participant