How to display user text automatically according to its natural direction - css

I want to support the display of user inputted text in Unicode according to its general direction instead of the default left-to-right direction. For example, in the Arabic text below, the English word (4th) appears to be split apart:
اُردو کا بعض اوقات ہندی کے ساتھ موازنہ کیا جاتا ہے. اُردو اور ہندی میں بُنیادی فرق یہ ہے کہ اُردو نستعلیق رسم الخط میں لکھی جاتی ہے اور عربی و فارسی الفاظ استعمال کرتی ہے. جبکہ ہندی دیوناگری رسم الخط میں لکھی جاتی ہے اور سنسکرت الفاظ زیادہ استعمال کرتی ہے. کچھ ماہرینِ لسانیات اُردو اور ہندی کو ایک ہی زبان کی دو معیاری صورتیں گردانتے ہیں. تاہم، دوسرے اِن کو معاش اللسانی تفرّقات کی بنیاد پر الگ سمجھتے ہیں۔ بلکہ حقیقت یہ ہے کہ ہندی ، اُردو سے نکلی۔اسی طرح اگر اردو اور ھندی زبان کو ایک سمجھا جاۓ تو یہ دنیا کی چوتھی (4th) بڑی زبان ہے۔
Is there a CSS or HTML method that automatically considers the natural direction of the text flow? I read this article from W3C which discusses the way to set text direction, but did not find any solution that does so automatically.

The fact that there is a way to automatically detect the natural direction of text flow is what is causing you trouble: the bidirectional algorithm is not perfect. Sometimes you need to give it some extra hints, as explained in Unicode controls vs. markup for bidi support.
The Unicode bidirectional algorithm determines the directionality of text on the basis of the directional properties of each character. Occasionally the algorithm needs a little help to determine the flow of objects in the text that mixes Arabic or Hebrew characters with those of other scripts. In other cases you might want to override the effect of the bidirectional algorithm altogether.
You can fix this manually by adding U+202A ʟᴇғᴛ-ᴛᴏ-ʀɪɢʜᴛ ᴇᴍʙᴇᴅᴅɪɴɢ and U+202C ᴘᴏᴘ ᴅɪʀᴇᴄᴛɪᴏɴᴀʟ ғᴏʀᴍᴀᴛᴛɪɴɢ characters to the text, as I did below:
اُردو کا بعض اوقات ہندی کے ساتھ موازنہ کیا جاتا ہے. اُردو اور ہندی میں بُنیادی فرق یہ ہے کہ اُردو نستعلیق رسم الخط میں لکھی جاتی ہے اور عربی و فارسی الفاظ استعمال کرتی ہے. جبکہ ہندی دیوناگری رسم الخط میں لکھی جاتی ہے اور سنسکرت الفاظ زیادہ استعمال کرتی ہے. کچھ ماہرینِ لسانیات اُردو اور ہندی کو ایک ہی زبان کی دو معیاری صورتیں گردانتے ہیں. تاہم، دوسرے اِن کو معاش اللسانی تفرّقات کی بنیاد پر الگ سمجھتے ہیں۔ بلکہ حقیقت یہ ہے کہ ہندی ، اُردو سے نکلی۔اسی طرح اگر اردو اور ھندی زبان کو ایک سمجھا جاۓ تو یہ دنیا کی چوتھی‪ (4th) ‬بڑی زبان ہے۔
...‪(4th)‬...
You can also use the <bdi> element in HTML5, or a <span> in HTML4.
...<bdi dir="ltr">(4th)</bdi>...
...<span dir="ltr">(4th)</span>...
For more info about the bidirectional algorithm see What you need to know about the bidi algorithm and inline markup.
If this text comes from the user, I guess there is nothing you can do about it. I would just treat it as any other kind of faulty user input; like a typo.

First of all tricky question, but very well documented and an upvote for that.
I tried the same and faced the same issue. I read in an article that you can do this using dojo. The link I am going to give you is mobile based I guess. Hope this will give a start up to you.
https://dojotoolkit.org/reference-guide/1.9/dojox/mobile/bidi.html

Doesn't the browser decide to use rtl of ltr automatically based on the visitors preference? I'm not quite sure of that, but I think it does.
Not really an answer but this might be interesting for you:
In CSS3 there is a new value for the text-align property, namely start. According to the W3C standards this will 'align to the start edge of the line box'. So if the visitors preference is rtl it will align right, and vica-versa.

Related

Not Receiving ShelvesDefinitions in BFM

