Skip to content

Commit

Permalink
fix new line
Browse files Browse the repository at this point in the history
  • Loading branch information
joyqi committed Jan 26, 2016
1 parent 1c140a5 commit 2200d86
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
config.rb
/config.inc.php
/usr/uploads/
/usr/*.db
13 changes: 13 additions & 0 deletions tools/transfer-array.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

// transfer [] to array()

$file = $argv[1];
$text = file_get_contents($file);

$text = preg_replace("/= \[([^;]*)\];/s", "= array(\\1);", $text);
$text = preg_replace("/(\(| )\[([^\n]*?)\]\)/", "\\1array(\\2))", $text);
$text = preg_replace("/(\(| )\[([^\n]*?)\],/", "\\1array(\\2),", $text);

file_put_contents($file, $text);

File renamed without changes.
14 changes: 6 additions & 8 deletions var/HyperDown.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php
// replace square brackets with array()
// vim regex: %s/= \[\(\_[^;]*\)\];/= array(\1);/g

/**
* HyperDown
Expand Down Expand Up @@ -133,7 +131,7 @@ public function makeHolder($str)
*/
private function initText($text)
{
$text = str_replace(["\t", "\r"], [' ', ''], $text);
$text = str_replace(array("\t", "\r"), array(' ', ''), $text);
return $text;
}

Expand Down Expand Up @@ -264,7 +262,7 @@ private function parseInline($text, $whiteList = '', $clearHolders = true)
}
}, $text);

$text = str_replace(['<', '>'], ['&lt;', '&gt;'], $text);
$text = str_replace(array('<', '>'), array('&lt;', '&gt;'), $text);

// footnote
$text = preg_replace_callback("/\[\^((?:[^\]]|\\]|\\[)+?)\]/", function ($matches) {
Expand Down Expand Up @@ -412,7 +410,7 @@ private function parseBlock($text, &$lines)
|| strlen($matches[1]) > $space;
}

$this->startBlock('code', $key, [$matches[1], $matches[3], $isAfterList]);
$this->startBlock('code', $key, array($matches[1], $matches[3], $isAfterList));
}

continue;
Expand Down Expand Up @@ -473,7 +471,7 @@ private function parseBlock($text, &$lines)
// footnote
case preg_match("/^\[\^((?:[^\]]|\\]|\\[)+?)\]:/", $line, $matches):
$space = strlen($matches[0]) - 1;
$this->startBlock('footnote', $key, [$space, $matches[1]]);
$this->startBlock('footnote', $key, array($space, $matches[1]));
break;

// definition
Expand Down Expand Up @@ -533,7 +531,7 @@ private function parseBlock($text, &$lines)
$aligns[] = $align;
}

$this->setBlock($key, [$head, $aligns]);
$this->setBlock($key, array($head, $aligns));
}
break;

Expand Down Expand Up @@ -1010,7 +1008,7 @@ private function parseHtml(array $lines, $type)
*/
private function escapeBracket($str)
{
return str_replace(['\[', '\]', '\(', '\)'], ['[', ']', '(', ')'], $str);
return str_replace(array('\[', '\]', '\(', '\)'), array('[', ']', '(', ')'), $str);
}

/**
Expand Down

0 comments on commit 2200d86

Please sign in to comment.