Skip to content

Commit

Permalink
fix markdown list parser
Browse files Browse the repository at this point in the history
  • Loading branch information
joyqi committed Dec 11, 2017
1 parent f3dab39 commit f2731b7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions admin/js/hyperdown.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions var/HyperDown.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ private function parseBlock($text, &$lines)
*/
private function parseBlockList($block, $key, $line, &$state)
{
if (preg_match("/^(\s*)((?:[0-9]+\.)|(?:[a-z]\.?)|\-|\+|\*)\s+/i", $line, $matches)) {
if (preg_match("/^(\s*)((?:[0-9]+\.)|\-|\+|\*)\s+/i", $line, $matches)) {
$space = strlen($matches[1]);
$state['empty'] = 0;

Expand Down Expand Up @@ -1269,7 +1269,7 @@ private function parseList(array $lines)

// count levels
foreach ($lines as $key => $line) {
if (preg_match("/^(\s*)((?:[0-9]+\.?)|(?:[a-z]\.?)|\-|\+|\*)(\s+)(.*)$/i", $line, $matches)) {
if (preg_match("/^(\s*)((?:[0-9]+\.?)|\-|\+|\*)(\s+)(.*)$/i", $line, $matches)) {
$space = strlen($matches[1]);
$type = false !== strpos('+-*', $matches[2]) ? 'ul' : 'ol';
$minSpace = min($space, $minSpace);
Expand Down
7 changes: 5 additions & 2 deletions var/Widget/Contents/Post/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,11 @@ protected function getCreated()
$created = $this->request->created;
} else if (!empty($this->request->date)) {
$dstOffset = !empty($this->request->dst) ? $this->request->dst : 0;
$timezoneOffset = isset($this->request->timezone) ? intval($this->request->timezone) : $this->options->timezone;
$created = strtotime($this->request->date) - $timezoneOffset + $this->options->serverTimezone - $dstOffset;
$timezoneOffset = $this->options->timezone;
$timezone = ($timezoneOffset >= 0 ? '+' : '-') . str_pad($timezoneOffset / 3600, 2, '0', STR_PAD_LEFT) . ':00';
list ($date, $time) = explode(' ', $this->request->date);

$created = strtotime("{$date}T{$time}{$timezone}") - $dstOffset;
} else if (!empty($this->request->year) && !empty($this->request->month) && !empty($this->request->day)) {
$second = intval($this->request->get('sec', date('s')));
$min = intval($this->request->get('min', date('i')));
Expand Down

0 comments on commit f2731b7

Please sign in to comment.