Indenting plain text in a .text.haml file in a rails app - ruby-on-rails-3

In my rails 3.1 app I am working on a text email backup and want it to show up in the email client as text separated into new lines like this:
Lorem ipsum dolor sit amet
Consectetur adipisicing elit
Sed do eiusmod tempor incididunt
Ut labore et d Lorem ipsum dolor sit amet Consectetur adipisicing elit Sed do eiusmod tempor incididunt Ut labore et dolore magna aliquaolore magna aliqua
In my .text.haml file I have tried to use this:
:plain
Lorem ipsum dolor sit amet
Consectetur adipisicing elit
Sed do eiusmod tempor incididunt
Ut labore et dolore magna aliqua
However, when I check it in gmail it appears condensed into one paragraph like this:
Lorem ipsum dolor sit amet Consectetur adipisicing elit Sed do eiusmod tempor incididunt Ut labore et dolore magna aliqua
What can I do to get this to work? When I copy and paste this code into a view file, and view source, it appears as text as I want it in the view source, but gets condensed into one paragraph in the browser. Does this perhaps indicate that gmail is taking the text and formatting it that way and I don't actually have a problem?

I don't have a setup to test this, but I believe you want either :escaped or :preserve (probably the latter).
If those don't work, see http://haml.info/docs/yardoc/file.HAML_REFERENCE.html#filters for others (including info on how to create your own).

Related

XSLT value-of not showing new paragraphs

I have problem of getting text from xml in original state.
When I use <xsl:value-of select="desc" /> I get full text, but merged, without spaces between paragraphs.
I have data like this:
<desc><![CDATA[Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat]]>
</desc>
And, as output I get this:
This is not good for me, because I want output text to be same as inside CDATA[], with blank lines between paragraphs.
I tried with using preserved spaces.
I'm using Saxon xslt processor
Using fo:block linefeed-treatment="preserve" as your container element might suffice, see https://www.w3.org/TR/xsl11/#linefeed-treatment.

How to break long strings in XAML source code?

Silly question, but a Google/SO search didn't bring me the desired result. I have a very long string like this:
<Label Text="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
VerticalOptions="Start"
HorizontalOptions="StartAndExpand" />
How can I break up the Text attribute on multiple lines to have a better code formatting? Is there an option or not?
If I enter a new line and add some spaces (for indenting), the label also contains the spaces ...
It's funny I've not really thought about this one before but it's a great question! I always just kept word wrap on the editor so I never noticed...
That looks like xamarin? If so you might add that tag since wpf etc would be <Label Content="blah"/> format so it confused me at first.
However, in WPF, Silverlight, UWP, etc, you can just do this and skip the measuring of the ContentPresenter to display as a whole line and wrap accordingly when rendered;
<Label>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore
magna aliquyam erat, sed diam voluptua. At vero eos et accusam
et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem
ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam
erat, sed diam voluptua. At vero eos et accusam et justo duo
dolores et ea rebum. Stet clita kasd gubergren, no sea takimata
sanctus est Lorem ipsum dolor sit amet.
</Label>
Unfortunately I don't use xamarin currently so if it turns out to be different just me know and I'll del this answer but hope it helps.
This problem has nothing to do with Xamarin. I use WPF and I had the same problem.
The problem does not only occur in a Label, it is in all Controls. Every Control has a Text property.
The cause is that you use the Text property to assign your text, using Text="..."
The solution, as Chris W suggested (maybe without realizing it), is to move the assignment of the Text property to the part between the opening tag and the closing tag; so to the part between <...> and </...>
So Instead of
<TextBox Height="auto" TextWrapping="Wrap"
Text="Lorem ipsum dolor sit amet, consetetur ... (etc.)"/>
Use:
<TextBox Height="auto" TextWrapping="Wrap">
Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore
... (etc.)
<TextBox>
Even the spaces / tabs in front of the text will be replaced by one space.
Note that if you use property assignment, you use string quotes: Text="...";
If you use the part between opening and closing tag, there are no string quotes.
That might be the reason that you can add line breaks in your source code.

inline tag in haml

