debanjandhar12 / logseq-anki-sync

An logseq to anki syncing plugin with superpowers - image occlusion, card direction, incremental cards, and a lot more.
GNU Affero General Public License v3.0
421 stars 30 forks source link

Code blocks should escape all characters #269

Open Amparose opened 2 months ago

Amparose commented 2 months ago

It seems that some special characters (< > &) that this plugin uses aren't being escaped when in a code fenced block.

Add a code fence block to Logseq with these commonly-used characters (ignore the backslashes to escape backticks):

\```js
< > &
\```

The resulting card in Anki ends up as:

&lt; &gt; &amp;

When it should be:

< > &
Resia1 commented 2 months ago

I'm experiencing a similar issue. It seems to be a particular problem with HTML codeblocks. 😭

If I write the html code below in logseq and sync it to Anki, I get the following

<!DOCTYPE html>
<title>Title</title>

<style>body {width: 500px;}</style>

<script type="application/javascript">
  function $init() {return true;}
</script>

<body>
  <p checked class="title" id='title'>Title</p>
  <!-- here goes the rest of the page -->
</body>

image image

I think this is very much related to the issue you're describing.

Resia1 commented 1 month ago

Hi, I've been studying SQL recently and found a similar error.

I am using version v6.1.0.

-

image

Other than SQL, <, >, & are properly represented in other languages.

I'm on 6.1.0, so javascript is also represented correctly.

javascript image