Giter VIP home page Giter VIP logo

qmarkdowntextedit's Introduction

Build Status GitHub Actions Build Status Linux/OS X Build Status Windows

QMarkdownTextEdit is a C++ Qt QPlainTextEdit widget with markdown highlighting and some other goodies.

Widget Features

  • Markdown highlighting
  • Code syntax highlighting
  • Clickable links with Ctrl + Click
  • Block indent with Tab and Shift + Tab
  • Duplicate text with Ctrl + Alt + Down
  • Searching of text with Ctrl + F
    • Jump between search results with Up and Down
    • Close search field with Escape
  • Replacing of text with Ctrl + R
    • You can also replace text with regular expressions or whole words
  • Line numbers (Qt >= 5.5)
  • Very fast
  • And much more...

Supported Markdown Features

Commonmark compliance is enforced where possible however we are not fully Commonmark compliant yet. Following is a list of features/extensions supported by the highlighter. Please note that this is just a plaintext editor and as such, it only does the highlighting and not rendering of the markdown to HTML.

Feature Availablity
Bolds and Italics Yes
Lists (Unordered/Orderered) Yes
Links and Images
(Inline/Reference/Autolinks/E-mail)
Yes (Cannot handle nested links or complex cases yet)
Heading (ATX and Setext) Yes
Codeblocks (indented and fenced)
Both backtick and tilde code fences are supported
Yes (Only fenced code block has syntax highlighting)
Inline code Yes
Strikethrough Yes
Underline Yes (Optional)
Blockquotes Yes
Table Yes

Screenshot

Screenhot

Usage

There are multiple ways to use this. You can use the editor directly, or you can subclass it or you can just use the highlighter.

Using the editor

QMake

  • Include qmarkdowntextedit.pri to your project like this include (qmarkdowntextedit/qmarkdowntextedit.pri)
  • add a normal QPlainTextEdit to your UI and promote it to QMarkdownTextEdit (base class QPlainTextEdit)

CMake

  • Include CMakeLists.txt to your project like this add_subdirectory(qmarkdowntextedit)
  • add a normal QPlainTextEdit to your UI and promote it to QMarkdownTextEdit (base class QPlainTextEdit)

Using the highlighter only

Highlighter can work with both QPlainTextEdit and QTextEdit. Example:

auto doc = ui->plainTextEdit->document();
auto *highlighter = new MarkdownHighlighter(doc);

Projects using QMarkdownTextEdit

Disclaimer

This SOFTWARE PRODUCT is provided by THE PROVIDER "as is" and "with all faults." THE PROVIDER makes no representations or warranties of any kind concerning the safety, suitability, lack of viruses, inaccuracies, typographical errors, or other harmful components of this SOFTWARE PRODUCT.

There are inherent dangers in the use of any software, and you are solely responsible for determining whether this SOFTWARE PRODUCT is compatible with your equipment and other software installed on your equipment. You are also solely responsible for the protection of your equipment and backup of your data, and THE PROVIDER will not be liable for any damages you may suffer in connection with using, modifying, or distributing this SOFTWARE PRODUCT.

qmarkdowntextedit's People

Contributors

0x3508a avatar bjorn avatar cm0use avatar data-man avatar fnkabit avatar fnkhz avatar gremious avatar liulex avatar maya-doshi avatar pbek avatar rwiesenfarth avatar sanderboom avatar sandsmark avatar sdicke avatar stuhlmeier avatar szinedine avatar tim-gromeyer avatar waqar144 avatar wineee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qmarkdowntextedit's Issues

Idea: Highlight links in headings

Would it be a good idea if I implemented highlighting in headings?

My idea is to highlight them normally, like any link, but we don't highlight the title itself. Here is an example:

image

The yellow parts will be highlighted with masked syntax (like the #) and the other part will not be highlighted at all.

Question: How to zoom?

How can I zoom in and out with as little code as possible? MarkdownHiglighter uses a fixed font, so QPlainTextEdit's zoom functions can't be used

Auto format table

Currently the text editor in QOwnNotes understands and marks the tables as code. This is an enhancement request to also auto format the table when user inputs a separator |.

Example:

  1. Assume given text as below
| header 1 | header 2 |
| content abc 
  1. User inputs | after abc
  2. Expected output - note how the | after header 1 auto indented itself
| header 1    | header 2 |
| content abc |

This makes the content more readable.

Build fails with -DQT_NO_CAST_FROM_ASCII

When -DQT_NO_CAST_FROM_ASCII is defined, you cant call QChar(' ')(char) and QString("String")(const char*).
To avoid the QChar error we could use QChar(u' ') but this requires Qt >= 5.10.
For QString we could use QStringLiteral.

I created a issue because i don't want to create a pull request that requires Qt 5.10 without having your OK.

Support for Forth Syntax Highlighting

Thanks for creating this very wonderful effective control for Qt.
I am an avid user of the QOwnNotes and a Forth enthusiast.

While adding Forth code, I found that there is no highlighting support.
I wish to request your kind help regarding the same.

In line with this, I have taken a fork and placed in my changes.
Initially, the gforth words are added as the keywords.
There is also addition of special filter functions to help with comment highlighting.

This would be the first time I am trying to contribute to a project.
Please guide me and help me correct my mistakes.

What is the license? GPL or MIT?

I can see the license on the repo is listed as MIT however, when looking in the files it states the license is GPL:

/*
 * Copyright (c) 2014-2023 Patrizio Bekerle -- <[email protected]>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 * for more details.
 *
 */

Is it possible to confirm which license is to be taken in consideration when using these files?

Danke

Character auto-removal for same char types doesn't work correctly

Characters such as:

* ` _ " '

don't get auto removed correctly sometimes on pressing backspace.

To fix this we need to determine whether the character being removed is an 'opening' or 'closing' character.

  • Fix single quotes removal
  • Fix double quotes removal
  • Fix asterisk removal
  • Fix backtick removal
  • Fix underscore removal

Note: Looking backward for these characters is temporarily removed until proper solution is implemented.

Note: Commonmark rules for some characters might not completely apply because we are removing only one character at a time. Consider **bold**, we need to handle this in a way that removal of first asterisk results in the removal of third asterisk.

Use Qmarkdowntextedit just to view the markdown

Hi, I have used QmarkDownTextEdit in one of my utility, am wondering if this can be used just to show the parsed output in QTextBrowser, etc.
Right now it is showing output with markdown syntax in place.

License of markdownhighlighter

Hi @pbek,

I would like to use the markdownhighlighter class in a project and I saw that in the file headers the license is set to GPLv2, while the project is under MIT license.
Can you please clarify which one is the valid license?

thanks a lot in advance,
Johannes

Options for a WYSIWYG editor?

Hi,

since https://github.com/Fmstrat/ownnote isn't really maintained anymore I'm looking for a new notes editor for nextcloud. Unfortunately, I'm a big fan of WYSIWYG editors - thats whats stopping me to switch to e.g. notes for nextcloud.

I could live with a "normal" md editor in the web (since I'm only editing offline anyways) but under Win I would really love to use a WYSIWYG editor. Had a look at your code but my c++ is a bit rusty :-) So before digging deeper: Do you see any chance to be able to replace the current editor with another one? (not even sure if there currently is such a thing as a WYSIWYG editor in c++...).

Thanks,
Thomas

Highlight line break

Here an image:
Example

On the left side is qmarkdowntextedit, on the right side the default editor of Linux mint(xed).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.