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

Extra trailing line gets inserted to code blocks on saving #150

Closed
akjir opened this issue Jul 9, 2019 · 8 comments
Closed

Extra trailing line gets inserted to code blocks on saving #150

akjir opened this issue Jul 9, 2019 · 8 comments
Labels
1. to develop bug Something isn't working feature: formatting Features related to text formatting and node types

Comments

@akjir
Copy link

akjir commented Jul 9, 2019

Describe the bug
After i reopened a saved file, the formatting of the code block is wrong. See screenshots.

To Reproduce
Steps to reproduce the behavior:

  1. create a new file
  2. write Text
  3. combine with code block
  4. save and close
  5. reopen

Expected behavior
The reopened file should have the same formatting like before closing.

Screenshots

File i created:

1

Plain text:

2

After saving and reopening:

3

Client details:

  • Windows 10 Pro 64bit
  • Firefox 67.0.4 64bit
  • Nextcloud 16.0.2
  • Nextcloud Text 1.0.0

Edit: It seems the code block uses the blank line.

@akjir akjir added the bug Something isn't working label Jul 9, 2019
@juliusknorr juliusknorr added this to the 1.0.2 milestone Jul 10, 2019
@juliusknorr juliusknorr modified the milestones: 1.0.2 📜, 1.0.3 Aug 8, 2019
@juliusknorr juliusknorr added 1. to develop feature: formatting Features related to text formatting and node types labels Aug 22, 2019
@juliusknorr juliusknorr modified the milestones: 1.1.1, 18.0.1 Jan 16, 2020
@MorrisJobke MorrisJobke modified the milestones: 18.0.1, Nextcloud 18.0.7 Jul 7, 2020
@rullzer rullzer removed this from the Nextcloud 18.0.12 milestone Dec 10, 2020
@claell claell changed the title Wrong formatting after reopen file Extra trailing line gets inserted to code blocks on saving Mar 13, 2021
@claell
Copy link

claell commented Mar 13, 2021

Might be related or have the same root cause as the plenty issues described in #593, so possibly a duplicate.

@herrdeh
Copy link

herrdeh commented May 2, 2021

Still present with NC 20.0.7, markdown editor (by Robin Appelman) 2.3.3, qownnotes 21.1.3, see here.

@juliusknorr
Copy link
Member

juliusknorr commented Jun 7, 2022

Seems to happen only when using code blocks in lists, especially if the last line with the code block separator is indented:

	test('failure with newline', () => {
		const text = `
### Headline

* Some list item

  \`\`\`
  nano  /var/www/html/config/config.php
  \`\`\``
		// markdown it already shows the issue
		// expect(markdownit.render(text)).toBe("")
		expect(markdownThroughEditor(markdownThroughEditor(text))).toBe(text)
	})

The generated HTML that markdown it generates already contains a newline:

    expect(received).toBe(expected) // Object.is equality

    Expected: ""
    Received: "<h3>Headline</h3>
    <ul>
    <li>
    <p>Some list item</p>
    <pre><code>nano  /var/www/html/config/config.php
    </code></pre>
    </li>
    </ul>
    "

      190 |   \`\`\``
      191 | 		// markdown it already shows the issue
    > 192 | 		expect(markdownit.render(text)).toBe("")
          | 		                                ^
      193 | 		expect(markdownThroughEditor(markdownThroughEditor(text))).toBe(text)
      194 | 	})
      195 |

Not sure yet how to address that best yet though.

@XueSheng-GIT
Copy link

Seems to happen only when using code blocks in lists

Just creating a new file (md), adding a code block with text, saving/closing and re-opening does already trigger this issue (new line). I'm on NC24.0.1.

@Praetorian1410
Copy link

Praetorian1410 commented Jun 7, 2022

@XueSheng-GIT: can confirm this behavior on NC23.0.5.
@juliushaertl: It definitely happens outside of lists too. Sounds dumb, maybe it is, but, couldn't you theoretically add a trim() to the codeblock renderer (bandaidy-solution, may have unintended side-effects, but surely better than one-liner code blocks devolving into unlimited empty lines, right)?

@juliusknorr juliusknorr moved this to 🧭 Planning evaluation (don't pick) in 📝 Office team Jun 7, 2022
@juliusknorr juliusknorr moved this from 🧭 Planning evaluation (don't pick) to 📄 To do (5-20 entries) in 📝 Office team Jun 10, 2022
@the-s-a-m
Copy link

Issues still exist. Please resolve the new line issue in code blocks

@susnux
Copy link
Contributor

susnux commented Jul 24, 2022

Just creating a new file (md), adding a code block with text, saving/closing and re-opening does already trigger this issue (new line). I'm on NC24.0.1.

For me this happens only in the editor, but the markdown source file does not contain the newline.
(on the master branch)

@max-nextcloud
Copy link
Collaborator

I think this is the same issue that was reported in #2344 which was fixed in #3321.
So closing this.

Repository owner moved this from 📄 To do (~10 entries) to ☑️ Done in 📝 Office team Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop bug Something isn't working feature: formatting Features related to text formatting and node types
Projects
Archived in project
Development

No branches or pull requests