0

我想把这段代码放到 Jade 中(缩进是一个制表符):

function isSafe(number) {
    return /^\d+(\.\d+)?(e\d+)?$/i.test(number);
}

typeof number === 'string' && isSafe(number) && typeof eval(number) !== 'number'

当我这样做时,空白行消失:

pre
    code
        | function isSafe(number) {
        |    return /^\d+(\.\d+)?(e\d+)?$/i.test(number);
        | }

        | typeof number === 'string' && isSafe(number) && typeof eval(number) !== 'number'

当我这样做时,管道出现:

pre
    code
        | function isSafe(number) {
        |    return /^\d+(\.\d+)?(e\d+)?$/i.test(number);
        | }
        |
        | typeof number === 'string' && isSafe(number) && typeof eval(number) !== 'number'

当我这样做时,选项卡变成了一个空格:

pre
    code.
        function isSafe(number) {
            return /^\d+(\.\d+)?(e\d+)?$/i.test(number);
        }

        typeof number === 'string' && isSafe(number) && typeof eval(number) !== 'number'

标记它的正确方法是什么?

4

1 回答 1

3

原来管道后面需要一个空格:

pre
    code
        | function isSafe(number) {
        |    return /^\d+(\.\d+)?(e\d+)?$/i.test(number);
        | }
        |·← here
        | typeof number === 'string' && isSafe(number) && typeof eval(number) !== 'number'
于 2013-03-06T19:52:20.650 回答