How to represent spaces in MigraDoc - pdfsharp

For a project i was working on i was required to produce a PDF of whats displayed on screen using Migradoc. I encountered an issue where preceding spaces where getting removed from the text.

That question was answered one week ago:
MigraDoc: How do I add preceding spaces to a String?
The way to enter non-breaking spaces depends on the programming language and the editor in use.

To get around this i had to convert the spaces to use the following tag
 

Related

Assign <wbr> to specific characters within CSS style

I am new to CSS and web development in general. Hopefully there is a way to accomplish what I am trying to do. What I am trying to do is simple to explain, but I need to give some background info first, sorry for the length of the post.
I have created a webpage that is in the Tibetan language. Tibetan does not have spaces between words, it only has a character called a "tsheg" (་ - U+0F0B) that is used to separate every syllable. It also has a mark called a "shey" (། - U+0F0D) that comes at the end of phrases and clauses and sentences. Although sometimes it is doubled, after a shey is generally a space before the next line of text. When typing in Tibetan this space is represented not as a normal space (U+0020) but instead U+00A0, however when it comes to browsers and HTML/coding in general these two seem to behave the same.
In any Tibetan writing, the ideal aesthetic is for full justification. Traditionally there would be slight spaces placed between the tsheg marks and the shey marks to achieve a perfectly flush left and right alignment. (The exception would be the last line of a text, or a paragraph in contemporary formatting, does not need to be justified). It is acceptable for lines to break mid-word or mid-sentence, but never mid syllable. So the last character on any line is going to be either a tsheg or a shey. It is also not acceptable to start a line with a shey. In the last few years this has been easy to achieve for desktop publishing using MS Word, using "Thai Justification." However that option is not available even in other Office products, never mind outside of the Office environment. Other work-arounds have been to add invisible width characters after every tsheg and shey, allowing for wrapping at any point.
Now comes the question and difficulty. I am using distributed justification, and that seems to be the best option. It does not break syllables up, which is important. But it only wants to break at those spaces after shey marks, and it breaks elsewhere when there is a long string of text without a space, but if there is a space then it breaks there, sometimes stretch one or two syllables across an entire line, which is obviously not ideal.
Now, when coding the HTML of the text I can use the same work-around that is used for desktop publishing pre "Thai justification," I can add a <wbr> after every single tsheg, and this will not be visible to the end user and should allow cleaner breaking. However, there are two problems with this. But inserting that many <wbr> characters I am essentially doubling, or close to doubling, my character count, which can make the page take twice as long to load, even if half of those characters are invisible. However, more important is that it disrupts search functionality. Although you may see the word that has the syllables "AB" for instance, if you tried searching for AB you wouldn't find it, because the HTML sees "AB". And being able to search is kind of critical. Enough so that an ugly formatting is preferable to losing the ability to search and to be indexed properly. Obviously, since I need the site to be responsive and I do not know what size screens will be used I cannot have forced line breaks, either, another trick used when publishing.
So, finally, my question. Is there a way I can define a style or function or some sort of element that automatically associates a certain character--in my case the tsheg character--as having a <wbr> command after it without actually needing to input that command into my HTML? So when the text is justified it treats every tsheg as a <wbr>? I have a class .Tibetan in my stylesheet that defines the font and the justification and so forth, is there some way I can add some code there that achieves what I am looking for?
The one other thing I tried was replacing all of the spaces with which gave a beautiful justified appearance but it also caused the browser to disregard the tsheg marks entirely and it allowed for the cutting in half of syllables.
If you want to see an example of what I am talking about you can visit this page of my site: http://publishing.simplebuddhistmonk.net/index.php/downloads/critical-editions/ and next to the word "English" click the Tibetan characters and that will bring up a paragraph of prose, or you can look here: http://publishing.simplebuddhistmonk.net/index.php/downloads/tibetan/essence-of-dispelling-errors-tib/ (though the formatting on that latter page is less egregious than the former, at least on my screen).
EDIT It looks like the solution this person used might be able to be adapted for my use: Dynamically add <wbr> tag before punctuation however I do not actually understand what I would need to add, and where, to make that work for me. Anyone think that might apply to this scenario? And if so, what code would I add where?
NEW EDIT So, I think the problem might be with the search function that comes from my WordPRess theme. I used my workaround as mentioned above, adding the tag after every tsheg, on this page: http://publishing.simplebuddhistmonk.net/index.php/downloads/tibetan/essence-of-dispelling-errors-tib/ and as you can see, it displays perfectly. But if you search for any phrase from that page using the search function that is up in my header, it will not find it. If you do a Ctrl+F and search on the page, though it will find it. Even if you copy the text from the page and paste it into the search box it still does not find it. Copy the text into a word editor doesn't reveal any hidden or invisible characters. However, if you search for a term from this page http://publishing.simplebuddhistmonk.net/index.php/downloads/tibetan/beautiful-garland-ten-innermost-jewels-tib/ which I have not added the tags to, you will see that it finds it no problem.
So, that leads me to believe the error is in the search function. Any experience with this? Because search is important but I can quite possibly find alternative earch widgets to replace the one that comes with the theme. What is most important though is if you search for a line of text on Google it needs to be found. My site has not been indexed fully by any search engine so I cannot yet confirm if this does or does not affect them.
So.... At this point I wil take any advice I can get. Any advice regarding the original question (is there a way to tell the style guide "if your are displaying X then treat it like X" ) or any idea about this issue with the search functionality, and how the tag may or may not affect search, both from within the site and also from search engines.

