Skip to content

Commit

Permalink
Merge pull request #435 from kac89/dev
Browse files Browse the repository at this point in the history
up & fixes
  • Loading branch information
kac89 authored Nov 14, 2024
2 parents b6f2965 + 4136593 commit 021e316
Show file tree
Hide file tree
Showing 7 changed files with 1,322 additions and 40 deletions.
8 changes: 5 additions & 3 deletions src/app/report/report.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3019,9 +3019,11 @@ Date | Description
{ "filename": "jquery/3.6.3/jquery.min.js", "integrity": "sha512-STof4xm1wgkfm7heWqFJVn58Hm3EtS31XFaagaa8VMReCXAkQnJZ+jEy8PCC/iT18dFy95WcExNHFTqLyp72eQ==" },
{ "filename": "crypto-js/4.1.1/crypto-js.min.js", "integrity": "sha512-E8QSvWZ0eCLGk4km3hxSsNmGWbLtSCSUcewDQPQWZF6pEU8GlT8a5fF32wOl1i8ftdMhssTrF/OhyGWwonTcXA==" },
{ "filename": "bootstrap/5.2.3/js/bootstrap.bundle.min.js", "integrity": "sha512-i9cEfJwUwViEPFKdC1enz4ZRGBj8YQo6QByFTF92YXHi7waCqyexvRD75S5NVTsSiTv7rKWqG9Y5eFxmRsOn0A==" },
{ "filename": "marked/4.2.5/marked.min.js", "integrity": "sha512-5JZDwulT+S/K8p/KO4tikNKA5t6Ebb+tqPwT7Ma+lVpJuS4G+Z0lSktWcl8hymXeFqCprGEuKGOCrKjyulql/A==" },
{ "filename": "marked/15.0.0/marked.min.js", "integrity": "sha512-/tpw1ej/DTEJDoX8qZM1YY8H9bz2+2T9nhojBmizu9JDVNvjXvgA3zfRjVF96V3bwK6Uf3eIqrYKIKRZx203iA==" },
{ "filename": "dompurify/2.4.1/purify.min.js", "integrity": "sha512-uHOKtSfJWScGmyyFr2O2+efpDx2nhwHU2v7MVeptzZoiC7bdF6Ny/CmZhN2AwIK1oCFiVQQ5DA/L9FSzyPNu6Q==" },
{ "filename": "Chart.js/4.4.0/chart.umd.js", "integrity": "sha512-6HrPqAvK+lZElIZ4mZ64fyxIBTsaX5zAFZg2V/2WT+iKPrFzTzvx6QAsLW2OaLwobhMYBog/+bvmIEEGXi0p1w==" }
{ "filename": "Chart.js/4.4.0/chart.umd.js", "integrity": "sha512-6HrPqAvK+lZElIZ4mZ64fyxIBTsaX5zAFZg2V/2WT+iKPrFzTzvx6QAsLW2OaLwobhMYBog/+bvmIEEGXi0p1w==" },
{ "filename": "highlight.js/11.10.0/highlight.min.js", "integrity": "sha512-6yoqbrcLAHDWAdQmiRlHG4+m0g/CT/V9AGyxabG8j7Jk8j3r3K6due7oqpiRMZqcYe9WM2gPcaNNxnl2ux+3tA==" },
{ "filename": "marked-highlight/2.2.1/index.umd.min.js", "integrity": "sha512-T5TNAGHd65imlc6xoRDq9hARHowETqOlOGMJ443E+PohphJHbzPpwQNBtcpmcjmHmQKLctZ/W3H2cY/T8EGDPA==" }

];
let ciphertext = "";
Expand Down Expand Up @@ -3091,7 +3093,7 @@ Date | Description
res = res.replace("<depstyle></depstyle>", css_String);
css_String = "";

