Earlier quoted context omitted.
My suspicion is correct - code is full of things like: /\[\[([^\[\]] )\]\]|\{\{([^\{\}] )\}\}|-\{([^\{\}]*)\}-/
I never understood why people find regex so intimidating. Obviously you probably didn't look to find the worst of all, but one you posted is very straightforward.
Parsoid in PHP, or There and Back Again
21–30 of 75 posts
Re: Parsoid in PHP, or There and Back Again
#22I would assume that the code is open source? For some reason, I did not manage to find it. Neither linked from this article, nor via the MediaWiki page: https://www.mediawiki.org/wiki/Parsoid Nor via the Phabricator page: https://phabricator.wikimedia.org/project/profile/487/ What am I missing?
Google fu.
parsoid source code => https://github.com/wikimedia/parsoid
Re: Parsoid in PHP, or There and Back Again
#23Earlier quoted context omitted.
My suspicion is correct - code is full of things like: /\[\[([^\[\]] )\]\]|\{\{([^\{\}] )\}\}|-\{([^\{\}]*)\}-/
I never understood why people find regex so intimidating. Obviously you probably didn't look to find the worst of all, but one you posted is very straightforward.
Re: Parsoid in PHP, or There and Back Again
#24I would assume that the code is open source? For some reason, I did not manage to find it. Neither linked from this article, nor via the MediaWiki page: https://www.mediawiki.org/wiki/Parsoid Nor via the Phabricator page: https://phabricator.wikimedia.org/project/profile/487/ What am I missing?
> What am I missing? Google fu. parsoid source code => https://github.com/wikimedia/parsoid
Re: Parsoid in PHP, or There and Back Again
#25Earlier quoted context omitted.
> What am I missing? Google fu. parsoid source code => https://github.com/wikimedia/parsoid
Woops .. so they use Phabricator for issue management and GitHub to host the code?
Re: Parsoid in PHP, or There and Back Again
#26Example: https://github.com/wikimedia/parsoid/blob/master/src/Parsoid...
This is how I would write the function definition:
function html2wikitext($config, $html, $options = [], $data = null)
This how Wikimedia did it: public function html2wikitext(
PageConfig $pageConfig, string $html, array $options = [],
?SelserData $selserData = null
): string
I see this "strictness over readability" on the rise in many places and I think it is a net negative.Not totally sure, but this seems to be the old JS function definition:
https://github.com/abbradar/parsoid/blob/master/lib/parse.js...
A bit cryptic and it suffers from the typical promise / async / callback / nesting horror so common in the Javascript world:
_html2wt = Promise.async(function *(obj, env, html, pb)Re: Parsoid in PHP, or There and Back Again
#27Re: Parsoid in PHP, or There and Back Again
#28Anybody else feeling that strict typing and long var names are not worth all the visual overload? Example: https://github.com/wikimedia/parsoid/blob/master/src/Parsoid... This is how I would write the function definition: function html2wikitext($config, $html, $options = [], $data = null) This how Wikimedia did it: public function html2wikitext( PageConfig $pageConfig, string $html, array $options = [], ?SelserData $…
Re: Parsoid in PHP, or There and Back Again
#29Re: Parsoid in PHP, or There and Back Again
#30Earlier quoted context omitted.
I never understood why people find regex so intimidating. Obviously you probably didn't look to find the worst of all, but one you posted is very straightforward.
You jest, but that regex looks machine-generated. My Emacs is full of these in places used for syntax coloring, but I know these are optimized . There's an elisp function, regex-opt, into which you can throw a bunch of strings, and you get out a regex like above.