writing right-to-left sentences in ASP.NET labels and text boxes

how can I CORRECTLY display English and non-English (Persian, Farsi language, middle eastern) words in ASP.NET labels or text boxes? it is OK when I type or display only English or only non-English (Farsi) words, but when I type or display a sentence which contains both of them, everything gets out of order, my sentences are misplaced, punctuation symbols are wrongly inserted, in another word it is difficult to understand what is written.
When I'm going to use Office Word for writing Persian documents (which may contain English words), first I set paragraph direction as Right-To-Left, is it possible to do something similar in ASP.NET? of course I set following style in my ASPX files and now my texts boxes start writing from right to left but it does nothing for solving the aforementioned problem!
Style="text-align: right"
how can I solve it? thanks
You need to use the correct value for the dir attribute - in this case, rtl:
dir="rtl"
This needs to be done in the containing element.
There are also CSS properties you can set, as discussed in this document (thanks #ANeves).

How to get plain html from textarea

I want to get data from textbox in plain HTML i.e if i write Hello World then it should return
Hello World
. I dont want to use HtmlEditor can i get plain html using textArea?
http://www.dotnetperls.com/encode-html-string
If you really need the you can always string-replace spaces
You're probably going to need to transform the text manually (with string.Replace() or something similar) to accomplish this. Consider, for example, the "enter" and "space" tags you're looking for. If the user enters this as plain text (such as in a TextArea):
Hello World
Another line
Then that's precisely the value that's in the TextArea. The user didn't enter this:
Hello World<br />Another line
That's an entirely different string value. A WYSIWYG HTML editing control (and there are many for ASP.NET) would do some of the text transforms for you. At least it would probably convert the carriage returns into break tags for you.
But I doubt it would convert every space into a non-breaking space, since that's a very different value than what was entered. You'll likely have to do that yourself. (And be aware that converting all spaces into non-breaking spaces might not render the output like you expect. Look forward to a lot of horizontal scrolling.)
HTML isn't a translation of text into another medium, it's markup that's included in the text. Both of my examples above are perfectly valid HTML. One of them just doesn't include any markup tags.

Wordpress FLIR (Facelift Image Replacement) plugin clipping off end of text

I'm using the FLIR for Wordpress plugin (v0.8.9.2) with FancyFonts enabled. I'm running Wordpress 3.1. The problem I'm having is that it appears the plugin is cutting off a couple pixels off of the end of some of the text that it generates. It doesn't do it for all text, but where it happens, it happens consistently.
Here are some examples:
In my search for a solution, I've found a number of people with this issue, but never any solutions. Any ideas would be greatly appreciated. Thank you!
I know this was asked quite a while ago, but while researching the problem I came up with a solution. Every page I'd read on this was a bunch of people bickering about the source of the problem and reproducing it, but nobody provided a solution.
This doesn't fix the problem at its source, but it works perfectly. Open generate.php
Find:
$FLIR['text'] = html_entity_decode_utf8($FLIR['text_encoded']);
Replace With:
$FLIR['text'] = html_entity_decode_utf8($FLIR['text_encoded']) . " ";
All it does is force a space after every input string. The space is rendered along with the rest of the text, but is cut off (so you don't see it). This doesn't add the space to the actual HTML, so if it's rendered using a text-browser, rendered without FLIR, or accessed by a crawler (for SEO) the additional space will not show. It is only inserted into the PHP function which creates the image.
After searching for about an hour, I thought it would be helpful for there to be at least one fix on Google.
EDIT: This doesn't work for text with letter-spacing. I was about to give up and just not use letter spacing, but I found this this worked (again, not solving the problem at the source but fixing the visual issue in the same way). Open inc-flir.php
Find:
return rtrim($ret);
Replace With:
return $spacetxt . rtrim($ret) . $spacetxt;
This inserts the same amount of space on either side of the image as are in-between each character. I added the spaces to both the left and right side so that the text will be mostly centered.
EDIT AGAIN:
Oh yeah! And don't forget clean both FLIR's cache and your browser's cache or you wont see the updates!
Thanks. i would use font-face to fix the problem, but BOTH answers (on those php´s) made the trick.
The problem was with stable version 1.2, then I found v2.0beta3 out there. PROBLEM WAS WITH CHROME , by the way...
Oh... i you use mode=´wrap´, you´ll probably still have the problem with chopped text at the last part of the paragraph. In a phrase, the width of an H1 cuts off the last part of the letter, so I added a non breaking space directly to the problematic word.
Example B&A:
<h3>Nuestra visión de la Seguridad Informática </h3>
then...
<h3>Nuestra visión de la Seguridad Informática </h3>
Voilá!
So, three patches to fix an OLD php font plugin... and your help was gold for me. Thanks!

How to force a monospaced font to render in Facebook?

I made a program that generates ASCII art from an image. I want users to be able to copy and paste that ASCII art to their wall and have it display properly.
Problem:
Facebook doesn't use a monospace font.
Does anyone have any ideas on a workaround?
𝚈𝚘𝚞 𝚌𝚊𝚗 𝚝𝚛𝚢 𝙼𝚊𝚝𝚑 𝙼𝚘𝚗𝚘𝚜𝚙𝚊𝚌𝚎 𝚘𝚗 𝚚𝚊𝚣.𝚠𝚝𝚏
But it must be done one line at a time unfortunately. But it is unicode so you can prepare it first in a text editor and copy/paste into facebook.
Basically the question is: can you post a formatted text on the wall? The answer is no, sorry. Facebook currently doesn't support any html, markdown-like syntax, or html entities in their wall posts, only plain text.
have you tried the following html tags (they may get filtered, but may not)
<pre> my code </pre>
<tt> my code </tt>
I get that this is a 9 year old question, but I was looking for something similar, saw http://qaz.wtf/u/ in the comments, and went digging.
Found this:https://github.com/cpsdqs/monotext
It's a single-file script (js) that appears to accomplish the same thing:
𝙳𝚘𝚐𝚎 𝚏𝚘𝚛 𝚕𝚒𝚏𝚎
𝚂𝚝𝚘𝚕 𝚆𝚘𝚆 𝚂𝚒𝚏𝚎
I'd imagine you could (as I plan to) use it as a base to convert something faster than one line at a time. Hope it helps someone!
monospace: Try a backtick ``before and after your text.`
italic: _italic_
bold: *bold*

Resources