前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Jupyter-Notebook版的博客园美化

Jupyter-Notebook版的博客园美化

作者头像
逸鹏
发布2018-07-23 17:50:07
7050
发布2018-07-23 17:50:07
举报
文章被收录于专栏:逸鹏说道逸鹏说道

文章汇总:https://www.cnblogs.com/dotnetcrazy/p/9160514.html

上级回顾:Jupyter ~ 像写文章般的 Coding(微信链接

今天早上起来把博客园样式稍微弄了下,这样Jupyter-Notebook 通过NBConvert之后,你粘贴到博客园编辑器就可以直接显示了

用Jupyter编程的好处不想再说,稍微优化了下样式,基本上对前面的兼容还不错(原文的附录中有)

别忘了JS的引用(如果你也在用Jupyter写文章,上传两个样式文件,然后引用即可

<script src="https://cdn.bootcss.com/require.js/2.1.10/require.min.js"></script> <link href="DIV样式1.css" rel="stylesheet"> <link href="DIV样式2.css" rel="stylesheet">

基本上你Jupyter-Notebook什么样子,博客园显示也是什么样子了,先随便贴几张图

最爽的是异常文本信息都可以高亮显示,如果你想看效果的话,下一篇文章就是了

目录信息(我针对Jupyter改了下之前的目录脚本,扩展里面有)

代码和提示都是文字,以前还需要一个个的贴图,现在省了大量时间。可以再联想之前说的生成html,你的github page和博客静态页面不就直接有了吗?


对了之前写的 Jupyter ~ 像写文章般的 Coding 原文链接中已经更新,扩充了GUI的方法:

扩展:如果你使用了MathJax 这一段给你参考:

  1. <!-- MathJax 相关参考 --><script src="https://cdn.bootcss.com/mathjax/2.7.1/MathJax.js"></script><script type="text/x-mathjax-config">MathJax.Hub.Config({
  2. tex2jax: {
  3. inlineMath: [ ['$','$'], ["\\(","\\)"] ],
  4. displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
  5. processEscapes: true,
  6. processEnvironments: true
  7. }, displayAlign: 'center', "HTML-CSS": {
  8. styles: {'.MathJax_Display': {"margin": 0}},
  9. linebreaks: { automatic: true }
  10. }
  11. });</script>

补充:(这样的话,前几天说的目录生成脚本就要修改一下了~)

  1. $(function () {
  2. // 生成目录索引列表
  3. var mainContent = $('#cnblogs_post_body');
  4. var h_list = $('#cnblogs_post_body h2,#cnblogs_post_body h3');//这边你可以自行修改
  5. if (mainContent.length < 1)
  6. return;
  7. if (h_list.length > 0) {
  8. var content = '<div id="navCategory">';
  9. content += '<p style="font-size:16px"><b>目录:</b></p>';
  10. content += '<ul>';
  11. for (var i = 0; i < h_list.length; i++) {
  12. var go_to_top = '<a name="_map' + i + '"></a>';
  13. $(h_list[i]).before(go_to_top);
  14. //Jupter-NoteBook
  15. var targetName = h_list[i].tagName.toLowerCase();
  16. console.log(targetName);
  17. var li2_content = '';
  18. if (targetName == 'h3') {
  19. li2_content = '<li style="padding-left: 1em;"><a href="#_map' + i + '">' + $(h_list[i]).text() + '</a></li>';
  20. } else {
  21. li2_content = '<li><a href="#_map' + i + '">' + $(h_list[i]).text() + '</a></li>';
  22. }
  23. content += li2_content;
  24. }
  25. content += '</ul>';
  26. content += '</div><p>&nbsp;</p>';
  27. content += '<p style="font-size:16px"><b>正文:</b></p>';
  28. if ($('#cnblogs_post_body').length != 0) {
  29. $($('#cnblogs_post_body')[0]).prepend(content);
  30. }
  31. }
  32. var allinfo = '<p><strong>文章汇总:<a href="https://www.cnblogs.com/dotnetcrazy/p/9160514.html" target="_blank">https://www.cnblogs.com/dotnetcrazy/p/9160514.html</a></strong></p>';
  33. $(mainContent[0]).prepend(allinfo);
  34. });

老规矩,附录见原文链接(太长了,超出文章限制)

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2018-06-21,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 我为Net狂 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档