I am trying to get UTA's inside Bargain Finder Max.
<PriceRequestInformation NegotiatedFaresOnly="false" CurrencyCode="CAD" >.
<TPA_Extensions>
<Priority>
<Price Priority="1"/>
<DirectFlights Priority="2"/>
<Time Priority="3"/>
<Vendor Priority="4"/>
</Priority>
<ShelvesIndicators Mode="NAS"/>
<BrandedFareIndicators SingleBrandedFare="true" MultipleBrandedFares="true"/>
</TPA_Extensions>
</PriceRequestInformation>
While I pass the ShelvesIndicators inside OTA_AirLowFareSearchRQ, when I put it at the end, I get a proper response without ShelvesDefinitions. When I put it in the middle or beginning, I receive an error regarding the node that comes after it.
For example
cvc-complex-type.2.4.a: Invalid content was found starting with element 'BrandedFareIndicators'. One of '{"http://www.opentravel.org/OTA/2003/05":BundledOffers}' is expected.
I tried this on BFM 6.3.0, 6.4.0, and 6.5.0.
Thank you for helping out

Highlight a text Qt [duplicate]

I'm a student programmer currently developing an application for work using Qt4. I am building an equation editor and I'm having issues attempting to highlight a string within my QTextEdit field. I have a function that parses through the QTextEdit string and returns an a start and end integer of where an error is located. My original strategy was to use HTML tags at these two points to highlight the error. Unfortunately there appears to be an issue with html tagging and the equation syntax.
What I think I need is a strategy that relies on Qt's library to set a background color between these two indices. I began looking a QSyntaxHighlighter; however I think that this is more for highlighting using a predefined set of laws and not for just grabbing up anything between a & b and setting the background color. If I can use syntax highlighter please provide me with and example or reference as I have already read through the documentation and didn't find anything.
Thanks for any help in advance!
P.S. Just to emphasize on the html compatibility issues; html becomes problematic due to multiple < and > signs used.
You can use QTextCursor and QTextCharFormat for it:
QTextEdit *edit = new QTextEdit;
...
int begin = ...
int end = ...
...
QTextCharFormat fmt;
fmt.setBackground(Qt::yellow);
QTextCursor cursor(edit->document());
cursor.setPosition(begin, QTextCursor::MoveAnchor);
cursor.setPosition(end, QTextCursor::KeepAnchor);
cursor.setCharFormat(fmt);

What's with the odd font used by spammers? How do they do it?

The screenshot below is from my Gmail spam folder. Notice that some of the email from and subject lines look normal, while many of them appear to use some sort of serif font:
I'm a web developer, and from poking around, there's no CSS font declarations that are causing this to happen. The only hint is that the inspection panel for the "ZippyLoan ." sender shows that the fonts being used are not just Google's typical Roboto, but also "Cambria Math" (despite there being no corresponding "Cambria Math" CSS font declaration):
In fact, it seems that the font definition is somehow built-in to the text, since it even maintains the same appearance in plain-Jane Windows Notepad:
Actually, here, I think it works anywhere... play around with it yourself it you'd like:
𝒁𝒊𝒑𝒑𝒚𝑳𝒐𝒂𝒏 .
𝗜𝗻𝘁𝗿𝗼𝗱𝘂𝗰𝗶𝗻𝗴 𝗟𝗔𝗦𝗜𝗞 𝘀𝘁𝗮𝗿𝘁𝗶𝗻𝗴 𝗮𝘁 $𝟮𝟮𝟬 𝗽𝗲𝗿 𝗲𝘆𝗲!
❤️𝑾𝒆𝒍𝒄𝒐𝒎𝒆 𝒕𝒐 𝒂 𝑪𝒐𝒖𝒓𝒕𝒆𝒔𝒚 $50 𝑪𝑽𝑺/𝒑𝒉𝒂𝒓𝒎𝒂𝒄𝒚® 𝒄𝒉𝒂𝒓𝒈𝒆 𝒄𝒂𝒓𝒅 (𝒀𝒐𝒖𝒓 𝒑𝒓𝒆𝒇𝒆𝒓𝒓𝒆𝒅 𝒄𝒖𝒔𝒕𝒐𝒎𝒆𝒓 𝒏𝒖𝒎𝒃𝒆𝒓 𝒘𝒂𝒔 𝒔𝒆𝒍𝒆𝒄𝒕𝒆𝒅)
Whiskey Tango Foxtrot. O.o
It's not a different font - it's the same font, just using odd code points. For example, the 𝒁 in 𝒁𝒊𝒑𝒑𝒚𝑳𝒐𝒂𝒏 has a code point of 119937:
console.log('𝒁'.codePointAt());
which corresponds to:
𝒁 mathematical bold italic capital z 0352201 119937 0x1D481 𝒁
There are many such odd code points that can be used. It's not ASCII.
In contrast, the standard capital Z has a code point of 90:
console.log('Z'.charCodeAt());

