Jwrede / Anki-KaTeX-Markdown

Creates a new Basic and a new Cloze Note Type that support Markdown and KaTeX
74 stars 5 forks source link

Code formatting is adding a new line #41

Open edap opened 1 year ago

edap commented 1 year ago

Hello, first of all, thanks for developing this addon, it is really useful to me.

I have a problem when inserting code blocks. If I copy a text formatted for markdown from Visual Studio Code to Anki (with type katex and markdown basic), the indentation is stripped off.

If I copy the text from Visual Studio Code to another editor, like Gedit, and then to Anki, the indentation is correct, but a new line is inserted after every line. So this markdown text:

```rust
use std::thread;
use std::time::Duration;

fn main() {
    let handle = thread::spawn(|| {
        for i in 1..10 {
            println!("hi number {i} from the spawned thread!");
            thread::sleep(Duration::from_millis(1));
        }
    });

    handle.join().unwrap();

    for i in 1..5 {
        println!("hi number {i} from the main thread!");
        thread::sleep(Duration::from_millis(1));
    }
}

Becomes:

use std::thread;

use std::time::Duration;

fn main() {

thread::spawn(|| {

    for i in 1..10 {

        println!("hi number {i} from the spawned thread!");

        thread::sleep(Duration::from_millis(1));

    }

});

for i in 1..5 {

    println!("hi number {i} from the main thread!");

    thread::sleep(Duration::from_millis(1));

}

}