2011年11月18日 星期五

391 - Mark-up

標記語言(mark-up languages)為一種以文字格式組成的電腦語言,特殊的關鍵字被用來標記文字以表示字型、頁面風格、段落風格…。例如TeX, troff, HTML皆為標記語言。

本題定義一種標記語言,請你讀取該語言的原始碼並輸出其文檔。

關鍵字會以 \ 字元開頭,若其後的字元並非合法的命令,則該字元會被視為一般字元作輸出,例如 \\ 可被用來表示 \ 的輸出。以下為合法的命令:
\b
開啟或關閉粗體字字型(預設為關)。
\i
開啟或關閉斜體字型(預設為關)。
\s
設定字體大小,其後緊接著一個數字表示字體大小,若其後並非數字則維持原字體大小。
\*
開啟或關閉標記功能,若標記功能設為關閉,則其後的字串皆視為一般的文字字串(預設為開啟)。
設定字體大小的數字可以包含小數點,例如12, 9.5, 11., .5皆為視為合法的數字格式。

Input and Output

請將輸入資料的每個字元視為標記語言的原始檔,並輸出其文檔,以EOF作為結束。

Sample Input

\s18.\bMARKUP sample\b\s

\*For bold statements use the \b command.\*

If you wish to \iemphasize\i something use the \\i command.

For titles use \s14BIG\s font sizes, 14 points usually works well.

Remember that all of the commands toggle except for the \\s command.

Sample Output

MARKUP sample

For bold statements use the \b command.

If you wish to emphasize something use the \i command.

For titles use BIG font sizes, 14 points usually works well.

Remember that all of the commands toggle except for the \s command.

原文出處

沒有留言:

張貼留言