如何在复制粘贴时阻止Wordpress.com删除空格?

时间:2016-01-18 04:45:04

标签: wordpress formatting copy-paste

我一直试图在Wordpress.com上发布我的帖子。

我希望在帖子中包含R控制台输出。输出格式如下:

age weight height      bmi waist_circ hip_circ waist_hip_ratio glucose cholesterol_total triglycerides hdl ldl insulin      homa ldl_by_hdl fat_pct
1  30     65    163 24.46460         80      100       0.8000000      70               198            66  58 127     4.9 0.8469136  2.1896552    28.6
2  29     54    165 19.83471         69       98       0.7040816      94               223            69  60 149     4.7 1.0908642  2.4833333    27.7
3  29     66    163 24.84098         83      100       0.8300000      79               130            61  60  58     4.1 0.7997531  0.9666667    34.7
4  29     55    163 20.70082         68      104       0.6538462      71               155            36  83  65     7.8 1.3674074  0.7831325    28.1
5  29     63    167 22.58955         70       98       0.7142857      79               183            63  52 118     5.4 1.0533333  2.2692308    29.2
6  27     63    172 21.29529         75      103       0.7281553      74               172            85  64  91     4.2 0.7674074  1.4218750    24.3

我正在使用OS X.当我将上面的内容复制到TextEdit应用程序中时,我可以清楚地看到某些值之间存在多个空格,以便使该表看起来像列调整,就像在代码段中一样以上。 (例如,第二行中6998之间有7个空格。)

当我在Wordpress.com编辑帖子部分中进行简单的复制粘贴(command + ccommand + v)时,会不断减少多个空格分为1个空格(不需要的),无论我是粘贴到段落还是代码区域都无关紧要。这使得输出看起来像NON-adjuested,例如:

 age weight height bmi waist_circ hip_circ waist_hip_ratio glucose cholesterol_total triglycerides hdl ldl insulin homa ldl_by_hdl fat_pct
1 30 65 163 24.46460 80 100 0.8000000 70 198 66 58 127 4.9 0.8469136 2.1896552 28.6
2 29 54 165 19.83471 69 98 0.7040816 94 223 69 60 149 4.7 1.0908642 2.4833333 27.7
3 29 66 163 24.84098 83 100 0.8300000 79 130 61 60 58 4.1 0.7997531 0.9666667 34.7
4 29 55 163 20.70082 68 104 0.6538462 71 155 36 83 65 7.8 1.3674074 0.7831325 28.1
5 29 63 167 22.58955 70 98 0.7142857 79 183 63 52 118 5.4 1.0533333 2.2692308 29.2
6 27 63 172 21.29529 75 103 0.7281553 74 172 85 64 91 4.2 0.7674074 1.4218750 24.3

问:如何阻止Wordpress.com删除这些空格?

2 个答案:

答案 0 :(得分:2)

您可以使用shortcodes WP.com offers,在这种情况下[code] or [sourcecode]

将代码粘贴到HTML editing mode

中非常重要
[code language="r"]
age weight height      bmi waist_circ hip_circ waist_hip_ratio glucose cholesterol_total triglycerides hdl ldl insulin      homa ldl_by_hdl fat_pct
1  30     65    163 24.46460         80      100       0.8000000      70               198            66  58 127     4.9 0.8469136  2.1896552    28.6
2  29     54    165 19.83471         69       98       0.7040816      94               223            69  60 149     4.7 1.0908642  2.4833333    27.7
3  29     66    163 24.84098         83      100       0.8300000      79               130            61  60  58     4.1 0.7997531  0.9666667    34.7
4  29     55    163 20.70082         68      104       0.6538462      71               155            36  83  65     7.8 1.3674074  0.7831325    28.1
5  29     63    167 22.58955         70       98       0.7142857      79               183            63  52 118     5.4 1.0533333  2.2692308    29.2
6  27     63    172 21.29529         75      103       0.7281553      74               172            85  64  91     4.2 0.7674074  1.4218750    24.3
[/code]

结果:


答案 1 :(得分:1)

一种选择是用 替换R表输出中出现的每个空格,这是表示不间断空格的HTML符号,然后将此内容粘贴到Wordpress HTML模式中。

Wordpress不应改变 符号,使输出看起来与从R导出时的输出方式相同。

如果你不想要替换空白的麻烦,你也可以添加一些CSS来达到同样的效果。为<div>标记创建一个新类,用于设置CSS属性white-space

<html>
<head>
<style>
div.rdata {
    white-space: pre;
} 
</style>
</head>

然后在<div>中使用此类,其中包含R:

的原始表输出
<div class="rdata">
    age weight height      bmi waist_circ hip_circ waist_hip_ratio glucose cholesterol_total triglycerides hdl ldl insulin      homa ldl_by_hdl fat_pct
    1  30     65    163 24.46460         80      100       0.8000000      70               198            66  58 127     4.9 0.8469136  2.1896552    28.6
    ...

</div>

请注意,使用这两种方法时,如果您希望表格格式正确,您也可能必须使用等宽字体(如Courier)。