 This is the session about editing Markdown with Qtex document using either widgets or Qt Quick. And one of the new features in Qt 5.14 was Markdown support in Qtex document. And this turns out to apply as well to text and QML. If a link is clicked inside this text object, then I want to open the URL externally. So if I click this Markdown, then it loaded this link here. The motivations for doing this, there's always been historically a bit of a disconnect between WYSIWYG applications and plain text editing. And people who use plain text editors think that their way is superior. You shouldn't depend on one particular tool, right? Markdown is a really nice compromise. You can use a plain text editor to write Markdown. But now you can also write WYSIWYG applications that look just like word processors, but actually are writing this format, which you're able to edit by hand as well. I've been using to-do dot text format for shopping lists and to-do lists and things like that, but that doesn't allow you to write any kind of notes along with your checklist items. Just a checklist. I think that Markdown is a better format for doing things like that. I think it would also be a better format to use by default for email and a sort of a consensus convention which turned into a formalized format. So I think that since people have already been writing Markdown all this time for emails, why don't we just go ahead and say that emails are usually Markdown. The only HTML emails you get would be commercial ones, and then that would be a nice way to filter them out. But I'm sure within the KDE community, you probably can come up with more ideas for what applications you'd like to use Markdown. Another motivation is that Q-text document supports a limited subset of HTML, but it's disappointing to people how little of HTML that we support. But it turns out that the Q-text document feature set is a very close match for the Markdown feature set. So there was a hackathon in December 2017 at the Qt company, and I decided to implement as much of that as I could in a couple of days. And then it took several more months of refinement before we shipped. So the feature set that we have, Q-text document already had two HTML and set HTML. And so alongside those, I added set Markdown and two Markdown. We support the GitHub dialect by default. When you call set Markdown, in addition to giving the string that you want to parse, you can also give these flags. You can specify that you only want to use Common Mark without the GitHub extensions, and you can also set no HTML. So thanks to Martin for implementing MD4C. Using the hackathon, I was looking for a library that I could use for the parser because I didn't really want to try to write one myself. So we're actually bundling it with Qt. And currently we ship version 0.43 in 5.15, and we hope that eventually MD4C is going to be popular enough that the distros will have it and we'll be able to stop bundling it with Qt. So here's an example using Qt Quick Controls 2. I used XHR to load an MD file, which, of course, is not something that we're supposed to be doing in Qt 6, for example. The text area you mark down, you can scroll through it. And if you hover a hyperlink, it shows you feedback down at the bottom. The next example I want to show you is Netbook, which is one that I've written for my personal use. So in my source directory, I've got a version of this built. So I can edit my Readme text file now, and I can format it different ways. And let's say I want to add some bullet items. So I can convert all of these to bullet points now by selecting that style. Control Right Bracket will indent. I can change to a different type of bullet. So it has the three types that Qt supports. Another feature that I liked, of course, is being able to do the checkboxes. So you could start by writing something, whether it's a bullet point or not, you can convert it to a checkbox by hitting Control K, which is another way of toggling the checkmark. Or once I've got the checkbox, I can simply click it to toggle it. So now let's save this Readme text file. So there's the stuff that I added. And notice that the bullets are the different types there based on the bullets that I chose in the Style checkbox. And the checkboxes are once checked and the other is not. But another thing that I discovered is that it's useful for saving snippets of information off of the web. Let's say, for example, I've been searching on the web and I found this recipe. It sounds interesting. I want to try. At the top it has pictures and so forth. But I don't need to save all of that, but I want to save the recipe itself. So I just select the text, copy it to the clipboard, and I'm going to create a Markdown file. I paste this text into there. Qt already had really great clipboard support. Now I've got my MD file. And this looks so good that I don't mind reading it with a plain text editor on the command line or however. But of course, I can also just start up a network again in the browser mode. The main control is actually a Qt text browser. It gives me a nice view of this, and if I was running this in the kitchen it'd be a nice way to view the recipe and cook. So another thing I wanted to be able to do is to blog with this tool. And I don't feel like writing text right now during this presentation. That takes time. I'm going to write a new blog post Markdown file, and I'm simply going to paste in some text from the web. This is another talk at Academy about the input handling update, which you also might want to watch. Not quite as interesting as this talk, though. So I save to a Markdown file simply by copying and pasting. Notice it actually got the image as well. And there's a feature that if you check this box, it will try to save the resources alongside the documents, and you get to specify the suffix for the resource folder. So now if I can't this Markdown file, you see that it actually has the resources and it got the alt text as well from the HTML. So I have this ready to go now. I have a Markdown file. I can read it again. I want to publish this. So I was thinking about using IPFS for this purpose, for publishing things. So what is IPFS? It's a content-addressed peer-to-peer file system for the distributed decentralized web. That's kind of a mouthful. What that basically means is that when you save files to IPFS, it's like a file system, but the files are hashed. If I simply hit save to IPFS in the file menu, it gets its hash, and it has now been pinned, which means that it's available. It's going to be held there in my local file system, and it can be served to others. So if I look at my pins, this one ends with R6Q. So there it is. And now I'll show you one of the browser features of Netbook. I can just look at all of my local files, and there's the blog post that I just created. So there's the file, and it knows how to load this. So why does that work at all? Well, it's because I wrote a KIO slave for IPFS along with this project. So the result is that you can use Dolphin, for example, to view the local IPFS files as well. I'm not sure why that directory doesn't work. Some of these are Markdown files. Most of them are Markdown files. And now I can open it with any application that's able to use KIO slaves. I think that this IPFS KIO slave should start to ship at some point. I want to try to get it into the distros, but it does need a bit more work. It's got some bugs. I'm not sure about the future of KIO in general. Maybe you guys could tell me more about that. So eventually, I want to be able to publish real blogs this way where not only I create the post, but I also update an index that links to the new post. So how do we publish things on the web with IPFS? You see that a file has a hash. There's Zukos Triangle, which says that you can only have two of three of these properties at the same time. It can be human meaningful, like a domain name. It can be decentralized, like IPFS. It can be secure, like IPFS. So there's this IPNS, the naming system, which allows you to map one hash to another. So IPNS will allow you to publish a fixed hash, and that can point to a changing hash. And so they came up with this DNS link mechanism. There's a text record, which says what the DNS link is for netbook.org. And that is an IPNS name. It's using the IP naming system. The result is if I go to netbook.org, I still have this loaded on a conventional web server, but it contains a redirect so that if everything is working right, it will use the IPFS.io gateway to eventually load the IPFS version of the website. So this is HTML. But what I eventually want to do is to be able to publish Markdown directly to the web. And there are JavaScript libraries for rendering Markdown into the browser, like strapdown.js is one that I was thinking of using. So eventually I want to make netbook into a blogging tool, which can publish a blog in Markdown on IPFS. Rendering in the browser is basically up to your browser to do for itself by running the JavaScript library. So that's a long-term vision, but I'm not there yet. So stuff left to work on, by which I mean the stuff left to work on in Qtxt browser and in Qt in general. And of course I want to just keep fixing bugs, especially in the writer, because the Markdown writer is something that I wrote myself. So there tends to be bugs in that code. I just fixed several of those in 5.15.1, so it's getting better. Whenever you're able to read a particular Markdown file and then you're not able to write it back out or it writes it out wrong, you can write a bug about that. So that's the end. Thanks for watching and enjoy Markdown in Qt.