<?php
#
#
# Parsedown
# http://parsedown.org
#
# (c) Emanuil Rusev
# http://erusev.com
#
# For the full license information, view the LICENSE file that was distributed
# with this source code.
#
#
class Parsedown
{
# ~
const version = '1.6.0';
# ~
function text($text)
{
# make sure no definitions are set
$this->DefinitionData = array();
# standardize line breaks
$text = str_replace(array("\r\n", "\r"), "\n", $text);
# remove surrounding line breaks
$text = trim($text, "\n");
# split text into lines
$lines = explode("\n", $text);
# iterate through lines to identify blocks
$markup = $this->lines($lines);
# trim line breaks
$markup = trim($markup, "\n");
return $markup;
}
#
# Setters
#
function setBreaksEnabled($breaksEnabled)
{
$this->breaksEnabled = $breaksEnabled;
return $this;
}
protected $breaksEnabled;
function setMarkupEscaped($markupEscaped)
{
$this->markupEscaped = $markupEscaped;
return $this;
}
protected $markupEscaped;
function setUrlsLinked($urlsLinked)
{
$this->urlsLinked = $urlsLinked;
return $this;
}
protected $urlsLinked = true;
#
# Lines
#
protected $BlockTypes = array(
'#' => array('Header'),
'*' => array('Rule', 'List'),
'+' => array('List'),
'-' => array('SetextHeader', 'Table', 'Rule', 'List'),
'0' => array('List'),
'1' => array('List'),
'2' => array('List'),
'3' => array('List'),
'4' => array('List'),
'5' => array('List'),
'6' => array('List'),
'7' => array('List'),
'8' => array('List'),
'9' => array('List'),
':' => array('Table'),
'<' => array('Comment', 'Markup'),
'=' => array('SetextHeader'),
'>' => array('Quote'),
'[' => array('Reference'),
'_' => array('Rule'),
'`' => array('FencedCode'),
'|' => array('Table'),
'~' => array('FencedCode'),
);
# ~
protected $unmarkedBlockTypes = array(
'Code',
);
#
# Blocks
#
protected function lines(array $lines)
{
$CurrentBlock = null;
foreach ($lines as $line)
{
if (chop($line) === '')
{
if (isset($CurrentBlock))
{
$CurrentBlock['interrupted'] = true;
}
continue;
}
if (strpos($line, "\t") !== false)
{
$parts = explode("\t", $line);
$line = $parts[0];
unset($parts[0]);
foreach ($parts as $part)
{
$shortage = 4 - mb_strlen($line, 'utf-8') % 4;
$line .= str_repeat(' ', $shortage);
$line .= $part;
}
}
$indent = 0;
while (isset($line[$indent]) and $line[$indent] === ' ')
{
$indent ++;
}
$text = $indent > 0 ? substr($line, $indent) : $line;
# ~
$Line = array('body' => $line, 'indent' => $indent, 'text' => $text);
# ~
if (isset($CurrentBlock['continuable']))
{
$Block = $this->{'block'.$CurrentBlock['type'].'Continue'}($Line, $CurrentBlock);
if (isset($Block))
{
$CurrentBlock = $Block;
continue;
}
else
{
if ($this->isBlockCompletable($CurrentBlock['type']))
{
$CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
}
}
}
# ~
$marker = $text[0];
# ~
$blockTypes = $this->unmarkedBlockTypes;
if (isset($this->BlockTypes[$marker]))
{
foreach ($this->BlockTypes[$marker] as $blockType)
{
$blockTypes []= $blockType;
}
}
#
# ~
foreach ($blockTypes as $blockType)
{
$Block = $this->{'block'.$blockType}($Line, $CurrentBlock);
if (isset($Block))
{
$Block['type'] = $blockType;
if ( ! isset($Block['identified']))
{
$Blocks []= $CurrentBlock;
$Block['identified'] = true;
}
if ($this->isBlockContinuable($blockType))
{
$Block['continuable'] = true;
}
$CurrentBlock = $Block;
continue 2;
}
}
# ~
if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted']))
{
$CurrentBlock['element']['text'] .= "\n".$text;
}
else
{
$Blocks []= $CurrentBlock;
$CurrentBlock = $this->paragraph($Line);
$CurrentBlock['identified'] = true;
}
}
# ~
if (isset($CurrentBlock['continuable']) and $this->isBlockCompletable($CurrentBlock['type']))
{
$CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
}
# ~
$Blocks []= $CurrentBlock;
unset($Blocks[0]);
# ~
$markup = '';
foreach ($Blocks as $Block)
{
if (isset($Block['hidden']))
{
continue;
}
$markup .= "\n";
$markup .= isset($Block['markup']) ? $Block['markup'] : $this->element($Block['element']);
}
$markup .= "\n";
# ~
return $markup;
}
protected function isBlockContinuable($Type)
{
return method_exists($this, 'block'.$Type.'Continue');
}
protected function isBlockCompletable($Type)
{
return method_exists($this, 'block'.$Type.'Complete');
}
#
# Code
protected function blockCode($Line, $Block = null)
{
if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted']))
{
return;
}
if ($Line['indent'] >= 4)
{
$text = substr($Line['body'], 4);
$Block = array(
'element' => array(
'name' => 'pre',
'handler' => 'element',
'text' => array(
'name' => 'code',
'text' => $text,
),
),
);
return $Block;
}
}
protected function blockCodeContinue($Line, $Block)
{
if ($Line['indent'] >= 4)
{
if (isset($Block['interrupted']))
{
$Block['element']['text']['text'] .= "\n";
unset($Block['interrupted']);
}
$Block['element']['text']['text'] .= "\n";
$text = substr($Line['body'], 4);
$Block['element']['text']['text'] .= $text;
return $Block;
}
}
protected function blockCodeComplete($Block)
{
$text = $Block['element']['text']['text'];
$text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
$Block['element']['text']['text'] = $text;
return $Block;
}
#
# Comment
protected function blockComment($Line)
{
if ($this->markupEscaped)
{
没有合适的资源?快使用搜索试试~ 我知道了~
HUSTOJ Web 完全重写版本 支持 PHP 7 ,更易用的前端交互,新增部分实用功能,提高代码可读性和可维护性
共226个文件
php:153个
js:29个
css:20个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 172 浏览量
2023-12-31
10:47:00
上传
评论
收藏 1.23MB ZIP 举报
温馨提示
HUSTOJ Web 完全重写版本。支持 PHP 7 ,更易用的前端交互,新增部分实用功能,提高代码可读性和可维护性。
资源推荐
资源详情
资源评论
收起资源包目录
HUSTOJ Web 完全重写版本 支持 PHP 7 ,更易用的前端交互,新增部分实用功能,提高代码可读性和可维护性 (226个子文件)
AUTHORS 242B
bootstrapnight.min.css 123KB
bootstrap.min.css 121KB
font-awesome-ie7.min.css 37KB
font-awesome.min.css 23KB
jasny-bootstrap.min.css 13KB
summernote.css 10KB
codemirror.css 8KB
bootstrap-select.min.css 5KB
bearkidframe.css 5KB
twilight.css 2KB
midnight.css 2KB
vibrant-ink.css 2KB
3024-night.css 2KB
3024-day.css 2KB
colorforth.css 2KB
night.css 2KB
nprogress.css 1KB
admin-css.css 1KB
eclipse.css 1KB
prettify.css 678B
fontawesome-webfont.eot 59KB
glyphicons-halflings-regular.eot 20KB
.gitattributes 378B
.gitignore 679B
.htaccess 42B
favicon.ico 422KB
codemirror.js 338KB
vim.js 193KB
highcharts.js 158KB
jquery.min.js 91KB
summernote.min.js 71KB
jqBootstrapValidation.js 35KB
bootstrap.min.js 35KB
javascript.js 26KB
markdown.js 23KB
clike.js 22KB
test.js 21KB
sublime.js 20KB
bootstrap-select.min.js 18KB
prettify.js 14KB
emacs.js 13KB
python.js 13KB
jquery.pjax.min.js 12KB
xml.js 12KB
nprogress.js 11KB
jasny-bootstrap.min.js 11KB
html5shiv.js 10KB
test.js 7KB
pnglib.js 6KB
lua.js 6KB
respond.min.js 4KB
md5.min.js 4KB
pascal.js 3KB
test.js 2KB
test.js 1KB
LICENSE 1KB
FAQ.schinese.md 8KB
FAQ.md 8KB
about.schinese.md 5KB
about.md 5KB
FontAwesome.otf 92KB
Parsedown.php 37KB
simple_html_dom.php 34KB
thread.php 10KB
ajax_discuss.php 10KB
problem_data.php 10KB
discuss.php 9KB
problem_judge.php 7KB
schinese.inc.php 7KB
gen_identicon.php 7KB
english.inc.php 7KB
safe_func.inc.php 7KB
status.php 7KB
userinfo.php 6KB
contest_mod.php 6KB
problem_submit.php 6KB
problem.php 5KB
contest_mod.php 5KB
ajax_problemdata.php 5KB
problemset.php 5KB
contest_status.php 5KB
modifyinfo.php 5KB
schinese.admin.inc.php 5KB
english.admin.inc.php 4KB
ajax_problemset.php 4KB
contest_problem.php 4KB
problemstatistics.php 4KB
navbar.php 4KB
contest_heading.php 4KB
problem_mod.php 4KB
problem_import_file.php 4KB
mail.php 4KB
config.sample.php 4KB
contest_list.php 4KB
contest_status.php 3KB
mail.php 3KB
contest_ranklist.php 3KB
ranklist.php 3KB
news_manager.php 3KB
共 226 条
- 1
- 2
- 3
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 6744
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 卡方数据.sav
- Python实现基于Django框架的二手物品购物网站设计源码+数据库.zip
- 基于Python和Django的二手物品购物网站设计源码+数据库脚本.zip
- 【计算机毕业设计】基于h5的移动网赚项目小程序【源码+lw+部署文档+讲解】
- 【计算机毕业设计】基于ssm-vue的oa系统设计与实现【源码+lw+部署文档+讲解】
- 基于pytorch实现的YOLOV5+SORT的车辆行人目标识别及追踪系统源码.zip
- 【计算机毕业设计】基于servlet+jdbc的在线选房系统设计与实现【源码+lw+部署文档+讲解】
- 投身科技创新,勇担时代先锋.pptx
- 【计算机毕业设计】基于SSM的仿微博系统的设计与实现【源码+lw+部署文档+讲解】
- 使用 Web Components 实现,遵循 Material You 设计规范的 Web 前端组件库
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功