qmarkdowntextedit icon indicating copy to clipboard operation
qmarkdowntextedit copied to clipboard

Option to disable sub headers by dashes/equal-signs?

Open nuttyartist opened this issue 2 years ago • 7 comments

Hi, @pbek!

Is there an option to disable the behaviour of --- or === creating sub headlines? Or at least/also an option just to disable the background highlighting of these?

Thanks!

nuttyartist avatar Jul 03 '23 10:07 nuttyartist

Is there an option to disable the behaviour of --- or === creating sub headlines?

Which behaviour are we takling about? 😅

Or at least/also an option just to disable the background highlighting of these?

You could customize the styling completely like QOwnNotes does.

pbek avatar Jul 03 '23 11:07 pbek

Which behaviour are we takling about? 😅

Screen Shot 2023-07-04 at 8 29 21 AM

Is there an option to disable the creation of headers by dashes/equals below text, and to remove the background color on dashes in the second example?

nuttyartist avatar Jul 04 '23 05:07 nuttyartist

Is there an option to disable the creation of headers by dashes/equals below text

No, not really, that's just Markdown. Why would you want to disable that specific syntax of Markdown? You could always just override the one method that applies that highlighting.

and to remove the background color on dashes in the second example?

You can just override the style, like in:

https://github.com/pbek/QOwnNotes/blob/22f7016849cce3d2f01a35c1eb62f9869029a26e/src/widgets/qownnotesmarkdowntextedit.cpp#L184

https://github.com/pbek/QOwnNotes/blob/22f7016849cce3d2f01a35c1eb62f9869029a26e/src/widgets/qownnotesmarkdowntextedit.cpp#L124

pbek avatar Jul 04 '23 07:07 pbek

No, not really, that's just Markdown. Why would you want to disable that specific syntax of Markdown?

Sometimes I (and I believe many others, especially non Markdown users) just want to create a line seperator below some text without formatting the text above it as a header. But I think I'll keep the current behavior, it's just good to know I can ovveride it.

You can just override the style, like in:

Awesome, thanks!

Two more questions:

  1. I want to set the font size for code blocks, so they're smaller than the regular text. So I did something like that:
qreal codeBlockFontSize = fontSize - 2;
    _formats[static_cast<HighlighterState>(HighlighterState::InlineCodeBlock)].setFontPointSize(codeBlockFontSize);
    _formats[static_cast<HighlighterState>(HighlighterState::CodeBlock)].setFontPointSize(codeBlockFontSize);
    _formats[static_cast<HighlighterState>(HighlighterState::CodeBlockComment)].setFontPointSize(codeBlockFontSize);

But the size of some syntex of cpp stays the same while the rest does gets smaller (I set a very small number below just to show the difference):

Screen Shot 2023-07-09 at 10 43 58 AM

  1. Do you think you can add marking/highlighting a piece of text syntax like Bear is doing here with two colons around a piece of text to highlight it?

Screen Shot 2023-07-09 at 10 48 05 AM

nuttyartist avatar Jul 09 '23 07:07 nuttyartist

  1. hard to tell without actually playing around with the code
  2. since that's no Markdown syntax, it's best to implement that somewhere else. QOwnNotes for example has a script function to do that

pbek avatar Jul 09 '23 07:07 pbek

That's our customMarkdownHighlighter.cpp. Did I miss any HighlighterState in my code above?

nuttyartist avatar Jul 09 '23 08:07 nuttyartist

Well, there are lots of code-states:

https://github.com/pbek/qmarkdowntextedit/blob/b2926abe78a98d79290106b17016e99a251f4a8c/markdownhighlighter.h#L82-L177

pbek avatar Jul 09 '23 08:07 pbek