Skip to content

code block rendering is... less than desireable #4175

@ryanfiller

Description

@ryanfiller

What happened?

In a book, this code bock -

​function​ generateLink(image, width) {
    const​ widthInt = parseInt(width, 10);
    return​ ​'https://'​ + getProvider() + ​'/'​ + image + ​'?width='​ + widthInt;
}

is interpreted as such -

<table class="processedcode">
  <tbody>
    <tr>
      <td class="codeinfo">​<span class="codeprefix">&nbsp;</span></td>
      <td class="codeline">​<strong class="kw">function</strong>​ generateLink(image, width) {</td>
    </tr>
    <tr>
      <td class="codeinfo">​<span class="codeprefix">&nbsp;</span></td>
      <td class="codeline"> ​<strong class="kw">const</strong>​ widthInt = parseInt(width, 10);</td>
    </tr>
    <tr>
      <td class="codeinfo">​<span class="codeprefix">&nbsp;</span></td>
      <td class="codeline"> ​<strong class="kw">return</strong>​ ​<em class="string">'https://'</em>​ + getProvider() +
        ​<em class="string">'/'</em>​ + image + ​<em class="string">'?width='</em>​ + widthInt;</td>
    </tr>
    <tr>
      <td class="codeinfo">​<span class="codeprefix">&nbsp;</span></td>
      <td class="codeline">}</td>
    </tr>
  </tbody>
</table>

Kavita renders without much regard for tab indention and makes reading longer code blocks difficult.
Image

What did you expect?

Other .epub readers seem to handle this more correctly, Calibre's ebook-viewer for example -
Image

Kavita Version Number - If you don't see your version number listed, please update Kavita and see if your issue still persists.

0.8.8 - Stable

Are you accessing kavita through a reverse proxy? If yes, confirm that the issue persists with a direct connection

Yes

What operating system is Kavita being hosted from?

None

If the issue is being seen on Desktop, what OS are you running where you see the issue?

None

If the issue is being seen in the UI, what browsers are you seeing the problem on?

No response

If the issue is being seen on Mobile, what OS are you running where you see the issue?

None

If the issue is being seen on the Mobile UI, what browsers are you seeing the problem on?

No response

Relevant log output

Additional Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageNeeds to be triaged by a developer and assigned a release

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions