I tried mixing wiki syntax and html and tried mixed filters to accommodate a goal of being able to use both wiki syntax and html, but had no success.

Comments

rnd’s picture

Category: feature » bug
Status: Active » Needs review

I believe I fixed this. Let me warn you that this is my first post on durpal.org, let alone to suggest a patch. That being said I found that if you comment out a line and cange a third, liquid will stop escaping html code. Here is what my code for mw_sanitizer.inc now looks like from lines 428-436 (being new to this please forgive me if I'm not posting this in the prefered manner):

					if ( ! $badtag ) {
						#CHANGED!REMOVE:$rest = str_replace( '>', '>', $rest );
						$close = ( $brace == '/>' ) ? ' /' : '';
						$text .= "<$slash$t$newparams$close>$rest";
						continue;
					}
				}
				$text .= '<' . $x; #CHANGED!WAS:$text .= '&lt;' . str_replace( '>', '&gt;', $x);
			}

Hope this helps everyone out... I would immagine that Matt and I aren't the only ones out there who wanted this fixed!

rnd’s picture

Actually, I discovered that this alone still causes funky issues with <a> tags because Liquid automatically creates the <a> tags for any URL. I found the line that identifies URLs and modified it so that the RegEx pattern should not if the URL is surrounded by quotes (single or double somehow!) Once again, this is what my code looks like on line 803 of mw_parser.inc now:

yes, this is all one line, and yes I do have a kind of strange way of documenting code modifications... I know this... But it does have the advantage of not changing line number references in the future!

$bits = preg_split( '/(\b(?:[^"]'.$wgUrlProtocols.'[^"]))/S', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); #CHANGED!WAS: $bits = preg_split( '/(\b(?:'.$wgUrlProtocols.'))/S', $text, -1, PREG_SPLIT_DELIM_CAPTURE );

This should allow your users to create a link by copying and pasting a url, using an <a> tag or by using Wiki syntax.

matt_paz’s picture

Thanks RND!! 'Will take a look at implementing this and circle back

matt_paz’s picture

I've been playing with it on and off for a few days now and it all looks good! Thanks again!

Regards,
Matt

rnd’s picture

So I may have encountered a strange side effect, or else it's just a problem with Liquid. We run a multisite implimentation of Drupal, and I occaisonally get the error below pop up on the sites when trying to access any page:

Fatal error: Call to undefined function arg() in /homepages/44/d157584041/htdocs/drupal-4.7.0/modules/liquid/liquid.module on line 116

Both times when this has happened, I have resolved it by renaming the liquid folder to liquid 2, then reloading, loging in, disabling liquid, naming it back to liquid and reenabling it. I haven't seen it repeat on the same drupal site twice, but it's still to early to tell if that is the case or not.

matt_paz’s picture

Hmmm. I haven't encountered that myself. So far, everything is working great. Will post here if I encounter it too.

fractile81’s picture

I've been using these modifications on my own site and have found a problem with the above patch, specifically the preg_split(). There is a bug where if you have, say, <td>http://example.com</td>, the td's > will become part of the URL and subsequently parts of the link (e.g. this example would become >http://example.com). I was able to get the desired functionality with the following changes in mw_parser.inc:

  • Revert the preg_split() change on line 803 back to what it originally was. (Remove both [^"] from the expression)
  • Add the following on line 810:
    if( $s{strlen( $s)-1} == '"') {
      $s .= $protocol . $remainder;
      continue;
    }
    

And that would do it. Appears to work rather well! Great research here, guys!

sorenp’s picture

Status: Needs review » Closed (won't fix)

My intention is that Liquid should provide the Wiki infrastructure to Drupal rather than specific markups. For this reason, the development of the Liquid Filter module will focus on providing infrastructure for Liquid Wiki Filters rather than supporting any specific markups. As soon as the basic infrastructure has been set up, the Media Wiki Markup support in Liquid will be dropped. A new project will be started to take care of the Media Wiki Liquid Filter, but I will not take any responsibility for the development. Until then, the module will be included for testing purposes, but no active development will be done except for things connected to the Liquid Filter Interface.

I know there are other approaches running on Drupal when it comes to Wiki Markup Filters. My suggestion is that you take a look at those or, if you have the time, start a Liquid MedaWiki Markup Filter project.

// Soren

matt_paz’s picture

Version: 4.7.x-1.x-dev » 5.x-1.x-dev

I've switched over to the PearWiki_Filter. It offers a regular expression for ignoring content. Here is what we're using to ignore html ...

/(<\/?[^>]+>)|(&[\w]{3,8};)/

Please advise if you're aware of another alternative that would be better suited for ensuring ongoing interoperability with Liquid.