How to set the default markup language to HTML (instead of markdown) for new notes?

Hello,

I find Joplin Desktop application awesome, but I'm not interested in using Markdown in my notes as it's too limited compared to HTML.

I found out that it's possible to have the markup language of the notes set to HTML(). Thanks to this setting Joplin doesn't try to convert the notes in Markdown which among other things allows me to keep my tables as HTML. But I am not able to set the markup to HTML when I create a new note from within the desktop app.

  • How can I set the markup language of a new note created in the app to HTML?
  • How can I set the default markup language to HTML?

Thanks a lot for your help!


*) The markup language of a note is set to html when I import files with the .html extension (via File>import). I can also set the markup language html when I create a note via the API (by setting markup_language="2"). But it isn't practical to import a file or use the API each time I want to create a new note.


Desktop application
Joplin 2.8.8 (prod, win32)
Client ID: f493c04dd4c2456593b807a1a1a6d505
Sync Version: 3
Profile Version: 41
Keychain Supported: Yes
Revision: c2a6a13

Window 10 version 21H1

1 Like

Markdown is just shorthand for html, it all gets converted into html in the backend anyway so you can just write html as is :ok_hand:

That said, it might be worth your time to get used to markdown for the simple stuff anyway since there's no real difference under the hood and markdown is quicker! Using both is an option for what you find too limited in markdown :man_shrugging:

1 Like

Thanks for you answer but there are differences in how the notes are processed when switching from the note editor to the rich text editor. For example, when the markup is set to markdown, the HTML tables are converted to markdown (which messed up with my tables are they are too complex for markdown, ie merged cells...) but not when the markup is set to HTML. That's why I really need to be able to set the markup by default to HTML.