of("jquery/3.6.3/jquery.min.js", "crypto-js/4.1.1/crypto-js.min.js", "bootstrap/5.2.3/js/bootstrap.bundle.min.js", "marked/4.2.5/marked.min.js", "dompurify/2.4.1/purify.min.js", "chart-js/4.4.0/chart.js")
of("jquery/3.6.3/jquery.min.js", "crypto-js/4.1.1/crypto-js.min.js", "bootstrap/5.2.3/js/bootstrap.bundle.min.js", "marked/15.0.0/marked.min.js", "dompurify/2.4.1/purify.min.js", "chart-js/4.4.0/chart.js", "highlight.js/11.10.0/highlight.min.js", "marked-highlight/2.2.1/index.umd.min.js")
.pipe(
concatMap(ind => {
let obs1 = this.http.get('/assets/res/' + ind, { responseType: 'text' })
Expand Down
106 changes: 77 additions & 29 deletions src/assets/html_report_v2_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,16 @@
font-size: 15px;
background-color: #f0f1f2;
display: block;
white-space: pre;
-webkit-overflow-scrolling: touch;
overflow-x: scroll;
max-width: 100%;
min-width: 100px;
padding-left: 5px;
border-left: 12px solid #16bf6e;
border-radius: 5px;
white-space: pre-wrap; /* Since CSS 2.1 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}

pre {
Expand All @@ -100,6 +102,30 @@
border-left: 3px solid #ccc;
}

/* highlight.js style*/
pre code.hljs{display:block;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#fff;color:#000}.hljs-comment,.hljs-quote,.hljs-variable{color:green}.hljs-built_in,.hljs-keyword,.hljs-name,.hljs-selector-tag,.hljs-tag{color:#00f}.hljs-addition,.hljs-attribute,.hljs-literal,.hljs-section,.hljs-string,.hljs-template-tag,.hljs-template-variable,.hljs-title,.hljs-type{color:#a31515}.hljs-deletion,.hljs-meta,.hljs-selector-attr,.hljs-selector-pseudo{color:#2b91af}.hljs-doctag{color:grey}.hljs-attr{color:red}.hljs-bullet,.hljs-link,.hljs-symbol{color:#00b0e8}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}

.tablemd {
width: 100%;
border: 0px;
border-collapse: collapse;
border: 1px solid #f0f1f2;
}

thead.tablemd {
border: 1px solid #f0f1f2;
background-color: #f0f1f2;
padding: 8px;
}

.tableb {
border: 1px solid #f0f1f2;
padding: 8px;
}

.titlepad {
padding-left: 10px;
}

</style>
<style>
Expand Down Expand Up @@ -520,44 +546,66 @@ <h5 class="modal-title" style="display: flex;" id="exampleModalLongTitle">
function genreport(obj) {

// console.log(obj);

const { Marked } = globalThis.marked;
const { markedHighlight } = globalThis.markedHighlight;

const marked = new Marked(
markedHighlight({
emptyLangClass: 'hljs',
langPrefix: 'hljs language-',
highlight(code, lang, info) {
const language = hljs.getLanguage(lang) ? lang : 'plaintext';
return hljs.highlight(code, { language }).value;
}
})
);
// add Markdown rendering
const renderer = new marked.Renderer();

renderer.code = function (code, infostring, escaped) {
return `<code>` + DOMPurify.sanitize(code) + `</code>`;
renderer.code = function (token) {
return `<pre class="hljs"><code>` + DOMPurify.sanitize(token.text) + `</code></pre>`;
};

renderer.table = function (header, body) {
const table = `
<table class="table">
<thead>${header}</thead>
<tbody>${body}</tbody>
</table>
`;
return table;
};
renderer.blockquote = function (token) {
return `<blockquote><p>` + DOMPurify.sanitize(token.text) + `</p></blockquote>`;
};

renderer.blockquote = function (quote) {
return `<blockquote>` + DOMPurify.sanitize(quote) + `</blockquote>`;
renderer.image = function (token) {
//return `<img src="` + DOMPurify.sanitize(token.href) + `" alt="` + DOMPurify.sanitize(token.text) + `" title="` + DOMPurify.sanitize(token.title) + `">`;
//disable image parse
return DOMPurify.sanitize(token.href);
};

renderer.link = function( href, title, text ) {
renderer.link = function( token ) {

try {
var prot = decodeURIComponent(unescape(href))
.replace(/[^\w:]/g, '')
.toLowerCase();
} catch (e) {
return text;
}
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
return text;
}
try {
var prot = decodeURIComponent(unescape(token.href))
.replace(/[^\w:]/g, '')
.toLowerCase();
} catch (e) {
return token.text;
}
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
return token.text;
}

return '<a target="_blank" rel="nofollow" href="'+ DOMPurify.sanitize(href) +'" title="' + DOMPurify.sanitize(title) + '">' + DOMPurify.sanitize(text) + '</a>';
return '<a target="_blank" class="active-link" rel="nofollow" href="'+ DOMPurify.sanitize(token.href) +'" title="' + DOMPurify.sanitize(token.title) + '">' + DOMPurify.sanitize(token.text) + '</a>';
}

renderer.table = function(token) {

const header = token.header.map((res) => {
return "<th class='titlepad'>"+DOMPurify.sanitize(res.text)+"</th>";
}).join("");

const body = token.rows.map((res) => {
return "<tr>" + res.map((res2) => {
return "<td class='tableb'>"+DOMPurify.sanitize(res2.text)+"</td>";
}).join("") + "</tr>";
}).join("");

return "<div class='table-responsive'><table class='tablemd'><thead class='tablemd'><tr>" + header + "</tr></thead><tbody>" + body + "</tr></tbody></table></div>";
}
$("title").text(obj.report_name);

if (obj.report_settings.report_logo.logo != "") {
Expand Down
Loading

0 comments on commit 021e316

Please sign in to comment.