公告 编辑器新增插入代码功能

huacnlee · 2013年08月08日 · 最后由 tonysh 回复于 2014年09月29日 · 9007 次阅读

总是发现许多新来的同学不会插入代码,一坨坨的代码直接扔上来,结果没人理他。 另外每次手机上面输入 ``` 都很麻烦,半天都没法打出来。


这是来自 @young4u_amy 的改进,现在论坛的发帖和回帖输入框上面都新增了插入代码的按钮,以后点点菜单就可以了。

如图:

不支持 Erlang 啊

#1 楼 @bhuztez 忘了你们老用的,哈哈哈,我加一下

哈哈 UI 比我那个更简洁了 👍 不过我更喜欢那个小 bug 的图标 👽

#2 楼 @huacnlee 为什么点完了语言之后 会多空出一行呢~ 强迫症看着很郁闷啊

不错,刚刚上传图片还没有呢!应该是刚上线的!

#4 楼 @zj0713001 貌似代码块之前没空行 有时会出现高亮失败 这也是 github 推荐的用法 参考 https://help.github.com/articles/github-flavored-markdown#fenced-code-blocks

For testing

p 'hello world'

#7 楼 @huacnlee Bug 图标可以时刻提醒大家注意自己的 code 不要变成 Bug,哈哈

另外有个功能,不选语言 直接点确定,会生成空的代码块,这个大家会不会经常用到?

//fucking good

#8 楼 @young4u_amy 😊 空行的问题已经修好了,正在发布

没有clojure。。。

#13 楼 @Tony612 等会儿还有的说,没有 Go

#14 楼 @huacnlee 哈哈,重口难调啊

Erlang 没高亮啊。

-module(quick_sort).
-export([quick_sort/1]).

% My Quick Sort
quick_sort([]) -> [];
quick_sort([X]) -> [X];

quick_sort([X, Y]) ->
  if
    X =< Y -> [X, Y];
    X > Y -> [Y, X]
  end;

quick_sort(List) ->
  [Mid | _] = List,

  Left = lists:filter(fun(E) -> E < Mid end, List),
  Middle = lists:filter(fun(E) -> E == Mid end, List),
  Right = lists:filter(fun(E) -> E > Mid end, List),

  lists:append(lists:append(quick_sort(Left), Middle), quick_sort(Right)).
Erlang ! got.
# so cooooool
puts 'hello world'
console.log('hh');
.hide {display: none}
coffee = []

好!好!好!顶楼主。

def test
end
匿名 #24 2013年08月08日
@huacnlee

好像仅有 Ruby 不会插入空行。其他的语言都会插入空行

p "Hello Ruby"
def fun
end
console.log('hello ruby china!');

#26 楼 @chunlea

prefix_break = ""  
if txtBox.val().length > 0
  prefix_break = "\n"
src_merged = "#{prefix_break }```#{language}\n\n```\n"

我好兴奋啊!我好兴奋啊!

#32 楼 @Rei 。。。因为全裸写真?

sudo rm -rf /

#34 楼 @blacktulip 你这是要闹哪样?

不错不错。^_^

#36 楼 @lgn21st 我不信他敢执行

$->
  test 1, 2, 3

实用啊

我也试试看

Ruby

puts "Hello World"

ERB

<%= "Hello World" %>

CSS

.hello-world{
    color: red;
}

Javascript

console.log("Hello World");

Coffee Script

console.log "Hello World"

Python

print("Hello World")

Java

System.out.println("Hello World");

Shell

echo "Hello World"

为什么插入代码会多出个空行捏~

#43 楼 @song940 你前面别留空格啊

#44 楼 @huacnlee 总觉得是不是应该有缩进 , 很少用 ``` 基本都用 Tab 控制了 , 所以 ....

alert('顶')
匿名 #48 2013年08月09日

我和我的小伙伴都惊呆了!

@huacnlee 预览出来还是有点问题

tumayun 预览出来是红色,但是显示出来是黑色。

头像裸照曝光

不体谅下 Slim/HAML 用户?

#52 楼 @oran 那种用户一定懂怎么贴代码的

#53 楼 @huacnlee 原贴代码方式保留?

55 楼 已删除
需要 登录 后方可回复, 如果你还没有账号请 注册新账号