If all you need is merged cells, multimarkdown tables can do that, you can enable them in the settings (Tools > Options > Markdown, it's at the bottom) and the syntax is here.

Also what do you mean by "the markup is set to HTML", where are you looking in the settings, I don't see an option like that anywhere?

The table with merged cells was just an example. I use many more features in my tables so I really need them to be set as HTML.
To know if a note is markdown or HTML, click on the info symbol on the top right corner.
This is markdown:


This is html (this note was created via the API):

Made a pair of notes and I see the difference now as well as your problem!

I will mention that duplicating a note keeps the markup type as well so keeping an empty note is an option?

But in terms of a better solution like a keyboard shortcut, I doubt you'll find it unless the devs are willing to help, Joplin is a markdown note taking app first and foremost, this feature seems pretty niche as far as I can tell... :man_shrugging:

(post deleted by author)

Please keep it civil, I very much doubt anything malicious like that was intended. The app is indeed designed to be markdown based for actual note taking as well as storage - the HTML mode is mostly used for lossless Evernote imports and website clipping.

The ability to manually switch modes hasn't come up very much before but it is something I have thought about before as it is really pretty easy to swap the types in the database or do what @Jippi has via the API. One of the reasons I was wondering about it was for the richtext editor as it has features that are lost when converting to markdown which is something that does come up quite often.
However the major drawback here is that notes written in pure html will be much more difficult to edit on mobile.

An idea that I also was thinking about would be a way of marking a blocks of text or other elements which the markdown conversion will then ignore which would go some way to solving the issue.
For example if you made a fancy table in the richtext editor (or even manually) then if you were to wrap it in a special tag or give it a class (Joplin already has class="jop-noMdConv" which it adds to some elements, such as resized images so it doesn't go back to markdown).

5 Likes

You need to cool your jets mate, I'm just a fellow user trying to answer a question...

Never said it was a better way, just trying to offer literally any kind of solution, I don't use HTML notes so I can't help there but I do use multimarkdown occasionally so it doesn't hurt to ask if that works instead. I can't give them advice about HTML notes if I don't use them myself...

You're telling me to give a yes/no answer when I don't know if a solution exists, I'm just exploring options with them to see if there's something that will work in the mean time...

3 Likes

Thanks for your answer.

I don't mind if my notes are very long because of the HTML tag/styling. I much prefer this to not having the full power of HTML.

This would not be a good solution as it would be too easy to delete the markers for those blocks (be it a tag, an html class...) without paying attention and then the content of those blocks would be converted to markdown and a lot of formatting and even data could be lost. I would be much easier to simply let the user choose the default markup of the notes by having a general setting. So, the user could choose to have markdown by default, or HTML.

Thanks for investigating it and finding this solution. I didn't know about that. It's better than importing a file/using the API but still very cumbersome.

The thing is... everything is already there, it's just that it's not accessible to the regular user but a simple setting could fix this. It would greatly improve what the users can do with Joplin. I almost gave up on Joplin because of the lack of HTML support. I just saw by chance that there was this markup. Having an easy way to have full HTML support would not change anything for the users who want to use markdown, but could bring a lot of new users and with minimal change for the Joplin team (as HTML is already "secretly" supported)

1 Like

Just thinking, if markup_language is updatable via the data api then it will be easy enough to write a plugin that allows you to convert from one to the other. At that point it would be as easy as using any other command which could also be bound to a UI button, menu item or shortcut.

I don't think its really a secret, its literally part of the spec.

1 Like

I think that it's pretty risky to rely on a plugin for such a fundamental thing as the default markup language (I am not trying to convert my markdown note into HTML note, I am trying to get all my future new notes to be HTML). I just don't understand why the full HTML support (without any markdown filtering ― which is already available via import/API), is not made available via the Joplin UI (which is what I meant by "secretly supported").

I think what @Daeraxa meant was that you could have a plugin to change the markup type of the note in the backend, the processing would still be the same but it would be an easier way to switch any notes between the two types rather than having to import a .html file/copy an existing note/etc

Indeed, I was thinking that (if possible which I haven't actually checked yet, a plugin could access the data API and set the markup_language field and swap it on command.
If you wanted to get fancier with it then it could have an option to always set it to HTML by watching for notes being loaded or always set it on newly created blank notes etc.

Ultimately it is a fairly niche request judging by how often it has come up and I think there is a better solution in there somewhere that won't lead to problems down the line that haven't been foreseen.

Edit: Yes, it definitely is updatable to HTML (i.e. "markdown_language": 2 using the data API, no need to define a note from scratch. It also does have some weird side effects, for example if you swap to the richtext editor then it does some odd things with the font colour. I was using the dark theme, the text is black until you reload the note.

1 Like

Just out of curiosity if nothing else I've created a plugin with a command that should swap the note type.

The command to run is toggleMarkupLanguageType and once the plugin is installed you can do it from the command palette.

I haven't published this yet as I'd like to know if this actually breaks anything before I unleash it on the world so currently the way to install it would be to download the jpl from my github repo Release v0.1.0 · Daeraxa/joplin-plugin-toggle-markup · GitHub and install it manually in Joplin, preferably in the dev environment as I accept no responsibility for breaking anything.
If you decide to install on your main environment then please make sure you back everything up first.

Code wise it doesn't really do anything scary (in theory). It just grabs the selected note's ID, checks its markup_language type then sets it to whatever it currently isn't.

3 Likes

If you're comfortable working with the underlying database directly, this should set the default markup language to HTML and change it for all existing notes as well:

ALTER TABLE notes DROP COLUMN markup_language;
ALTER TABLE notes ADD COLUMN `markup_language` INT NOT NULL DEFAULT 2;
UPDATE table_fields SET field_default=2 WHERE field_name='markup_language';

Obviously make a backup first.

2 Likes

@roman_r_m , that's awesome! Thank you so much! Please add this as a setting in Joplin. It won't change anything for all the users who want to keep markdown as they default markup but for those who want to have full HTML, they could just activate this setting without being afraid of tinkering with their DB. This would bring a lot of new users to Joplin (once again, I also gave up on Joplin when I saw that all my HTML tables were ―badly― converted to markdown). It's not a massive change for you and would be a huge advantage for Joplin!

@Daeraxa, Thanks for taking the time to write a plugin! I tried it and it was nice for converting my HTML note that add the markup language set as markdown. One drawback is that it has to be done for each note separately but at least the option is here now. Also, I am very happy because I have an example now of a simple plugin and can start experimenting further! So, thank you!

2 Likes

I think so far you're the only one who asked for this.

3 Likes