Re: Cell["\<\ ... \>", ... ; TextData[...]
- To: mathgroup at smc.vnet.net
- Subject: [mg114790] Re: Cell["\<\ ... \>", ... ; TextData[...]
- From: Derek Yates <yatesd at me.com>
- Date: Fri, 17 Dec 2010 03:28:50 -0500 (EST)
- References: <email@example.com>
I did find a reference to this in some of the legacy Mathematica (version 5.2) documentation. 2.8.7 Advanced Topic: Newlines and Tabs in Strings http://reference.wolfram.com/legacy/v5_2/book/section-2.8.7 John Fultz mentioned that the kernel simply ignores the delimiters, however I noticed that the kernel's interpretation of a raw string is still affected. As he mentioned, it is essentially legacy, as the front-end no longer inserts raw strings into cells the way the 5.2 documentation mentions, but you can still see the behaviour if you try editing a Cell expression (Cell > Show Expression) as follows: type a few characters (I entered qwerty) in an empty cell in the front- end, and then do Cell > Show Expression, and you will see something like this: Cell[BoxData["qwerty"], "Input"] replace it with: Cell["qw erty","Input"] where you have put the new line in using the Return key. Now when you revert the Show Expression, you will see qw erty in the cell. If you edit the cell expression again so that it is Cell["\<qw erty\>","Input"] Then you will see qw erty in the cell. Here is an excerpt from the documentation. Note that the example they show does not work in new versions of Mathematica, but my example above showed how to create it artificially. "When you enter a long string in Mathematica, it is often convenient to break your input across several lines. Mathematica will by default ignore such breaks, so that if you subsequently output the string, it can then be broken in whatever way is appropriate. Mathematica ignores the line break and any tabs that follow it. In:= "A string on two lines." Out= A string on two lines There is no newline in the string. In:= InputForm[%] Out//InputForm= "A string on two lines." Input forms for strings: "text" line breaks in text are ignored "\<text\>" line breaks in text are stored explicitly as \n Here Mathematica keeps the newline In:= "\<A string on two lines.\>" Out= A string on two lines In InputForm, the newline is shown as an explicit \n. In:= InputForm[%] Out//InputForm= "a string on\ntwo lines."