Stardown-app / Stardown

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

Add support for more markdown flavors and markup languages #96

Open wheelercj opened 1 month ago

wheelercj commented 1 month 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 1 month 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 1 month 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. BBCode
  4. Org mode
  5. Rich Text Format (RTF)
  6. DokuWiki
  7. AsciiDoc
  8. Wikitext a.k.a. Wiki markup a.k.a. Mediawiki markup
  9. OpenDocument (ODF)
  10. reStructuredText
  11. RDoc
  12. DocBook

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.

What if there was a PDF option? Users could then select part of a web page and press Alt+C to immediately download a PDF of what they selected. Maybe when nothing is selected, pressing Alt+C would make a PDF of the entire page, but then the end result might be the same as browsers' existing feature to print pages as PDFs unless Stardown converts the content in a different way.

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 weeks 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 1 week 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.