You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
1.1 KiB

9 years ago
  1. var crypto = require('crypto'),
  2. util = require('util');
  3. hexo.extend.tag.register('sidenote', function(args, content) {
  4. var id = crypto.createHash('sha256').update(content).digest('hex');
  5. return util.format('<label for="%s" class="sidenote-number margin-toggle"></label>', id) +
  6. util.format('<input type="checkbox" class="margin-toggle" id="%s">', id) +
  7. '<span class="sidenote">' + hexo.render.renderSync({text: content, engine: 'md'}).replace(/<\/?p>/g, "") + "</span>";
  8. }, {ends: true});
  9. // repeated because adding several conditionals turns 2 4-line
  10. // functions into a single hard-to-follow 10-line function
  11. hexo.extend.tag.register('marginnote', function(args, content) {
  12. var id = crypto.createHash('sha256').update(content).digest('hex');
  13. return util.format('<label for="%s" class="margin-toggle">&#8853;</label>', id) +
  14. util.format('<input type="checkbox" class="margin-toggle" id="%s">', id) +
  15. '<span class="marginnote">' + hexo.render.renderSync({text: content, engine: 'md'}).replace(/<\/?p>/g, "") + "</span>";
  16. }, {ends: true});