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

underscore (italics) markdown in preview disrupted by cursor logic #167

Closed
clem4962 opened this issue Dec 3, 2024 · 5 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@clem4962
Copy link

clem4962 commented Dec 3, 2024

Add a fresh paragraph to a page, highlight it, then hit the Italics button, then Preview. The italics will not render (it will display plain text with underscores):

_my new text_

There are other variations, such as leaving the cursor on a subsequent blank line etc, but all occur because the cursor logic in renderer.py has modified the line to this:

_my new text_CuRsoRm4g1cW0Rd

which the markdown rendering no longer recognises.

(Using asterisks instead of underscores works fine.)

Possibly this might be fixed by changing the magic cursor word to an html comment, eg <!--CuRsoRm4g1cW0Rd--> ? This worked in my somewhat limited testing.

OTOH, I'm not too sure what purpose the cursor processing actually serves. Is it required in some other use case other than preview?

@redimp redimp self-assigned this Dec 3, 2024
@redimp redimp added the bug Something isn't working label Dec 3, 2024
@redimp
Copy link
Owner

redimp commented Dec 3, 2024

Hey @clem4962, I can reproduce this bug.

You are right, the CuRsoRm4g1cW0Rd is used for previewing the location of the page where you placed your cursor, so that you dont have to scroll and search for what you've just edited.

If you mark a paragraph, hit Italics as you described and place the cursor below, before you hit Preview it's rendered correctly.

@redimp redimp closed this as completed in c364efb Jan 23, 2025
@redimp
Copy link
Owner

redimp commented Jan 23, 2025

Released in v2.9.0.

@rhartmann
Copy link
Contributor

Hi @redimp, you might want to have another look into this.

I noticed <!-- CuRsoRm4g1cW0Rd --> showing up in a code block in preview mode. It seems to misbehave when the cursor is in a code block. When you switch to preview, the magic word prints as part of the code block (and the preview does not scroll to the position).

This also happens if the cursor is on a directly adjacent line (line directly before or after the code block), even if that line is not blank. No matter whether the code block uses single ticks, triple ticks or four-space indention.

Exceptions I found so far:

  • Code blocks with triple ticks and a syntax specifier such as python and/or line numbers: The magic word does not show up but the indentation of the code or the line numbers is messed up, depending on where the cursor is; this one is particularly weird: the mess is not necessarily near the cursor position
  • Non-blank line directly before indented code blocks: the code block becomes regular text
  • Non-blank line directly after indented code block: magic word won't show up in the code block; interestingly now also if the cursor is on the last line of the code block itself
    • Exception to the exception: If an indented code block is directly followed by a 1-tick or 3-tick code block 😄

@redimp redimp reopened this Jan 29, 2025
@redimp
Copy link
Owner

redimp commented Jan 30, 2025

Thx @rhartmann for the detailed analysis ... I didn't think through that adding the html comment tags would of course make other parsers interact with it.

@redimp redimp closed this as completed in f930d44 Jan 31, 2025
@redimp
Copy link
Owner

redimp commented Jan 31, 2025

Fix released in v2.9.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants