2

Python has triple quoted string which provides free text input. There is no need next line character to define next line. Here is an example;

 hello = """

            This string is bounded by triple double quotes (3 times ").
        Unescaped newlines in the string are retained, though \
        it is still possible\nto use all normal escape sequences.

            Whitespace at the beginning of a line is
        significant.  If you need to include three opening quotes
        you have to escape at least one of them, e.g. \""".

            This string ends in a newline.
        """

So I have a text in HTML which consist of paragraphs. I can do spaces between paragraphs with but I think if javascript has a functionality like Python's triple quoted string, I can generate paragraphs with it.

Is there a alternative free text usage in Javascript like Python has, or can you advice a Javascript library which is doing this?

Thank You!

Ahmet DAL
  • 4,445
  • 9
  • 47
  • 71
  • http://stackoverflow.com/questions/805107/creating-multiline-strings-in-javascript – John Jun 29 '13 at 14:46
  • Triple quoted strings in Python do more than allow free range in defining paragraphs and the link. They also allow for literal transcription of quotation marks. – wheaties Nov 15 '16 at 18:10

1 Answers1

1

When python stores the string like that, it's strictly a list of characters and the triple quotes tell it not to modify anything.

For your html, if I understand right you probably have the slightly different problem that you want to automatically add all the html tags like <p>...</p> in and around your paragraphs? Perhaps a more suitable way to think about doing this would be using a simpler markup language like markdown that you can then convert to fully formed html. Actually, this is how (for instance) stackoverflow posts work - you use the simple markup syntax to write the paragraphs and then they are transformed to html with all the tags in place. This has the advantage that it does more than just the paragraph tags, you can also denote italic text, links, images etc.

I'm not sure what the best way would be for your particular purpose, but here is a javascript markdown library that might be useful. Or if you just want to convert static text you could just use a service like this online converter.

inclement
  • 29,124
  • 4
  • 48
  • 60