Stardown-app / Stardown

Copy the web as markdown
Apache License 2.0
28 stars 1 forks source link

Add support for more markdown flavors and markup languages #96

Open wheelercj opened 3 months ago

wheelercj commented 3 months ago

Currently, Stardown focuses mostly on GitHub Flavored Markdown (GFM), but there are many flavors of markdown and many other markup languages.

Examples of markup languages:

wheelercj commented 3 months ago

I'm currently planning on making the default option "markdown", not "GitHub Flavored Markdown (GFM)", because even though GFM is the main flavor of markdown Stardown should support, it may be useful to allow slightly lower quality GFM output for rarely used markdown features in return for significantly higher compatibility with other markdown flavors. Then anyone who knows they only need GFM can change the setting from "markdown" to "GitHub Flavored Markdown (GFM)" to get the high quality GFM output. Also, some of GFM's features depend on its support for many HTML elements, but it will probably be good to have a way to generate pure markdown without any HTML because some tools, like Hugo, allow using markdown but don't allow using HTML by default.

wheelercj commented 3 months ago

To help prioritize which markup languages to add support for, I searched various markup languages on Google Search Trends to get an approximate measure of their popularity. The results are below. For some of them, I used a different search term like "overleaf" instead of "LaTeX" because unrelated topics were heavily affecting the results.

  1. Markdown
  2. LaTeX
  3. Typst
  4. BBCode
  5. Org mode
  6. Rich Text Format (RTF)
  7. DokuWiki
  8. AsciiDoc
  9. Wikitext a.k.a. Wiki markup a.k.a. Mediawiki markup
  10. OpenDocument (ODF)
  11. RDoc
  12. reStructuredText
  13. DocBook
  14. Wolfram Language notebook
  15. Djot

This is only an approximate ordering of their popularity, not necessarily the order in which these might be added to Stardown, and the list is not exhaustive.

On Google Trends, if "markdown" and "overleaf" are compared with any of the others, the others appear as nearly flat lines at around 0% interest. Overleaf hovers at around half the interest of markdown. Due to that, the chances I will put in the work to add full support for markup languages besides markdown, LaTeX, HTML, and JSON without someone else's help are low.

Markdown flavors

I haven't read much about the various markdown flavors yet, but two of the most important ones appear to be GitHub Flavored Markdown (GFM) and Pandoc's Markdown.

More are listed here: Markdown Flavors · commonmark/commonmark-spec Wiki.

wheelercj commented 2 months ago

Currently, Stardown only writes to the clipboard with navigator.clipboard.writeText, not with navigator.clipboard.write. It's unclear to me right now whether Stardown should ever support multiple MIME types.

Here's an interesting blog post on this topic: The web's clipboard, and how it stores data of different types. Related HN discussion: The web's clipboard, and how it stores data of different types | Hacker News.

wheelercj commented 2 months ago

I didn't know until I recently read the CommonMark spec that CommonMark also includes some HTML elements. Stardown currently has two options for the output markup language: "markdown" and "HTML". I think it would be good to have the third option I add be "markdown with some HTML" which keeps as HTML any HTML elements that don't always render well as markdown.

Many markdown editors that render any HTML elements appear to also support some elements not listed in the CommonMark spec, such as sup and sub.