发布片段(Smultron的附加组件)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了发布片段(Smultron的附加组件)相关的知识,希望对你有一定的参考价值。

  1. #!/usr/bin/perl -w
  2. use strict;
  3. use Frontier::Client;
  4. #
  5. # Post a snippet (add-on for Smultron)
  6. # perl smultron snipperl rpc
  7. #
  8. # (paste the script as a New Command in Tools menu, for example: Post it)
  9. # (then select lines of code and run the script, Tools -> Commands -> Post it)
  10. #
  11. # post title grabbed from first non-empty comment, if any
  12. # tags grabbed from second non-empty comment, if any
  13. # language set to first tag, if many of them, else set to bash
  14. #
  15. my $key = ''; # (your API key)
  16.  
  17. my $tempfile = '%%s';
  18. die "Please select some text " if ($tempfile =~ /^\%\%s$/);
  19.  
  20. open(FC, "<:utf8", $tempfile);
  21. my $title='no title yet';
  22. my $code = '';
  23. my $tags = '';
  24. my $language = 'bash';
  25. my $flag = 0;
  26. while (<FC>) {
  27. if (/^#[^!]s*(.+)/ && $flag == 0) {
  28. $title = $1;
  29. $flag++;
  30. }
  31. elsif (/^#[^!]s*(.+)/ && $flag == 1) {
  32. $tags = $1;
  33. $flag++;
  34. if (/(w+) (.+)/) {
  35. $language = $1;
  36. $tags = $2;
  37. }
  38. }
  39. $code = $code . $_;
  40. }
  41.  
  42. my $session = Frontier::Client->new( url => 'http://snipplr.com/xml-rpc.php', debug => 0,);
  43. my @args = ($key, $title, $code, $tags, $language);
  44. my $result = $session->call('snippet.post', @args);

以上是关于发布片段(Smultron的附加组件)的主要内容,如果未能解决你的问题,请参考以下文章

Cocoa 文本编辑组件(面向程序员)

如何阻止片段一直弹出到根片段? [导航组件]

使用Android导航组件时如何从后台获取片段?

使用导航组件将返回箭头添加到片段

从 Relay 中的动态组件获取片段

使用新的架构组件 ViewModel 在片段之间共享数据