Lost password? | Help

[ advanced search ]

Tuesday, 20. December 2005, 19:12:58

Ruby support.

The title says it all, really.

Could you add Ruby support to O9? It doesn't seem to be too big a spec, all things (I know of) considered. I could be wrong of course.

Thanks.
SirPavlova

Tuesday, 20. December 2005, 20:38:55

Thanks, I searched the forums for 'ruby' but those didn't turn up. I don't know why...

Not much chance then?

Tuesday, 20. December 2005, 23:13:09

sgunhouse

Volunteer

avatar

Posts: 52996

Flag City, USA

Ruby is not a browser-side language. You've no doubt been reading about "Ruby on rails", to the browser that is just AJAX. That is, Ruby is the server-side of that system, AJAX is the client side.

Opera 8.x does have AJAX support, though it is not full support. Opera 9.0 will have even better support. What the server actually uses doesn't matter.

Wednesday, 21. December 2005, 00:03:48

No, I mean Ruby markup; I didn't think to differentiate. Ruby's a module of XHTML 1.1, markup designed to display ruby characters.

<ruby><rb>Base text</rb><rp>(</rp><rt>Notation</rt><rp>)</rp></ruby> is an example of simple Ruby markup. Check near the bottom of http://en.wikipedia.org/wiki/Ruby_character - use IE to see how it should be rendered.

Here's the W3C rec.: http://www.w3.org/TR/ruby/

Wednesday, 21. December 2005, 07:04:20

sgunhouse

Volunteer

avatar

Posts: 52996

Flag City, USA

If it's part of XHTML 1.1 as the article says, then I'm sure they are working on it.

Thursday, 22. December 2005, 10:15:32

It doesn't seem to be too big a spec, all things (I know of) considered. I could be wrong of course.


Simple ruby markup seems to be easy to implement but its CSS counter part (CSS3 ruby module) is non-trivial. I have no idea whether Ruby will be supported in near future, but when I unwrap my Cristmass gift I plan to write userJS and/or user CSS that renders simple Ruby (complex one will be supported only partly).

Sometimes people use Ruby markup for abbreviations like:

Quoted from http://annevankesteren.nl/2004/05/xhtml-ruby
Ruby can also be used for other things, like abbreviations, which is more interesting for me and probably other people. Consider the following markup:

<ruby>
  <rb>WWW</rb>
  <rt>World Wide Web</rt>
</ruby>


In this case it sounds more reasonable to use abbr element
<abbr title="Wild Wild Web">WWW</abbr>

with CSS
abbr[title]
{display:inline-block;
text-align:center;
vertical-align:middle;
line-height:1.4em;
border-bottom:none;}
abbr[title]:before, abbr[title]:after
{display:block;
content:attr(title);
font-size:0.6em;
line-height:1.2em;}
abbr[title]:after
{visibility:hidden;}


or
abbr[title]
{display:inline-block;
text-align:center;
border-bottom:none;}
abbr[title]:before
{display:block;
content:attr(title);}

first one works in current Opera, second one requires Christmass gift :smile:

Thursday, 22. December 2005, 12:10:33

scipio

Undutchable

avatar

Posts: 29747

Netherlands

Originally posted by SirPavlova:

I searched the forums for 'ruby' but those didn't turn up. I don't know why...

Probably because they've been posted a long time ago. :smile:

Sunday, 25. December 2005, 21:45:47 (edited)

Originally posted by scipio:

Probably because they've been posted a long time ago. :smile:


Makes sense. :smile:

Originally posted by White Lynx:

Simple ruby markup seems to be easy to implement but its CSS counter part (CSS3 ruby module) is non-trivial.


Not to mention incomplete. They've no support for the rbspan attribute of rtc>rt elements, because they want to use the same system the table module does for colspan. Unfortunately the CSS3 table module is so far going to remain unchanged from CSS2.1, so it won't actually have a system for colspan :irked:

Originally posted by White Lynx:

I have no idea whether Ruby will be supported in near future, but when I unwrap my Cristmass gift I plan to write userJS and/or user CSS that renders simple Ruby (complex one will be supported only partly).


