Jump to content

Topic on Talk:Parsoid/Extension API

Tgr (WMF) (talkcontribs)

Method naming seems pretty confusing. We have toDOM and fromDOM, but parseHTML and toHTML/innerHTML (which return the same thing even though the naming would suggest that the latter drops the top node; also toHTML hardly warns you that the DOM object is going to be corrupted), parseWikitextToDOM / parseExtTagToDOM and serializeHTML / serializeChildren (which are supposed to be the mirror image of each other but follow different naming schemes)...

IMO it would be a lot nicer if you just stanadardized on somethingToSomething - ExtensionTag::domToWikitext, ExtensionTag::wikitextToDom, ParsoidExtensionAPI::htmlToDom, ParsoidExtensionAPI::domToHtml, ParsoidExtensionAPI::domToHtmlInPlace (or something similar that makes it very clear that this changes the DOM), ParsoidExtensionAPI::wikitextToDom, ParsoidExtensionAPI::extensionTagToDom, ParsoidExtensionAPI::domToWikitext, ParsoidExtensionAPI::domToExtensionTag...

SSastry (WMF) (talkcontribs)

Ya, naming is pretty bad, isn't it? I have started to look at it but your 'somethingToSomething' standardization suggestion is pretty good. One reason we ended up with the 'toDOM', 'fromDOM' naming is because if extensions implement content handlers other than wikitext (ex: JSON), wikitextToDom, domToWikitext doesn't cut it. However, Arlo was proposing in a different context (Parsoid.php API for internal use) if this should be called 'contentToDom', 'domToContent'. Maybe that is an option. Thoughts on that bit?

Tgr (WMF) (talkcontribs)

Yeah, that sounds good too. sourceToDOM might work as well.

SSastry (WMF) (talkcontribs)

Ya, that sounds better.