0

I'm creating a webapp where I can present a documentation. In my documentations I often have some code snippets so I used prism (https://prismjs.com/) to format the text I enter in a textfield on the admin page.

The Problem is that whenever I enter code in the textfield it makes spaces on the first line like that:

    import { Pipe, PipeTransform } from '@angular/core';  
import { UserService } from '../user.service';

My code looks likt this:

Template:

<pre><code class="language-{{ subdoc.language }}">
        {{ subdoc.code }}            
</code></pre>
Janik Spies
  • 399
  • 7
  • 15
  • 1
    Your HTML is the culprit. Looks like you have space or tab characters right before `{{ subdoc.code }}`, since you're using `
    ` tag, those space/tab characters won't disappear.
    – xxbinxx Jul 01 '19 at 07:31
  • @xxbinxx OMG thanks I'm such a dumb ass xD. Can you write that as a answer so i can close the qestion? – Janik Spies Jul 01 '19 at 07:33
  • If you have your answer, You can now close the question. – xxbinxx Jul 01 '19 at 09:02

1 Answers1

1

Remove the spaces/tab characters before {{ subdoc.code }}

You must be exhausted in coding. Most of the time we think the complicated coding is where something's wrong but in your case it's the HTML.

you sure know how <pre> tag works. Now understand the difference between this

 <pre><code class="language-{{ subdoc.language }}">
        {{ subdoc.code }}            
 </code></pre>

and this

<pre><code class="language-{{ subdoc.language }}">
{{ subdoc.code }}            
</code></pre>

Happy coding ;)

xxbinxx
  • 1,527
  • 11
  • 18