MCPcopy Index your code
hub / github.com/hackmdio/codimd / generateCleanHTML

Function generateCleanHTML

public/js/extra.js:812–849  ·  view source on GitHub ↗
(view)

Source from the content-addressed store, hash-verified

810window.removeDOMEvents = removeDOMEvents
811
812function generateCleanHTML (view) {
813 const src = view.clone()
814 const eles = src.find('*')
815 // remove syncscroll parts
816 eles.removeClass('part')
817 src.find('*[class=""]').removeAttr('class')
818 eles.removeAttr('data-startline data-endline')
819 src.find("a[href^='#'][smoothhashscroll]").removeAttr('smoothhashscroll')
820 // remove gist content
821 src.find('code[data-gist-id]').children().remove()
822 // disable todo list
823 src.find('input.task-list-item-checkbox').attr('disabled', '')
824 // replace emoji image path
825 src.find('img.emoji').each((key, value) => {
826 let name = $(value).attr('alt')
827 name = name.substr(1)
828 name = name.slice(0, name.length - 1)
829 $(value).attr('src', `https://cdn.jsdelivr.net/npm/@hackmd/emojify.js@2.1.0/dist/images/basic/${name}.png`)
830 })
831 // replace video to iframe
832 src.find('div[data-videoid]').each((key, value) => {
833 const id = $(value).attr('data-videoid')
834 const style = $(value).attr('style')
835 let url = null
836 if ($(value).hasClass('youtube')) {
837 url = 'https://www.youtube.com/embed/'
838 } else if ($(value).hasClass('vimeo')) {
839 url = 'https://player.vimeo.com/video/'
840 }
841 if (url) {
842 const iframe = $('<iframe frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>')
843 iframe.attr('src', url + id)
844 iframe.attr('style', style)
845 $(value).html(iframe)
846 }
847 })
848 return src
849}
850
851export function exportToRawHTML (view) {
852 const filename = `${renderFilename(ui.area.markdown)}.html`

Callers 2

exportToRawHTMLFunction · 0.85
exportToHTMLFunction · 0.85

Calls 1

removeMethod · 0.80

Tested by

no test coverage detected