MathML widget : XML or HTML elements?
Lars Knoll
lars at trolltech.com
Wed Apr 10 08:58:25 BST 2002
Hi Ellis,
> I have a MathML widget working in khtml now. Currently all the text
Cool :)
> between the <math> & </math> tags gets passed to the KMathMLView widget,
> which parses it using the QDom-classes. There are a couple major
> short-comings here: 1) style settings aren't handled and 2) the nodes
> aren't externally accessable (e.g. via javascript).
>
> How should I make the MathML nodes javascript accessable?
You will have to parse the MathML directly in khtml I guess. In this case
style settings will automatically be applied to the nodes and they will be
accessible from jscript.
> One possibility would be to use the ElementImpl class as a parent for the
> (currently internal) KMathML node classes so that each child node is made a
> part of the khtml DOM tree, but then do I need to create both XML & HTML
> element implementations? So far, I've created HTMLMathElement* and
No, just one kind of implementation is enough. You can make sure they get
created from the HTML parser, and import them into the XML parser if the
corresponding namespace is defined.
All this would probably mean a partly rewrite of KMathMLView, moving over to
khtml DOM classes, and maybe putting all that in a seperate subdir in khtml.
KMathMLView would then get to be a wrapper around khtml. IMO that's the only
way to get a 100% integration into khtml including scripting and styles.
> RenderMath classes, added ID_MATH the tokens list, and edited
> htmlparser.cpp and htmltokenizer.cpp to handle the <math> tag. I'm betting
> that this is the wrong way to go about it. MathML is, after all, an XML
> spec, so there must be some way to make khtml aware of the XML definition?
You might still need to hack the html/xml parsers to create your MathML
elements in this case and add the list of math tags to the taglist, but you
should not need to do much more.
> Furthermore, I currently have formatting defaults hardcoded into the widget
> (such as the % font size of superscripts). I'd rather have this defined by
> a CSS style sheet. How do you read in a style sheet?
If you use khtml this gets automatically done for you. You get a style element
for every node in the DOM (a RenderStyle object) containing all the
definitions you need, as eg. font, background, width, height etc. I don't
think that you want to redo a css parser on your own :)
Lars
More information about the kde-core-devel
mailing list