App-Music-ChordPro

 view release on metacpan or  search on metacpan

lib/ChordPro/res/abc/abc2svg/tohtml.js  view on Meta::CPAN

		}
		if (/^<style>[^<]+<\/style>$/.test(str)) {
			h_sty = str.replace(/^<style>\n|<\/style>$/g,'')
			return
		}

		  var	cfmt = abc.cfmt(),
			header = cfmt.header,
			footer = cfmt.footer,
			topmargin = cfmt.topmargin || "1cm",
			botmargin = cfmt.botmargin || "1cm",
			media_s = '@media print {\n\
	body {margin:0; padding:0; border:0}\n\
	.newpage {page-break-before: always}\n\
	div.nobrk {page-break-inside: avoid}\n\
}',
			media_f = '@media screen {\n\
	.header, .footer, .h-sp, .f-sp {display: none}\n\
}\n\
@media print {\n\
	body {margin:0; padding:0; border:0;\n\
		counter-reset: page;\n\
		counter-increment: page; }\n\
	.newpage {page-break-before: always}\n\
	div.nobrk {page-break-inside: avoid}\n\
	.header {\n\
		position: fixed;\n\
		top: ' + cfmt.headerfont.size + 'px;\n\
		height: ' + (cfmt.headerfont.size * 2) + 'px;\n\
		' + abc.style_font(cfmt.headerfont) + ';\n\
		left: ' + cfmt.leftmargin.toFixed(1) + 'px;\n\
		width: ' + (cfmt.pagewidth - cfmt.leftmargin
				- cfmt.rightmargin).toFixed(1) + 'px\n\
	}\n\
	.footer {\n\
		position: fixed;\n\
		bottom: 0;\n\
		height: ' + (cfmt.footerfont.size * 2) + 'px;\n\
		' + abc.style_font(cfmt.footerfont) + ';\n\
		left: ' + cfmt.leftmargin.toFixed(1) + 'px;\n\
		width: ' + (cfmt.pagewidth - cfmt.leftmargin
				- cfmt.rightmargin).toFixed(1) + 'px\n\
	}\n\
	.h-sp, .f-sp {height: '
			+ (cfmt.headerfont.size * 2) + 'px}\n\
	div.page:after {\n\
		counter-increment: page;\n\
		content: counter(page);\n\
	}\n\
	.l {text-align: left}\n\
	.c {text-align: center}\n\
	.r {text-align: right}\n\
}';

		// no margin / header / footer when SVG page formatting
		if (abc.page)
			topmargin = botmargin = header = footer = 0

		abc2svg.print('<!DOCTYPE html>\n\
<html>\n\
<meta charset="utf-8"/>\n\
<meta name="generator" content="abc2svg-' + abc2svg.version + '"/>\n\
<!-- CreationDate: ' + get_date() + '-->\n\
<style>\n\
body {width:' + cfmt.pagewidth.toFixed(0) +'px}\n\
svg {display:block}\n\
p {' + set_pstyle() + 'margin-top:0}\n\
p span {line-height:' + ((cfmt.lineskipfac * 100) | 0).toString() + '%}\n' +
			((header || footer) ? media_f : media_s))
// important for chrome and --headless (abctopdf)
		if (abc.page)
			abc2svg.print('@page{size:' +
				(cfmt.pagewidth / 96).toFixed(2) + 'in ' +
				(cfmt.pageheight / 96).toFixed(2) + 'in;margin:0}')

		abc2svg.print(h_sty + '</style>\n\
<title>' + fn.replace(/.*\//,'')
			+ '</title>\n\
<body>')
		if (header || footer) {
			if (header)
				gen_hf("header", header)
			if (footer)
				gen_hf("footer", footer)

			abc2svg.print('\
<table style="margin:0" width="100%">\n\
  <thead><tr><td>\n\
    <div class="h-sp">&nbsp;</div>\n\
  </td></tr></thead>\n\
  <tbody><tr><td>')
			init_done = 2		// with header/footer
		} else {
			init_done = 1
		}

		// output the first generated string
		abc2svg.print(str)
	}

	// get the main ABC source file name
	for (var i = 0; i < args.length; i++) {
	    var	a = args[i]

		if (a[0] == '-') {
			i++
			continue
		}
		fn = a
		break
	}
}

abc2svg.abc_end = function() {
    var	font_style = abc.get_font_style()

	if (!init_done)				// if empty document
		user.img_out('')
	if (user.errtxt)
		abc2svg.print("<pre>" + clean_txt(user.errtxt) + "</pre>")
	if (font_style)				// if some %%text at the end



( run in 1.720 second using v1.01-cache-2.11-cpan-97f6503c9c8 )