User:Jiangxin/Patch Indent Pre

Support raw html ouput from extension

edit

Indent_PRE means before PRE block (<pre>), there are several colon and the rander page shows a indented PRE block. When using UseMod wiki, I like it's indent pre syntax, but MediaWiki seems not support it. This patch lets MediaWiki support a indent pre feature.

Indent_PRE 就是在 <pre> 之前有若干个表示缩进的 冒号。 UseMod wiki 支持这样的语法,但是 MediaWiki 1.5.2 并不支持。 下面这个 Patch 提供了 MediaWiki 缩进 pre 的语法。

Bug 1581: pre over multiple lines in lists (duplicate of 1518) describe this problem: pre block can not be used in list. Though I have fixed it with the following patch, I find out these is another solution, which can solve another MediaWiki annoyance.

Bug 1115 described the another annoyance of the current implement(1.5.2) of list.

The patch I wrote fixed both the bug/annoyance: User:Jiangxin/Patch Blankline As List Terminator

Bug 1581: pre over multiple lines in lists (duplicate of 1518) 详细描述了 Wiki 的这个问题:不能在列表中使用跨行的 PRE 语法。 虽然我已经用补丁: User:Jiangxin/Patch Indent Pre 修复了这个问题,但是我发现另外的一个解决方案,并且可以解决另外一个 MediaWiki 受限制的地方。

Bug 1115 描述了由于 list 以回车结束导致不能分行写的困扰, 并建议以遇到空行或者下一个 list 时终止当前 list。

我关于这两个 Bug 的解决方案,参见: User:Jiangxin/Patch Blankline As List Terminator

-- Jiangxin 07:12, 17 November 2005 (UTC)

Index: Parser.php
===================================================================
RCS file: /user/jiangxin/project/wiki/mediawiki/src/includes/Parser.php,v
retrieving revision 1.8
retrieving revision 1.10
diff -u -r1.8 -r1.10
@@ -1688,6 +1688,28 @@
 			$lastPrefixLength = strlen( $lastPrefix );
 			$preCloseMatch = preg_match('/<\\/pre/i', $oLine );
 			$preOpenMatch = preg_match('/<pre/i', $oLine );
+			
+			# <pre> in a list
+			if(!empty($preOpenMatch) && empty($preCloseMatch) && empty($concat_line) && !$this->mInPre) {
+				if (preg_match('/^[\*#:;]+/i', $oLine )) {
+					$concat_line = $oLine;
+					$preOpenMatch = 0;
+					continue;
+				}
+			}
+			if (!empty($concat_line)) {
+				$concat_line = $concat_line . "\n" . $oLine;
+				if (!empty($preCloseMatch)) {
+					$oLine = $concat_line;
+					$preCloseMatch = 0;
+					$concat_line = "";
+				}
+				else
+				{
+					continue;
+				}
+			}
+			
 			if ( !$this->mInPre ) {
 				# Multiple prefixes may abut each other for nested lists.
 				$prefixLength = strspn( $oLine, '*#:;' );