Yeah, I've done a stylesheet to display simple ruby markup when rendered horizontally, but due to my not being particularly expert with CSS I'm not sure how to do complex markup, or even if it can be done. I can't get an rtc>rt to span multiple rbc>rb elements like so:

<ruby>
  <rbc>
    <rb>10</rb>
    <rb>31</rb>
    <rb>2002</rb>
  </rbc>
  <rtc>
    <rt>Month</rt>
    <rt>Day</rt>
    <rt>Year</rt>
  </rtc>
  <rtc>
    <rt rbspan="3">Expiration Date</rt>
  </rtc>
</ruby>

Copy'n'paste - aren't specs handy? It's a fairly simple table structure really - not the simplest, that'd be a grid, but still, because the CSS table properties don't have anything for colspan I'm stumped. Nor can I get anything robust enough for the different possible orderings of the rbc & rtc elements. I suppose I'd really need UserJS for that hey? I haven't even looked at doing anything for vertical rendering. OK, enough rambling.

And about the abbreviations, I agree; I'm more interested in the typographical aspects of ruby though, just because I have a passing interest in, well, typography.

Edit: Fixed slight misquoting.

Monday, 26. December 2005, 14:13:34

Yeah, I've done a stylesheet to display simple ruby markup when rendered horizontally, but due to my not being particularly expert with CSS I'm not sure how to do complex markup, or even if it can be done. I can't get an rtc>rt to span multiple rbc>rb elements like so:

<ruby>
  <rbc>
    <rb>10</rb>
    <rb>31</rb>
    <rb>2002</rb>
  </rbc>
  <rtc>
    <rt>Month</rt>
    <rt>Day</rt>
    <rt>Year</rt>
  </rtc>
  <rtc>
    <rt rbspan="3">Expiration Date</rt>
  </rtc>
</ruby>


Yep, it is impossible to write CSS2.1 style sheet that handles complex Ruby. Some time ago I posted style sheet(s) for complex ruby on Prince forum but it uses experimental CSS extension that Opera does not support and in addition it does not handle vertical alignment well when content of ruby is complex (not just inline text).

I suppose I'd really need UserJS for that hey?


One can write JS that transforms ruby into XHTML tables with colspan attributes and then set display property to inline-table, but frankly speaking this approach sucks.

Tuesday, 27. December 2005, 01:56:00

Yep, it is impossible to write CSS2.1 style sheet that handles complex Ruby.

I suspected as much, but wasn't sure. Thanks.

but frankly speaking this approach sucks.

I agree wholeheartedly :smile:

Tuesday, 27. December 2005, 11:48:40 (edited)

For entertainment purposes I wrote UserJS that renders ruby (including complex one). Of course userJS can't replace native support but it is good toy to play with. Just save ruby.js script in your userJS directory and then try test page. Script works in Opera 9 only (Opera 8 has bug that spoils vertical alignment) and runs only on XHTML pages (served as application/xhtml+xml, application/xml or text/xml and not text/html).


P.S. userJS directory can be specified at

-[Tools]
--[Preferences]
---[Advanced]
----[Content]
-----[JavaScript options]
------[My script files]

Tuesday, 27. December 2005, 15:39:40

(Opera 8 has bug that spoils vertical alignment)


It has a lot of those doesn't it? Thinking about what I remember of your troubles rendering XML MAIDEN, a lot of it was vertical alignment, though that was CSS. IIRC, of course.

I shall have to learn JS, I think... the DOM methods sure are verbose. And about the UserJS dir., I knew already, but thanks anyway.

Is the column-span you used in your stylesheets for Prince being considered for CSS3 that you know of, or is it Prince-only, forever & always?

Wednesday, 28. December 2005, 08:15:32

It has a lot of those doesn't it?


Test page should look OK, problem in Opera 8 arises when inline blocks/tables of different height appear on one line.

Thinking about what I remember of your troubles rendering XML MAIDEN, a lot of it was vertical alignment, though that was CSS.