In html, you can do something like this
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eget
aliquet odio. Fusce id quam eu augue sollicitudin imperdiet eu ac eros.
<em>Etiam nec nisi lorem</em>, ac venenatis ipsum. In sollicitudin,
lectus eget varius tincidunt, felis sapien porta eros, non
pellentesque dui quam vitae tellus.
</p>
It is nice, because the paragraph of text still looks like a paragraph in the markup. In haml, it looks like this
%p
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eget
aliquet odio. Fusce id quam eu augue sollicitudin imperdiet eu ac eros.
%em Etiam nec nisi lorem
, ac venenatis ipsum. In sollicitudin,
lectus eget varius tincidunt, felis sapien porta eros, non
pellentesque dui quam vitae tellus.
Is there any way to totally inline a tag in haml?
Haml excels for structural markup, but it's not really intended for inline markup. Read: Haml Sucks for Content. Just put your inline tags as HTML:
.content
%p
Lorem ipsum <em>dolor</em> sit amet.
Or else use a filter:
.content
:markdown
Lorem ipsum *dolor* sit amet.
I know this is old. But figured I'd post this in case anyone lands here. You can also do this sort of thing in haml (And maybe more what the OP was looking for?).
%p Here is some text I want to #{content_tag(:em, "emphasize!")}, and here the word #{content_tag(:strong, "BOLD")} is in bold. and #{link_to("click here", "url")} for a link.
Useful for those situations where doing it on multiple lines adds spaces you don't want
I.E. When you have a link at the end of a sentence, and don't want that stupid space between the link and the period. (or like in the OP's example, there would be a space between the and the comma.
Just don't get carried away like i did in the example :)
You can inline HTML in any HAML doing
%p!= "Lorem ipsum <em>dolor</em> sit amet"
The != operator means that whatever the right side returns it will be outputted.
As a hybrid of these nice answers by others, I think you can define a Helper method in your application_helper.rb for some inline markups you'd frequently use. You don't need to mix HTML with HAML, nor do you have to type much.
In your helper;
def em(text)
content_tag(:em, text)
end
#def em(text)
# "<em>#{text}</em>".html_safe
#end
In your haml;
%p
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eget
aliquet odio. Fusce id quam eu augue sollicitudin imperdiet eu ac eros.
#{em 'Etiam nec nisi lorem'}, ac venenatis ipsum. In sollicitudin,
lectus eget varius tincidunt, felis sapien porta eros, non
pellentesque dui quam vitae tellus.
It's all about indentation:
%p
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eget aliquet odio. Fusce id quam eu augue sollicitudin imperdiet eu ac eros.
%em
Etiam nec nisi lorem, ac venenatis ipsum. In sollicitudin, lectus eget varius tincidunt, felis sapien porta eros, non pellentesque dui quam vitae tellus.

How to set left margin in PowerPoint textbox using VSTO

I'm taking some user data and adding it to a PowerPoint presentation using VSTO. To get the formatting to look right, though I need to be able to set the left margin of some of the text in the textbox. There will be an initial block of text followed by another, indented block. For example (underlines added to emphasize spacing):
Lorem ipsum dolor sit amet,
consectetur adipiscing elit. Sed
vestibulum elementum neque id rhoncus.
In fermentum eros nec dolor lobortis
sit amet fermentum est consequat.
Curabitur eleifend nunc eu odio
vehicula ut elementum erat aliquam. Ut
adipiscing ipsum sit amet leo pulvinar
hendrerit. Cum sociis natoque
penatibus et magnis dis parturient
montes, nascetur ridiculus mus. Nulla
non neque in velit lacinia tempor et a
lacus.
___________Cras auctor bibendum urna, a facilisis lacus
lacinia non.
___________Nullam at quam a mauris consequat vulputate sed eu
sapien.
___________Fusce sed urna nulla, ut sagittis lacus. Pellentesque
tortor
___________augue, scelerisque at aliquet a, pretium ac
ipsum.
I can get this effect by setting Shape.TextFrame.TextRange.IndentLevel = 2 on the lower block of text. However, I cannot figure out how to programmatically set the value of the margin. Does anyone know how to do this?
This is taken care of via Shape.TextFrame.MarginRight and Shape.TextFrame.MarginLeft and the like.

create pdf with long lines, fit to pagewidth without wordwrap

i'd like to create a large pdf (not typical page size) with long lines, max ~1000 characters / line, where the page size and font are such that no lines need to wrap.
the intention is not for the text in this document to be readable when the full page is viewed on any reasonably-sized monitor -- instead the reader can zoom to individual portions of interest within the document.
i attempted this with a small font in latex, but no success.
any help is greatly appreciated. thanks.
This works with pdflatex:
\documentclass{article}
\pdfpagewidth 200cm
\pdfpageheight 200cm
\textwidth 190cm
\def\lorem{Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.}
\begin{document}
\lorem \lorem \lorem \lorem
\end{document}