Description
It would be valuable to get a working proof of concept of language parsing built for one of the mf2-parsers and the php-mf2 library along with the javascript one are two good candidates for that.
The discussion around language parsing is happening here: http://microformats.org/wiki/microformats2-parsing-brainstorming#Parse_language_information
There's a similar issue as this in the javascript MF2 parser here: glennjones/microformat-shiv#22
And the original PR to create proof of concept for an old version of the javascript mf2 parser can be found here: glennjones/microformat-node#23
To achieve the language parsing in php-mf2 one can probably utilize the fact that a DOMNode
has a parentNode
property (see docs) and use that to traverse the document tree upwards until one reach the first lang=
attribute or one reaches the end of the tree. Then one knows what the language of a node is (apart from some defaults that may have been specified in the eg. the HTTP-response, see HTML5 docs) and one can then know whether to add the language attribute or not.
Update: As @gRegorLove pointed out on IRC it may be hard to add the proposed output without breaking backwards compatibility, so the new output would either have to be introduced as a new major version or, probably preferably, as an opt-in feature flag for now that those who wants to use language data here and now can use while those who prefer to wait for a future major version before updating to support the new output could do so.