Hacker News new | ask | show | jobs
by the_gipsy 25 days ago
> Using WebKit to render Markdown seems completely appropriate.

It doesn't? Needs an explanation.

1 comments

markdown is a markup language 'intended' to be rendered as HTML, WebKit seems appropriate to render HTML
Still seems overkill. It's just headers, lists, block quotes, codeblocks, and a few inner emphasis and link formatters, basically. HTML is the whole jungle for a gorilla with a few bananas here.
> It's just headers, lists, block quotes, codeblocks, and a few inner emphasis and link formatters, basically

That, and in-line HTML. https://daringfireball.net/projects/markdown/syntax#html:

“For any markup that is not covered by Markdown’s syntax, you simply use HTML itself. There’s no need to preface it or delimit it to indicate that you’re switching from Markdown to HTML; you just use the tags.

The only restrictions are that block-level HTML elements — e.g. <div>, <table>, <pre>, <p>, etc. — must be separated from surrounding content by blank lines, and the start and end tags of the block should not be indented with tabs or spaces. Markdown is smart enough not to add extra (unwanted) <p> tags around HTML block-level tags.”

Because of that, I think I would use a html renderer to render markdown. Because people allowing arbitrary HTML opens a huge can of worms I might also whitelist a restricted set of HTML.

It's still going to be faster than creating and moving around a bunch of NSViews simply because the WebView (native WebView, not Electron) renders the entire content at once, directly on the graphics pipeline, skipping all layout and compositor steps that get done on normal NS(Text)Views.

The key point here is to use the WebView only for the text view. Where it goes wrong is when people start writing entire interactive UIs in the WebView.

The other option would be PDFKit, but most people aren't nearly as comfortable programming with PDF as they are with HTML.

More importantly all HTML is valid markdown.
Also, there is no such thing as valid markdown.
Putting HTML in markdown defeats the purpose IMHO.
I don't think it does at all!

> The overriding design goal for Markdown’s formatting syntax is to make it as readable as possible. The idea is that a Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions.

https://daringfireball.net/projects/markdown/

Using some semantic HTML as an occasional escape hatch is perfectly in line with this overall goal.

> without looking like it’s been marked up with tags or formatting instructions.

From your own quote. Embedding html absolutely violates the spirit.

That’s for the markdown content.

HTML embedding as an escape was built in Gruber’s markdown from the start, and is part of why markdown is simple bordering on simplistic: https://daringfireball.net/projects/markdown/syntax#html

That doesn't make it not true though. Markdown generally supports HTML (though oftentimes only a subset), and is typically styled using CSS. Using a web view makes complete sense to me.
That doesn’t track at all. Markdown was created as a simpler way to mark up text than HTML. They are both ways of encoding a document that provide ways to convey intention. HTML is no one’s end goal.
First sentence of the announcement / introduction of markdown:

> Markdown is a text-to-HTML conversion tool for web writers.

HTML embedding was also integral to it: https://daringfireball.net/projects/markdown/syntax#html

> Markdown’s syntax is intended for one purpose: to be used as a format for writing for the web. […] For any markup that is not covered by Markdown’s syntax, you simply use HTML itself.

Understood. What I was trying to say but elided pretty well is I think it's now become something else. Almost its own in-between format that provides a fair bit of marking for clarity with a level of security and the ability to extend as needed. Definitely my own perspective as it's my default for working in Slack and Teams, I keep notes in Obsidian, etc. At no point do I think of those as places I am trying to write HTML, just places I am trying to write with the ability to add more context.