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

314
Visualizações
How can I save text with formatting in JavaScript?

I'm working on a Chrome Extension that has a notes page as a feature. It's not the main feature (meaning it won't be a lot of text) so I don't need to store the notes in a database, so I plan on storing the notes in LocalStorage.

Is there a way I can store this text with formatting such as new lines. For example, I want the following text:

Hello,

world.

to be saved as is, instead of "Hello,world."

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

To format the text, you need to use:

    const formattedText = text.split('\n').join("\\n")

To get the text back, you should use:

    const text = formattedText.split('\\n').join('\n')
about 4 years ago · Santiago Gelvez 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