View rendered markdown source

When I have a Markdown file I can view the markdown source, the rendered preview, or both side-by-side.

How can is see the HTML, JavaScript, and CSS that is built for the preview? I would like to see how my custom CSS stylesheet is applied.

Here is an example from clicking inspect element in Marked 2.

There are no developer tools built into DEVONthink.

Also, you can’t inspect elements in a Markdown file, so you’d need to convert it to HTML for inspection.

Otherwise, Development would have to assess the feasibility and broader appeal of adding such functions.

OTOH, you already have Marked 2 providing the functionality you desire. :wink:

1 Like

How exactly does DEVONthink render the Markdown? Marked 2 does not necessary render the Markdown the same way. That is part of the reason I want to see what DEVONthink does. Using the same CSS stylesheet, the DEVONthink preview and Marked 2 preview are different.

Is there perhaps some kind of AppleScript or something that I could run to produce and export the sources that are rendered for the DEVONthink Preview?

As @bluefrog said: Convert the MD to HTML in DT. Then you can look at the HTML source in DT or in your favorite browser. Dead simple, actually. And mentioned reguarly here in this context.

As to

you could perhaps describe in what way they’re different? I guess that Marked2 as well as DT use Apple’s WKWebView to render the HTML, so it should be the same. Well… in theory.


Marked 2 is a bespoke Markdown rendered. As such, it has extensive settings providing a variety of options for handling and rendering Markdown.

Just look at these options in the Marked 2 window…

You’re not comparing apples-to-apples here.

I am using the same custom CSS in both DEVONthink and Marked 2. There are different rendering settings in both applications. I think @chrillek 's suggestion of converting the MD to HTML in DEVONthink will help greatly.

Then I can compare the two and see what I need to do to get them to align.

I will try the MD to HTML suggestion. :grin:

This important differences for me are:

  • In DEVONthink the preview has no page margin/padding so the text starts and ends right at the page edge. Maybe DEVONthink does not support media queries, or not in the same way as Marked 2.
  • The rendering is different for fenced code blocks. Despite the differences, I want to make the font small for the fenced code blocks. I want to see how they are rendered in HTML so I know what to manipulate. Applying a style to the CODE tag did not work.

As I said: DT relies on WKWebView or something like that from Apple. So it should behave as Safari.

OTOH, user agents are free to implement their own CSS defaults. To ensure that your HTML looks as similar as possible on different browsers, you should set all the properties that are important to you. Searching the net for „reset CSS“ might help.

Fenced code blocks are usually pre elements within code.


To ensure that your HTML looks as similar as possible on different browsers, you should set all the properties that are important to you. Searching the net for „reset CSS“ might help.

I am first using normalize.css. I can see though some differences now even with normalize related to the browser/user-agent default style sheet.

I am now seeing conflict between local file access restrictions. (Most browsers restrict local file access for things like CSS.)

I can serve my CSS and JavaScript from a local web server but it appears that Markdown preferences permit only local CSS/Style Sheet and JavaScript. Is there a way to tell DEVONthink to use a remote resource rather than strictly a local file? When I select a resource, it converts the URL in to use file://.

I’m not sure what you’re seeing. Also, I would not use a third-party CSS that purports to gloss over browser differences – for markdown, that should be completely unnecessary.
For the rest: you should describe in detail what you’re doing. Right now, is only about the output but I have no idea about the concrete input.
It shouldn’t be a problem to provide a style element in the MD file with whatever link you want.

Okay. I will research this a bit more.

I do not want to add it to one markdown file, I want it added automatically to all markdown files during processing. The ideal way to do this would be to have a preference where I could have a file with content that is directly included in the HEAD of the Markdown rendered as HTML. So that rather than linking to a local file I could add content directly, including linking to local files, remote files, etc.

That Style Sheet preference produces this in the HTML.

<link type="text/css" rel="stylesheet" href="file:///Users/mmynsted/style/lit-plus.css"/>

This is a local file reference that is often blocked by web browsers.

Better would be something like this.
<link type="text/css" rel="stylesheet" href="http://localhost/css/lit-plus.css"/>

This is not blocked.

Best would be to directly include content to all Markdown files durning processing.
Like the proposed solution here → Please make it possible to include JS/CSS files in markdown rendering from Application Support folder

I wish there was a hidden preference for this. As is I will just have to deal with the issue of most browsers not supporting loading local resources. It can be overridden in modern Safari, but not Orion, etc.

Certainly not if your loading the HTML file locally in you browser? But: all this is beyond your original question – why does marked2 render MD differently from DT. In this context (I’d rendering in local apps), local CSS files are perfectly fine.

