(view)
| 861 | |
| 862 | // extract markdown body to html and compile to template |
| 863 | export function exportToHTML (view) { |
| 864 | const title = renderTitle(ui.area.markdown) |
| 865 | const filename = `${renderFilename(ui.area.markdown)}.html` |
| 866 | const src = generateCleanHTML(view) |
| 867 | // generate toc |
| 868 | const toc = $('#ui-toc').clone() |
| 869 | toc.find('*').removeClass('active').find("a[href^='#'][smoothhashscroll]").removeAttr('smoothhashscroll') |
| 870 | const tocAffix = $('#ui-toc-affix').clone() |
| 871 | tocAffix.find('*').removeClass('active').find("a[href^='#'][smoothhashscroll]").removeAttr('smoothhashscroll') |
| 872 | // generate html via template |
| 873 | $.get(`${serverurl}/build/html.min.css`, css => { |
| 874 | $.get(`${serverurl}/views/html.hbs`, data => { |
| 875 | const template = window.Handlebars.compile(data) |
| 876 | const context = { |
| 877 | url: serverurl, |
| 878 | title, |
| 879 | css, |
| 880 | html: src[0].outerHTML, |
| 881 | 'ui-toc': toc.html(), |
| 882 | 'ui-toc-affix': tocAffix.html(), |
| 883 | lang: (md && md.meta && md.meta.lang) ? `lang="${escapeAttrValue(md.meta.lang)}"` : null, |
| 884 | dir: (md && md.meta && md.meta.dir) ? `dir="${escapeAttrValue(md.meta.dir)}"` : null |
| 885 | } |
| 886 | const html = template(context) |
| 887 | // console.log(html); |
| 888 | const blob = new Blob([html], { |
| 889 | type: 'text/html;charset=utf-8' |
| 890 | }) |
| 891 | saveAs(blob, filename, true) |
| 892 | }) |
| 893 | }) |
| 894 | } |
| 895 | |
| 896 | // jQuery sortByDepth |
| 897 | $.fn.sortByDepth = function () { |
no test coverage detected