2015-06-25 28 views
0

我正在使用jquery terminal,它工作得很好。但是,對於我的生活,我無法弄清楚格式化字符串的正確語法。Jquery終端文本格式化語法,我做錯了什麼?

的例子說

echo([string|function], [options]) — display string on terminal — (additionally if you can call this function with a function as argument it will call that function and print the result, this function will be called every time you resize the terminal or browser). There are three options raw — it will allow to display raw html, finalize — which is callback function with one argument the div container and flush — default is true, if it's false it will not print echo text to terminal until you call flush method. 

You can also use basic text formating using syntax as folow: 

[[guib;<COLOR>;<BACKGROUND>]some text] will display some text: 

[[ — open formating 
u — underline 
s — strike 
o — overline 
i — italic 
b — bold 
g — glow (using css text-shadow) 
; — separator 
color — color of text (hex, short hex or html name of the color) 
; — separator 
color — background color (hex, short hex or html name of the color) 
; — separator [optional] 
class — class adeed to format span element [optional] 
] — end of format specification 
text — text that will be formated (most of the time for internal use, when you format text that's wrap in more then one line you'll get full text in data-text attribute) 
] — end of formating 

好...我已經試過這樣的東西

terminal.echo(["s"], myText); 

terminal.echo("[[s]" + myText + "]"); 

terminal.echo([["s"], myText]); 

和其他幾個。

這可能是一個愚蠢/簡單的問題,但我真的很難過。有人能告訴我我做錯了什麼嗎?

+1

乍一看你的第二次嘗試應該可以工作,但文檔沒有說''和''是可選的。也許你應該指定它們。 –

+0

不幸的是,第二次嘗試時,我只是看到「[[s」等...作爲輸出文本的一部分 – Zack

+1

是的,這就是爲什麼我建議你指定''和''。該文件只說該類是可選的,所以它看起來其他參數是強制性的。 –

回答

2

從FrédéricHamidi得到答案,我需要包括顏色和背景,他們不是可選的。

+0

您可以跳過它們,但需要分號。例如''[[s ;;] sometext]' – jcubic

+0

請問您可以發表一個例子...我有同樣的問題,但仍不明白如何使用它... – skamsie