Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Markdown highlighting format #1894

Open
HeyMyian opened this issue May 23, 2024 · 6 comments
Open

Add Markdown highlighting format #1894

HeyMyian opened this issue May 23, 2024 · 6 comments
Labels
editor Component: Editor enhancement Request: New feature or improvement

Comments

@HeyMyian
Copy link
Contributor

Is there a chance we could get the highlight background color as it is displayed in the document viewer also in the document editor? I next to never use the document viewer, but having a more eye-catching highlight color for marked stuff could be useful in the editor too. Unsure if technically possible.

1) Current viewer
2) Current editor
3) Proposed editor
2024-05-24___00_00_31

@HeyMyian HeyMyian added the enhancement Request: New feature or improvement label May 23, 2024
@vkbo
Copy link
Owner

vkbo commented May 23, 2024

Unfortunately, shortcodes are not parsed by the syntax highlighter, other than the code tag itself. Handling this would require nested parsing, since these are basically free form. The only way to really do it is to add Markdown-like highlighting with == wrappers or something like that.

@HeyMyian
Copy link
Contributor Author

What are your thoughts on adding additional markdown for this? The visual effect would be consistent with the other markdown vs. shortcodes, where only the markdown variant changes how the text renders in the editor.

I think it would be a nice-to-have feature, but perhaps there are some arguments against adding more and more markdown.

@vkbo
Copy link
Owner

vkbo commented May 25, 2024

I think it would be a nice-to-have feature, but perhaps there are some arguments against adding more and more markdown.

Well, yes. Each markdown addition needs an independent rule which is processed on a text paragraph on every single key press you make. The nice thing about shortcodes is that they are all included in a single rule. so adding more comes at a minimal cost.

That said, there's still room before keypresses become laggy (the spell checker also runs on the whole paragraph on each keypress) and we're not really hitting any issues yet that I know of. Python is relatively slow, but moder computers are also very fast. But I've noticed typing lag in other Python-based apps because there is too much processing going on when you type, and that is annoying. Especially for a writing app.

Anyway, I can add the == notation. The main reason I never did is that = is a more common symbol to actually use than the other markdown symbols _, * and ~, so it may misfire more often. I'll need to add a \= escape as well.

@vkbo
Copy link
Owner

vkbo commented May 25, 2024

If it wasn't for the fact that novelWriter runs on Python, I would probably write a parser that didn't rely on regular expressions. That way I could process character by character and flag formatting on and off as needed. I've written parser like this before in machine code compiled languages, and they are plenty fast enough, and have the ability to accept any rule logic I want.

I fear this will be too slow on Python, but I may give it another try at some point. Especially if there are too many highlight rules. The non-text blocks (headings, keywords, comments, footnotes) already uses this style of parsing rather than regex.

@HeyMyian
Copy link
Contributor Author

HeyMyian commented May 25, 2024

That said, there's still room before keypresses become laggy (the spell checker also runs on the whole paragraph on each keypress) and we're not really hitting any issues yet that I know of.

It looks to me like we're far off reaching any performance issues. I have this old 2011 Intel Atom N450 netbook lying around where I recently installed antiX Linux on to see if I could still use it for writing (I could)(but I don't). This thing is really slow and can barely handle a web browser. I see no issues at all though typing in novelWriter; keystrokes are crisp.

Out of curiosity, what are those Python apps you've seen where typing is laggy?

@vkbo vkbo changed the title "Highlight" syntax highlighting also in editor? Add Markdown highlighting format Jun 2, 2024
@vkbo
Copy link
Owner

vkbo commented Jun 2, 2024

I renamed this to "Add Markdown highlighting format" instead, as that's the solution to add actual formatting to the editor. I'll use the syntax discussed before, which was a non-standard Markdown format using ==highlighted text==. I really don't like it, but anyway ...

See: https://stackoverflow.com/a/63851626

@vkbo vkbo added the editor Component: Editor label Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor Component: Editor enhancement Request: New feature or improvement
Projects
None yet
Development

No branches or pull requests

2 participants