mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-12-23 07:51:53 +00:00
feat(web): add html2markdown
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
75976d9bcc
commit
db1500110a
44
web/app/controllers/html2markdown.php
Normal file
44
web/app/controllers/html2markdown.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
requireLib('bootstrap5');
|
||||
?>
|
||||
|
||||
<?php echoUOJPageHeader(UOJLocale::get('html to markdown')) ?>
|
||||
|
||||
<h1 class="h2">
|
||||
<?= UOJLocale::get('html to markdown') ?>
|
||||
</h1>
|
||||
|
||||
<style>
|
||||
#html, #markdown {
|
||||
font-family: Cascadia Mono, Ubuntu Mono, Roboto Mono, Jetbrains Mono, Fira Code, Consolas, '思源黑体 Regular', '思源宋体 Light', '宋体', 'Courier New', monospace;
|
||||
width: 100%;
|
||||
min-height: 300px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row row-cols-1 row-cols-md-2">
|
||||
<div class="col">
|
||||
<h2 class="h4">HTML 源码</h2>
|
||||
<textarea class="form-control" id="html" placeholder="input html here"></textarea>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h2 class="h4">Markdown 源码</h2>
|
||||
<textarea readonly class="form-control" id="markdown" placeholder="output markdown here"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?= HTML::js_src('/js/h2m.js') ?>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#html').on('input', function() {
|
||||
$('#markdown').val(h2m($('#html').val(), { converter: 'Gfm' }));
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php echoUOJPageFooter() ?>
|
@ -112,8 +112,8 @@
|
||||
<p>提示:</p>
|
||||
<ol>
|
||||
<li>请勿引用不稳定的外部资源(如来自个人服务器的图片或文档等),以便备份及后期维护;</li>
|
||||
<li>请勿在题面中直接插入大段 HTML 源码,这可能会破坏页面的显示,可以考虑使用 <a href="http://island205.github.io/h2m/">转换工具</a> 转换后再作修正;</li>
|
||||
<li>图片上传推荐使用 <a href="https://smms.app" target="_blank">SM.MS</a> 图床,以免后续产生外链图片大量失效的情况。</li>
|
||||
<li>请勿在题面中直接插入大段 HTML 源码,这可能会破坏页面的显示,可以考虑使用 <a href="/html2markdown">转换工具</a> 转换后再作修正;</li>
|
||||
<li>图片上传推荐使用 <a href="/image_hosting" target="_blank">S2OJ</a> 图床,以免后续产生外链图片大量失效的情况。</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
|
@ -102,4 +102,5 @@ return [
|
||||
'offline' => 'Offline',
|
||||
'apps' => 'Apps',
|
||||
'image hosting' => 'Image Hosting',
|
||||
'html to markdown' => 'HTML to Markdown',
|
||||
];
|
||||
|
@ -102,4 +102,5 @@ return [
|
||||
'last active at' => '最后活动于',
|
||||
'apps' => '应用',
|
||||
'image hosting' => '图床',
|
||||
'html to markdown' => 'HTML 转 Markdown',
|
||||
];
|
||||
|
@ -80,9 +80,10 @@ Route::group([
|
||||
|
||||
Route::any('/click-zan', '/click_zan.php');
|
||||
|
||||
// Image Hosting
|
||||
// Apps
|
||||
Route::any('/image_hosting', '/image_hosting/index.php');
|
||||
Route::get('/image_hosting/{image_name}.png', '/image_hosting/get_image.php');
|
||||
Route::any('/html2markdown', '/html2markdown.php');
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -116,6 +116,12 @@ mb-4" role="navigation">
|
||||
<?= UOJLocale::get('image hosting') ?>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item" href="<?= HTML::url('/html2markdown') ?>">
|
||||
<i class="bi bi-markdown"></i>
|
||||
<?= UOJLocale::get('html to markdown') ?>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif ?>
|
||||
|
5
web/js/h2m.js
Normal file
5
web/js/h2m.js
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user