That would require a running local webserver, which many DT users probably don’t have (nor need or want).

But I see your point about the inclusion of user CSS/JS. It’s not optimal now, I think. In my mind, a viable way would be to include the CSS/JS verbatim Inn the final HTML using style and script elements. Tough there might of course be CSP issues with that, too.

1 Like

Yes. What happens is that the HTML file loads, but some file:// linked resources are silently blocked unless the browser has a preference to override the “feature”.

all this is beyond your original question – why does marked2 render MD differently from DT. In this context (I’d rendering in local apps), local CSS files are perfectly fine.

Well I was trying to use my browser to examine the DEVONthink HTML file converted from Markdown. The browser would not fully render the HTML file because of the local file block. It is fine I can just diff the rendered HTML.

Direct inclusion is the only way to get both DEVONthink and my local browser to behave the same. This direct inclusion would be really useful to me, and hopefully others.

Which I find difficult to understand: A local HTML file is loaded via the file://protocol as well, so CSS and HTML have the same origin. Which seems what the second link you posted is referring to as well.

And I do not see any problem here with a file:// URI in Firefox:

It does not work with an x-devonthink-item URI, but that’s to be expected.

That is correct since you are linking a local file, regardless if you’re trying to serve it via web services.

This is a local file reference that is often blocked by web browsers.

May I ask why this is of consequence to you? Are you writing blog posts, etc. for publishing?

1 Like

I am no longer getting the error in Safari so I perhaps I was wrong about the cause of the blocked local files. I originally saw the error and making the change in safari appeared to solve the file access problem. I later gave Safari full disk access, restored the default Safari setting, and restarted everything and I no longer see the style sheet blocked.

Yes, that is a good question. I like DEVONthink to be my source for notes, information, etc. Part of the way I use it is as a Zettelkasten. I copy out information for documents, policies, technical writing, blog posts, and company wiki entries. The idea is to have one base style that covers the 80% of the styles that are common to all these destinations. The problem is that the presentation is not the same in DEVONthink and elsewhere. I believe this means I need to improve my stylesheet to ensure things work the same. One example was the margins. I mostly fixed that. Another example is fonts.

Here is a simple Markdown source.

# This is a test

This is a test

DEVONthink converts that to a rather large HTML file because I am using Prism, etc. Otherwise I would paste it here…

The presentation in DEVONthink looks like this.

The presentation in Marked2 looks like this.

The margins are a bit different. I would like to view the DEVONthink converted HTML version in Safari to see why the margins are different.

Here is what the DEVONthink HTML version looks like in Safari.

It seems that DEVONthink is finding the font, Nunito, but Safari is not. Once I get this sorted out I can use the DEVONthink converted HTML file as a comparison to the Marked2 version and update my styles to be more compatible.

It would be easier to help you if you’d provide the source of your CSS etc. You could turn off Prism support before converting to HTML or simply cut out the prism stuff in an editor before posting here.

Alternatively, a screenshot of the console and the CSS in the developer tools.

As I said before: Every user agent is free to define its own default style sheet (and they do!). The only way to ensure a mostly identical representation is to reset the CSS.

Again: show the source. E.g., I have

h1, h2, h3 {
  font-family: Avenir, Helvetica, "sans serif"

and the headings are in Avenir in DT as well as in Safari.


Unless I missed the answer to this: what are you using Marked for, outside of trying to inspect elements ?

1 Like

Here is the work-in-progress CSS file I am using. Here is a bit better test file modified from one I found somewhere on the web.

Here is the original test file converted without Prism etc.

<!DOCTYPE html>
<html dir="auto">
<meta name="generator" content="DEVONthink 3.9"/>
<link type="text/css" rel="stylesheet" href="file:///Users/mmynsted/style/lit-plus.css"/>
<meta charset="utf-8"/>

<h1 id="thisisatest">This is a test</h1>

<p>This is a test</p>


Here is what it looks like with Developer tools console open in Safari.

Here is what inspecting the BODY looks like in Safari Developer tools.

what are you using Marked for, outside of trying to inspect elements ?

I write far faster in Vim/Vimr than I do using other technologies like the editor in DEVONthink. I preview with DEVONthink when the file is both short and in DEVONthink. Often though, the Markdown content has been copied out of DEVONthink into Scrivener, a git repo, or some other place, or the file is in DEVONthink but longer than one screen. When that is true I use only Marked for the preview.

There are challenges with previewing long DEVONthink Markdown files with Marked. Marked is unable to find images, transcluded files, etc. Mostly that becomes a reminder that I need to break my DEVONthink content down into small pieces. More like singe pages, or even slips, rather than long-form writing.