Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

228
Visualizações
Is there a way to format TXT files that have been imported to my JS file?

I'm doing some tests on the Fetch function, and I'm using a txt file that should have like linebreaks/highlighted titles.

And when I imported the text and put into a variable, the console.log() showed up as it's supposed to. But using DOM to put into the HTML, the text just ignore everything but letters and spaces.

There's a way to correct that? Or I should try it another way?

Code below (only using the fetch function, the txt file is unnecessary I believe):

let basicText = ''

async function getBasicText(){
    const resposta = await fetch('./textos/pctBasico.txt')
    const texto = await resposta.text();
    let basicText = document.getElementById('pctBasicoDetail')
    basicText.innerHTML = texto
}

getBasicText()

Example:

*BOLD TITLE*
Paragraph
*ITALIC SENTENCE*
*BOLD TITLE*
Another paragraph

But it all goes one thing like:

TITLE PARAGRAPH SENTENCE TITLE PARAGRAPH
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I think you can keep line breaks if you use pre tag. But you couldn't keep format of txt. Then how can you format text as BOLD and ITALIC in .txt file? You should use .md file. In .md, file you can format text using **bold** and *italic*. Then you can use components displaying md files.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda