Open ghost opened 5 years ago
extension: https://github.com/yzane/vscode-markdown-pdf reference: https://codepen.io/heiswayi/pen/jyKYyg
/template/template.html
</body>
<script> (function() { var pre = document.getElementsByTagName('pre'), pl = pre.length; for (var i = 0; i < pl; i++) { pre[i].innerHTML = '<span class="line-number"></span>' + pre[i].innerHTML + '<span class="cl"></span>'; var num = pre[i].innerHTML.split(/\n/).length; for (var j = 0; j < (num - 1); j++) { var line_num = pre[i].getElementsByTagName('span')[0]; line_num.innerHTML += '<span>' + (j + 1) + '</span>'; } } })(); </script>
styles/markdown-pdf.css
pre { display: block; } pre code { display: block; } pre .line-number { display: block; float: left; margin: 0 1em 0 -1em; border-right: 1px solid #aaa; text-align: right; padding:5px 0; } pre .line-number span { display: block; padding: 0 .5em 0 1em; color: #aaaaaa; line-height: 19px; font-size: 14px; } pre .cl { display: block; clear: both; }
Restart your vscode, and it's just work
How To Inject Line Number On Code Block VsCode Yzane Markdown PDF
extension: https://github.com/yzane/vscode-markdown-pdf reference: https://codepen.io/heiswayi/pen/jyKYyg
Step By Step
/template/template.html
and inject this script before</body>
.styles/markdown-pdf.css
and add this CSSRestart your vscode, and it's just work