FooSoft / anki-connect

Anki plugin to expose a remote API for creating flash cards.
https://foosoft.net/projects/anki-connect/
Other
1.94k stars 219 forks source link

markdown /n not being passed as a new line #330

Open LootenPlunder opened 2 years ago

LootenPlunder commented 2 years ago

My main 'back' field is in markdown, and i'll often put a brief list:

-thing x -thing y

which is preserved in the rich text/long text field in Airtable. When these go to anki via addnote I lose the formatting and have to manually add the new lines. I understand that anki accepts HTML. Is there a way easily replace /n with
or something along those lines? Apologies for the half baked code:

`let iC = input.config();

let action = 'addNote'; let params={}; let deckName = 'AIRTABLE'; let modelName = 'uworld'; let fields={}; let note={}; let picture={};

iC.tag.push(iC.dpt.toString());

let version = 6;

if (iC.imgurl.length>0){ var data = { key : 'insertkeyhere', version : 6, action : 'addNote', params:{ note:{ deckName : 'AIRTABLE', modelName : 'uworld', fields:{ Front : iC.cardf, Back : iC.cardb, Objective: iC.obj, Depth: iC.dpt.toString() }, tags: iC.tag , picture: { url: iC.imgurl.toString(), filename: iC.imgname.toString(), fields: [ "Attachments" ] } } } } } else { var data = { key : 'insertkeyhere', version : 6, action : 'addNote', params:{ note:{ deckName : 'AIRTABLE', modelName : 'uworld', fields:{ Front : iC.cardf, Back : iC.cardb, Objective: iC.obj, Depth: iC.dpt }, tags: iC.tag } } } }

console.log(JSON.stringify(data,null,4));

let response = await fetch('url', { method: 'POST', body: JSON.stringify(data,null,4), headers: { 'Content-Type': 'application/json', }, });

console.log(await response.json());`