Yes, there still are problems with vertical alignment in present preview of Opera 9 but according to Moose, vikings from Osland have recently won fierce battle with army of vertical alignment bugs so hopefully next preview will solve the problem. It will also help to improve ruby.js (in current approach vertical alignment is broken when ruby base contains sub/superscripts or when heights of top and bottom annotations differ) that uses XHTML + CSS to render ruby, on JS side it uses only DOM2 core to modify document tree.


Is the column-span you used in your stylesheets for Prince being considered for CSS3 that you know of, or is it Prince-only, forever & always?


Currently it is Prince-only property, I don't know whether CSS3 will provide similar functionality (at the moment it does not). The property is necessary to merge XHTML tables into XML + CSS framework. Prince's rendering engine does not rely on native XHTML/DocBook/etc support, instead it renders XML applications by applying default CSS style sheets, so it was natural to add some CSS extensions to make default style sheets more powerful. In this respect it is interesting to see how they will implement MathML, if they'll manage to do it via default style sheet (with some CSS extensions) it will be really cool thing.

Thursday, 29. December 2005, 08:49:36

Good about the bugs.

Prince's rendering engine does not rely on native XHTML/DocBook/etc support, instead it renders XML applications by applying default CSS style sheets, so it was natural to add some CSS extensions to make default style sheets more powerful. In this respect it is interesting to see how they will implement MathML, if they'll manage to do it via default style sheet (with some CSS extensions) it will be really cool thing.


Yes it will.

Ever since I realised you couldn't make links in XML without declaring the XHTML namespace, I've basically thought everything should be done the way you say Prince does it, plus a usable version of XLink to generalise linking, & Web Forms to generalise forms, etc. Design a few building blocks, then build. MathML doesn't strike me as the right way to go... basically straight back into the one-spec-one-implementation idea. Designing a new block instead of building with the old ones. I know you don't like it because it's horribly verbose, but doesn't it also seem a bit odd to go for specs requiring special implementations for things which could be done purely via CSS?

Well maybe you couldn't actually do them in CSS, but if they put the work that went into MathML into CSS instead, that might not be the case.

The same ruby.js takes advantage of the fixes, right? It doesn't need reworking?

Thursday, 29. December 2005, 11:46:59

The same ruby.js takes advantage of the fixes, right? It doesn't need reworking?


It needs reworking to improve vertical alignment, I will rewrite it once new Opera will be available. Current ruby.js will continue to work like it works now.

but doesn't it also seem a bit odd to go for specs requiring special implementations for things which could be done purely via CSS?


It is odd, not just because capabilities of existing standards are not effectively reused but also because standards does not play well together in compound documents.

/* Top secret: for entertainment purposes (kind of bork edition) we wrote userJS implementation of MathML, it handles most of MathML layouts (msub, msup, msubsup, mmultiscripts, munder, mover, munderover, mfrac, msqrt, mphantom, maction, matrix, determinant, vector, piecewise) and will be posted after release of new Opera with vertical-alignment fixes. */

Thursday, 29. December 2005, 12:37:29

/* Top secret: for entertainment purposes (kind of bork edition) we wrote userJS implementation of MathML, it handles most of MathML layouts (msub, msup, msubsup, mmultiscripts, munder, mover, munderover, mfrac, msqrt, mphantom, maction, matrix, determinant, vector, piecewise) and will be posted after release of new Opera with vertical-alignment fixes. */


:zip:

Even though I'm not that interested in MathML itself, that sounds cool & worth looking at... I await it eagerly.

Thursday, 29. December 2005, 14:00:47

Moose

avatar

Posts: 7520

Norway

Opera Software

Originally posted by White Lynx:

/* Top secret: for entertainment purposes (kind of bork edition) we wrote userJS implementation of MathML, it handles most of MathML layouts (msub, msup, msubsup, mmultiscripts, munder, mover, munderover, mfrac, msqrt, mphantom, maction, matrix, determinant, vector, piecewise) and will be posted after release of new Opera with vertical-alignment fixes. */



::cough:: maybe I should update the olden moosified mathml torture experiment ::cough::

:sst:

M.

Friday, 30. December 2005, 08:10:44

Even though I'm not that interested in MathML itself


