Use case system-wide CSS for Markdown

First, let me say that DEVONthink’s support for Markdown was a big part of what made me choose it when I decided to leave Evernote. The good Markdown support combined with indexed files and DEVONthink’s superior search makes for an almost perfect environment.

I’m a developer/support person. I write a lot of Markdown. My team writes a lot of Markdown. Some Markdown goes to ZenDesk, some Markdown is our knowledge base or documentation web site, some is Markdown I write for my own notes. Most of the web clippings I make end up as clutter-free Markdown–so much better after the DEVON clipper was introduced!

DEVONthink’s default Markdown stylesheet is a bit plain. I’m aware I can use a per-document stylesheet link. That’s acceptable for my own notes. That’s not going to work for shared Markdown.

Having our entire documentation web site in indexed Markdown format, alongside our Markdown knowledge-base and my own notes makes my job so much easier because there is one place with excellent search that I stop first. The shared Markdown files are styled with the site theme by Hugo for the docs site, and GitHub’s default for the shared KB. I can’t inject CSS into the shared Markdown.

Please, allow us to use a custom stylesheet for any Markdown file that doesn’t specify one. In a perfect world, maybe define a few selectable ones like Marked. I’m aware that I can change the font and size, but the thing I really want is inline code and code blocks to be styled. You get really used to that on GitHub. I’m sure we all have our opinions about how to style things, so I think this would be useful for a lot of “Markdown first” types, like me.

Thanks,
Bill

1 Like

Thanks for the suggestion! One workaround might be to use Preferences > Web > Style Sheet but this would affect any web view.

I agree with the previous suggestion that you create a Markdown template with the link in place. Then just use that when you want to generate a new Markdown document.

A database wide header file for all markdown files would be rather nice. Especially when you have over 1000 markdown files and decide to do a change that requires another line.

Like searching for .header could bring up the special file.

Thanks, @BLUEFROG, but that’s not going to work in my case. I’m talking about a few thousand shared Markdown documents I’m storing that will be styled by a Hugo theme or GitHub’s stylesheet. I can’t inject CSS into them.

It’s pretty rare to see CSS used in a Markdown file in real-world usage. Generally, they are close to the platonic ideal of content instead of presentation.

I wondered if the system-wide web stylesheet would help. I could probably use that as a workaround. I spend a lot more time looking at styled Markdown instead of web sites in DEVONthink. I tried it with a pair of stylesheets that I tested in Marked, but neither affected the web or Markdown views in DEVONthink Pro.

Bill

Another upvote for this feature from me. Customizable system-wide CSS for the Markdown would be beeeeautiful. :slight_smile:

While waiting, I’ve made my custom CSS as short as possible using the multi-markdown meta block syntax. The first line of every markdown document includes the CSS line, linebreak, and then my document. So for example:


css: http://example.com/md.css

# My Main Heading

The rest of the document, etc

I had to set up the my custom URL to host the CSS, but it’s mostly unobtrusive this way.

The only annoyance is when I don’t have a network connection—this can cause the Markdown document to not display at all, since it’s stuck trying to load the CSS. Not perfect, but prettier than the default. :wink:

Why not just use a link to an external stylesheet that exists in your current database?

I think the point is that adding a link is not an option when you have hundreds of pre-existing Markdown files possibly spread over several databases. That is where a Markdown equivalent to Preferences > Web > Style Sheet would be fantastic.

1 Like

What if you have 100 you want one style and 100 you want another?

Well, if you don’t want the default style you set a specific link. If you want the default style you don’t set a specific link. But I would like to control the default style through a preference. Just like you can with a Web Style Sheet preference .

1 Like

I’m a bit late to the discussion, but, I concur a user-definable default CSS for Markdown would be fantastic - and a big improvement to DEVONthink’s Markdown feature!

I agree that the addition of this feature would make the DevonThink Markdown experience even better: For me, a single user-definable style sheet for markdown would be very helpful, in particular the mathjax one-liner


<script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>

is annoying for me to add to the hundreds of markdown files I already have. Another reason is that the font size between text, tables and lists seems to be a bit inconsistent.

Concerning

  • in the two cases I mentioned, there is no need to distinguish between different styles for different markdown files.)

Changing the “system wide” style sheet in preferences has only an effect on html, not on markdown. What am I doing wrong?

(And concerning mathjax, I am unsure how I could embed the mathjax one-liner via css; is this even possible?)

The Rich Text & Note Font applies to Markdown docs with no CSS styling applied.

You would use like this in the head…


<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML'></script>

Thanks for the quick reply, although it is no effective solution for BillSmargiassi or me;-)

In July, cgrunenberg and you wrote that style sheets could be a solution to change the style of all markdown files at one. It is good to learn from your reply that it is actually the inflexible RTF notes setting which sets the markdown preview style. That leaves the issue open for someone like me who has hundreds of existing notes and does not want to change the header for each of them.

I am a physicist, and most of my notes contain some equations (which are not too complicated, but utf8 is not a solution). I would appreciate if you considered to let the markdown style be determined by a style file just like html, and if you could add a checkbox in the preferences to swithc on mathjax support.

While I am a longterm DT user, I am a “forum newbie” - should I send these feature requests separately to feedback at devontechnologies.com?

Feature requests are best submitted on the Forums so other can weigh in on it.

A couple of comments.

First, for those wanting to use MathJax offline rather than use the CDN, you can put the files in a DEVONthink database and refer to it in the .


<script type="text/javascript" async src="/resources/MathJax/MathJax.js?config=TeX-MML-AM_HTMLorMML"></script>

This also works offline for DTTG too.

Second, I completely agree that it would be great if we could specify a default CSS that automatically applies to all markdown documents, and the ability to override in the markdown document.


Stephen

@StephenL: Thanks for the tip

What about using the tag system for applying the stylesheets? these 2k files are tagged for my GitHub css setup, the test are tagged for my modern css.

So what, apply CSS per Tags on a file?