支持公式和表格的显示

pull/99/head
dirk1983 4 years ago
parent d94402453f
commit 063c48116e

@ -38,6 +38,285 @@ a {
background-color: transparent;
}
th {
text-align: inherit;
text-align: -webkit-match-parent;
}
a {
color: #5e72e4;
font-weight: 300;
text-decoration: none;
}
code {
padding: 2px 4px;
font-size: 90%;
color: #f56d8f;
border-radius: 4px;
}
pre code {
display: block;
overflow-x: auto;
padding: 1em;
background: #282c34;
color: #abb2bf;
font-family: monospace, monospace;
font-size: 1em;
line-height: 1.5em;
}
td {
border-color: rgba(255, 255, 255, 0.1);
padding: 12px 7px;
vertical-align: middle;
color: rgba(255, 255, 255, 0.7) !important;
display: table-cell;
}
table {
caption-side: bottom;
border-collapse: collapse;
}
.table {
--bs-table-color: #7b809a;
--bs-table-bg: transparent;
--bs-table-border-color: #f0f2f5;
--bs-table-accent-bg: transparent;
--bs-table-striped-color: #7b809a;
--bs-table-striped-bg: rgba(0, 0, 0, 0.05);
--bs-table-active-color: #7b809a;
--bs-table-active-bg: rgba(0, 0, 0, 0.1);
--bs-table-hover-color: #7b809a;
--bs-table-hover-bg: rgba(0, 0, 0, 0.075);
width: 100%;
margin-bottom: 1rem;
color: var(--bs-table-color);
vertical-align: top;
border-color: var(--bs-table-border-color);
}
.table> :not(caption)>*>* {
padding: 0.5rem 0.5rem;
background-color: var(--bs-table-bg);
border-bottom-width: 1px;
box-shadow: inset 0 0 0 9999px var(--bs-table-accent-bg);
}
.table>tbody {
vertical-align: inherit;
}
.table>thead {
vertical-align: bottom;
}
.table-group-divider {
border-top: 2px solid currentColor;
}
.caption-top {
caption-side: top;
}
.table-sm> :not(caption)>*>* {
padding: 0.25rem 0.25rem;
}
.table-bordered> :not(caption)>* {
border-width: 1px 0;
}
.table-bordered> :not(caption)>*>* {
border-width: 0 1px;
}
.table-borderless> :not(caption)>*>* {
border-bottom-width: 0;
}
.table-borderless> :not(:first-child) {
border-top-width: 0;
}
.table-striped>tbody>tr:nth-of-type(odd)>* {
--bs-table-accent-bg: var(--bs-table-striped-bg);
color: var(--bs-table-striped-color);
}
.table-striped-columns> :not(caption)>tr> :nth-child(even) {
--bs-table-accent-bg: var(--bs-table-striped-bg);
color: var(--bs-table-striped-color);
}
.table-active {
--bs-table-accent-bg: var(--bs-table-active-bg);
color: var(--bs-table-active-color);
}
.table-hover>tbody>tr:hover>* {
--bs-table-accent-bg: var(--bs-table-hover-bg);
color: var(--bs-table-hover-color);
}
.table-primary {
--bs-table-color: #000;
--bs-table-bg: #fbd2e0;
--bs-table-border-color: #e2bdca;
--bs-table-striped-bg: #eec8d5;
--bs-table-striped-color: #000;
--bs-table-active-bg: #e2bdca;
--bs-table-active-color: #000;
--bs-table-hover-bg: #e8c2cf;
--bs-table-hover-color: #000;
color: var(--bs-table-color);
border-color: var(--bs-table-border-color);
}
.table-secondary {
--bs-table-color: #000;
--bs-table-bg: #e5e6eb;
--bs-table-border-color: #cecfd4;
--bs-table-striped-bg: #dadbdf;
--bs-table-striped-color: #000;
--bs-table-active-bg: #cecfd4;
--bs-table-active-color: #000;
--bs-table-hover-bg: #d4d5d9;
--bs-table-hover-color: #000;
color: var(--bs-table-color);
border-color: var(--bs-table-border-color);
}
.table-success {
--bs-table-color: #000;
--bs-table-bg: #dbefdc;
--bs-table-border-color: #c5d7c6;
--bs-table-striped-bg: #d0e3d1;
--bs-table-striped-color: #000;
--bs-table-active-bg: #c5d7c6;
--bs-table-active-color: #000;
--bs-table-hover-bg: #cbddcc;
--bs-table-hover-color: #000;
color: var(--bs-table-color);
border-color: var(--bs-table-border-color);
}
.table-info {
--bs-table-color: #000;
--bs-table-bg: #d1e3fa;
--bs-table-border-color: #bccce1;
--bs-table-striped-bg: #c7d8ee;
--bs-table-striped-color: #000;
--bs-table-active-bg: #bccce1;
--bs-table-active-color: #000;
--bs-table-hover-bg: #c1d2e7;
--bs-table-hover-color: #000;
color: var(--bs-table-color);
border-color: var(--bs-table-border-color);
}
.table-warning {
--bs-table-color: #000;
--bs-table-bg: #fee8cc;
--bs-table-border-color: #e5d1b8;
--bs-table-striped-bg: #f1dcc2;
--bs-table-striped-color: #000;
--bs-table-active-bg: #e5d1b8;
--bs-table-active-color: #000;
--bs-table-hover-bg: #ebd7bd;
--bs-table-hover-color: #000;
color: var(--bs-table-color);
border-color: var(--bs-table-border-color);
}
.table-danger {
--bs-table-color: #000;
--bs-table-bg: #fdd9d7;
--bs-table-border-color: #e4c3c2;
--bs-table-striped-bg: #f0cecc;
--bs-table-striped-color: #000;
--bs-table-active-bg: #e4c3c2;
--bs-table-active-color: #000;
--bs-table-hover-bg: #eac9c7;
--bs-table-hover-color: #000;
color: var(--bs-table-color);
border-color: var(--bs-table-border-color);
}
.table-light {
--bs-table-color: #000;
--bs-table-bg: #f0f2f5;
--bs-table-border-color: #d8dadd;
--bs-table-striped-bg: #e4e6e9;
--bs-table-striped-color: #000;
--bs-table-active-bg: #d8dadd;
--bs-table-active-color: #000;
--bs-table-hover-bg: #dee0e3;
--bs-table-hover-color: #000;
color: var(--bs-table-color);
border-color: var(--bs-table-border-color);
}
.table-dark {
--bs-table-color: #fff;
--bs-table-bg: #344767;
--bs-table-border-color: #485976;
--bs-table-striped-bg: #3e506f;
--bs-table-striped-color: #fff;
--bs-table-active-bg: #485976;
--bs-table-active-color: #fff;
--bs-table-hover-bg: #435572;
--bs-table-hover-color: #fff;
color: var(--bs-table-color);
border-color: var(--bs-table-border-color);
}
.table-responsive {
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
@media (max-width: 575.98px) {
.table-responsive-sm {
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
}
@media (max-width: 767.98px) {
.table-responsive-md {
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
}
@media (max-width: 991.98px) {
.table-responsive-lg {
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
}
@media (max-width: 1199.98px) {
.table-responsive-xl {
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
}
@media (max-width: 1399.98px) {
.table-responsive-xxl {
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
}
abbr[title] {
border-bottom: none;
text-decoration: underline;

@ -32,6 +32,31 @@ $type = "个人";
<link rel="stylesheet" href="css/common.css?v1.1">
<link rel="stylesheet" href="css/wenda.css?v1.1">
<link rel="stylesheet" href="css/hightlight.css">
<script src="js/remarkable.js"></script>
<script src="js/jquery-3.6.4.min.js"></script>
<script src="js/jquery.cookie.min.js"></script>
<script src="js/layer.min.js"></script>
<script src="js/chat.js?v2.8"></script>
<script src="js/highlight.min.js"></script>
<script src="//cdn.bootcss.com/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
showProcessingMessages: false,
messageStyle: "none",
extensions: ["tex2jax.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ["$", "$"] ],
displayMath: [ ["$$","$$"] ],
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre','code','a'],
ignoreClass:"comment-content"
},
"HTML-CSS": {
availableFonts: ["STIX","TeX"],
showMathMenu: false
}
});
</script>
</head>
<body>
@ -201,14 +226,7 @@ $type = "个人";
</div>
</div>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/jquery.cookie.min.js"></script>
<script src="js/layer.min.js"></script>
<script src="js/chat.js?v2.8"></script>
<script src="js/highlight.min.js"></script>
<script src="js/showdown.min.js"></script>
<script>
</script>
</body>
</html>

@ -1,4 +1,56 @@
var contextarray = [];
var defaults = {
html: false, // Enable HTML tags in source
xhtmlOut: false, // Use '/' to close single tags (<br />)
breaks: false, // Convert '\n' in paragraphs into <br>
langPrefix: 'language-', // CSS language prefix for fenced blocks
linkify: true, // autoconvert URL-like texts to links
linkTarget: '', // set target to open link in
typographer: true, // Enable smartypants and other sweet transforms
_highlight: true,
_strict: false,
_view: 'html'
};
defaults.highlight = function (str, lang) {
if (!defaults._highlight || !window.hljs) { return ''; }
var hljs = window.hljs;
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(lang, str).value;
} catch (__) { }
}
try {
return hljs.highlightAuto(str).value;
} catch (__) { }
return '';
};
mdHtml = new window.Remarkable('full', defaults);
mdHtml.renderer.rules.table_open = function () {
return '<table class="table table-striped">\n';
};
mdHtml.renderer.rules.paragraph_open = function (tokens, idx) {
var line;
if (tokens[idx].lines && tokens[idx].level === 0) {
line = tokens[idx].lines[0];
return '<p class="line" data-line="' + line + '">';
}
return '<p>';
};
mdHtml.renderer.rules.heading_open = function (tokens, idx) {
var line;
if (tokens[idx].lines && tokens[idx].level === 0) {
line = tokens[idx].lines[0];
return '<h' + tokens[idx].hLevel + ' class="line" data-line="' + line + '">';
}
return '<h' + tokens[idx].hLevel + '>';
};
function getCookie(name) {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
@ -188,6 +240,7 @@ $(document).ready(function () {
let i = 0;
timer = setInterval(() => {
let newalltext = alltext;
let islastletter = false;
//有时服务器错误地返回\\n作为换行符,尤其是包含上下文的提问时,这行代码可以处理一下。
if (newalltext.split("\n\n").length == newalltext.split("\n").length) {
newalltext = newalltext.replace(/\\n/g, '\n');
@ -200,6 +253,7 @@ $(document).ready(function () {
if (isalltext) {
clearInterval(timer);
strforcode = str_;
islastletter = true;
$("#kw-target").val("");
$("#kw-target").attr("disabled", false);
autoresize();
@ -207,26 +261,29 @@ $(document).ready(function () {
if (!isMobile()) $("#kw-target").focus();
}
}
let arr = strforcode.split("```");
for (var j = 0; j <= arr.length; j++) {
if (j % 2 == 0) {
arr[j] = arr[j].replace(/\n\n/g, '\n');
arr[j] = arr[j].replace(/\n/g, '\n\n');
arr[j] = arr[j].replace(/\t/g, '\\t');
arr[j] = arr[j].replace(/\n {4}/g, '\n\\t');
arr[j] = $("<div>").text(arr[j]).html();
}
}
var converter = new showdown.Converter();
newalltext = converter.makeHtml(arr.join("```"));
newalltext = newalltext.replace(/\\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;');
//let arr = strforcode.split("```");
//for (var j = 0; j <= arr.length; j++) {
// if (j % 2 == 0) {
// arr[j] = arr[j].replace(/\n\n/g, '\n');
// arr[j] = arr[j].replace(/\n/g, '\n\n');
// arr[j] = arr[j].replace(/\t/g, '\\t');
// arr[j] = arr[j].replace(/\n {4}/g, '\n\\t');
// arr[j] = $("<div>").text(arr[j]).html();
// }
//}
//var converter = new showdown.Converter();
//newalltext = converter.makeHtml(arr.join("```"));
newalltext = mdHtml.render(strforcode);
//newalltext = newalltext.replace(/\\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;');
$("#" + answer).html(newalltext);
if (document.querySelector("[id='" + answer + "']" + " pre code")) document.querySelectorAll("[id='" + answer + "']" + " pre code").forEach(el => { hljs.highlightElement(el); });
if (islastletter) MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
//if (document.querySelector("[id='" + answer + "']" + " pre code")) document.querySelectorAll("[id='" + answer + "']" + " pre code").forEach(el => { hljs.highlightElement(el); });
$("#" + answer + " pre code").each(function () {
$(this).html("<button onclick='copycode(this);' class='codebutton'>复制</button>" + $(this).html());
});
document.getElementById("article-wrapper").scrollTop = 100000;
}, 20);
}, 30);
}
if (event.data == "[DONE]") {
isalltext = true;

File diff suppressed because one or more lines are too long

2
js/jquery.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save