Nor am I. Just want to celebrate victory of Oslanders in battle with outstanding pet bugs.

maybe I should update the olden moosified mathml torture experiment


UserJS will pass torture tests provided that matrix/determinant/piecewise markup is used for matrices, determinants and cases (tabular layouts produced via mtable will be BORK!ed on purpose).

Friday, 30. December 2005, 22:09:16

(tabular layouts produced via mtable will be BORK!ed on purpose)


Do you not like mtable? I confess I've no idea what it is, other than the obvious table-ness...

Saturday, 31. December 2005, 08:55:44

Do you not like mtable? I confess I've no idea what it is, other than the obvious table-ness...


It is not a big issue to render mtable with CSS, but I am not sure whether it is worth to do as using them in the way MathML users currently do, is not good practice. For example most common way of using mtable are:
1. To align equation numbers (markers), like
<mtable>
  <mlabeledtr id='e-is-m-c-square'>
    <mtd>
      <mtext> (2.1) </mtext>
    </mtd>
    <mtd>
     <mrow>
       <mi>E</mi>
       <mo>=</mo>
       <mrow>
        <mi>m</mi>
        <mo>&it;</mo>
        <msup>
         <mi>c</mi>
         <mn>2</mn>
        </msup>
       </mrow>
     </mrow>
    </mtd>
  </mlabeledtr>
</mtable>

It sound much more reasonable to set up counter via generated content that numbers equations and float it to the right side. Much less junk and much more flexible control over both numbering and alignment.

2. Matrices, determinants and cases are produced via mtable, where table in brackets immitates matrix
<mrow>
  <mo> ( </mo>
  <mtable>
    <mtr>
      <mtd> <mn>1</mn> </mtd>
      <mtd> <mn>0</mn> </mtd>
      <mtd> <mn>0</mn> </mtd>
    </mtr>
    <mtr>
      <mtd> <mn>0</mn> </mtd>
      <mtd> <mn>1</mn> </mtd>
      <mtd> <mn>0</mn> </mtd>
    </mtr>
    <mtr>
      <mtd> <mn>0</mn> </mtd>
      <mtd> <mn>0</mn> </mtd>
      <mtd> <mn>1</mn> </mtd>
    </mtr>
  </mtable>
  <mo> ) </mo>
</mrow>

It sounds much more reasonable to use native markup for matrices/determinants/vectors/cases that fortunately exists in MathML, and has much more clear semantical role then mtable, for example:
<matrix>
    <matrixrow>
      <cn>1</cn>
      <cn>0</cn>
      <cn>0</cn>
    </matrixrow>
    <matrixrow>
      <cn>0</cn>
      <cn>1</cn>
      <cn>0</cn>
    </matrixrow>
    <matrixrow>
      <cn>0</cn>
      <cn>0</cn>
      <cn>1</cn>
    </matrixrow>
  </matrix>

This are basic arguments against mtable. To Bork, or not to Bork — that's the question.

Saturday, 31. December 2005, 12:13:35

So it's a matter of encouraging (enforcing, perhaps) correctness? In that case, bork it. This isn't an official implementation that could come back & bite Opera on the behind after all. Then again, since Opera isn't used for MathML anyway, people will probably just continue that way if you bork it... I can think of no solution :frown:

Wednesday, 8. February 2006, 10:37:49

Vertical alignment works perfectly in Opera 9TP2, updated version of ruby.js is available. It should render complex ruby annotations too, bugs can be reported on UserJS forum.

Wednesday, 8. February 2006, 11:58:45

Just out of interest (since I'll likely never make such a page, let alone with this), does it support vertical text orientation? Like this:


+----------------+
|+------+        |
||      |+------+|
|| Ruby || Ruby ||
|| base || text ||
||      |+------+|
|+------+        |
+----------------+

That'd be cool. I don't know how to test it for myself (no idea how to make pages which render text vertically).

Wednesday, 8. February 2006, 12:50:27

No, it does not support vertical text. It places ruby annotation above/below the base, regardless text direction.

Forums » Opera Community » Opera for desktop » Desktop wish-list