Remove linespacing between tags in css

I am struggling with targeting the current hierachy of tags (CSS newbie). What I am trying to achieve is removal of the linespace/linebreak/whitepace between the references in the following example:
References
Wille, N., Badia, X., Bonsel, G., Burström, K., Cavrini, G., Devlin, N., … Ravens-Sieberer, U. (2010). Development of the EQ-5D-Y: A child-friendly version of the EQ-5D. Quality of Life Research, 19(6), 875–886. doi:10.1007/s11136-010-9648-y
Ravens-Sieberer, U., Wille, N., Badia, X., Bonsel, G., Burström, K., Cavrini, G., … Greiner, W. (2010). Feasibility, reliability, and validity of the EQ-5D-Y: Results from a multinational study. Quality of Life Research, 19(6), 887–897. doi:10.1007/s11136-010-9649-x
I am using markdown with pandoc build this reference list, and this output is what I have to work with:
<h3 id="references" class="unnumbered">
References
</h3>
<div id="refs" class="references">
<div id="ref-WilleDevelopmentEQ5DYchildfriendly2010">
<p>
<ol style="list-style-type: decimal">
<li>Wille, N., Badia, X., Bonsel, G., Burström, K., Cavrini, G., Devlin, N., … Ravens-Sieberer, U. (2010). Development of the EQ-5D-Y: A child-friendly version of the EQ-5D. <em>Quality of Life Research</em>, <em>19</em>(6), 875–886. doi:10.1007/s11136-010-9648-y
</p>
</div>
<div id="ref-Ravens-SiebererFeasibilityreliabilityvalidity2010">
<p>
<ol start="2" style="list-style-type: decimal">
<li>Ravens-Sieberer, U., Wille, N., Badia, X., Bonsel, G., Burström, K., Cavrini, G., … Greiner, W. (2010). Feasibility, reliability, and validity of the EQ-5D-Y: Results from a multinational study. <em>Quality of Life Research</em>, <em>19</em>(6), 887–897. doi:10.1007/s11136-010-9649-x
</p>
</div>
I have tried to give font-size: 0 for the parent div id refs and for the class references and separate font-size for the specific-ids <div id="ref-..."> using wildcard div[id^="ref-"]. I have read a lot of the similar questions, but not been able to solve this. I suspect that I must target the <p>, <ol> or <li> tags within the specific div, but haven' been able to get this to work.
Update:
Thanks for repllies, I see that some clarification is necessary;
1. The structure above is generated automatically, and I would prefer to not edit the HTML manually,
2. The references is the end of a long document where I probably need p tags to be as they are in order for the main text to have certain properties such as font, font size and linespacing.
By default most browsers define a top and bottom margin on <p> tags of 1em (see here). So try to remove that with:
p {
margin-top: 0;
margin-bottom: 0;
}

is there a faster way to perform spell checking in atom?

right now i have to highlight the word that is underlined as misspelled, then double click it, then choose correct spelling, then choose the right word.
i am tired just writing all these steps,
any idea how to get this done faster?
I use vim plugin, so PLUS 1 for any solution that will let me avoid the trackpad/mouse.
By default, the keyboard shortcut cmd-shift-: (ctrl-shift-: on Windows) will quickly bring up a list of corrections when your cursor is on a misspelled word.
With the 1.11.0-beta5 version of Atom, I had to register the spell-check keyboard shortcuts myself.
I put the following in my keymap.cson (Edit -> Keymap):
'.platform-darwin atom-text-editor':
'cmd-:': 'spell-check:correct-misspelling'
'.platform-darwin .corrections atom-text-editor':
'cmd-:': 'core:cancel'
'.platform-win32 atom-text-editor':
'ctrl-:': 'spell-check:correct-misspelling'
'.platform-win32 .corrections atom-text-editor':
'ctrl-:': 'core:cancel'
'.platform-linux atom-text-editor':
'ctrl-:': 'spell-check:correct-misspelling'
'.platform-linux .corrections atom-text-editor':
'ctrl-:': 'core:cancel'
'.corrections atom-text-editor[mini]':
'enter': 'core:confirm'
'tab': 'core:confirm'
Source: https://github.com/atom/spell-check/blob/master/keymaps/spell-check.cson

Resources