第 6 章 Visual Studio Code

6.1 下载安装

请在Visual Studio Code官网下载该软件。

6.2 制作公开数据的README.md文件

更新于:2024-11-29

  1. 在Visual Studio Code中新建一个文本文档:
在VS Code中新建一个文本文档

图 6.1: 在VS Code中新建一个文本文档

之后,你应该看到类似的新建文件:

VS Code中的新建文本文档

图 6.2: VS Code中的新建文本文档


2. 将新建文档保存为README.md文件:

将新建文本文档另存为...

图 6.3: 将新建文本文档另存为…

在打开的对话框中,请选择保存新建文本文档的位置,并将文件命名为README.md
重命名文件为“README.md”并选择文件存储位置

图 6.4: 重命名文件为“README.md”并选择文件存储位置


3. 根据数据文件编辑README.md文件

README.md文件中,你可以添加根据数据文件的内容,添加列名称(Header)和内容描述(Description):


Header | Description
---|---
Column1 | Description of Column1
Column2 | Description of Column2
假定我们用有这样一个数据文件:
数据文件

图 6.5: 数据文件

我们相应地编辑README.md文件:


Header | Description
---|---
SubjCode | Subject Code
Trial Number | trial number
Orientation | orientation of the stimulus: `upr`: upright vs `inv`: inverted
Congruency | congruency of the trial type in complete composite task: `con`: congruent vs `inc`: incongruent
Alignment | whether the top and bottom halves of faces are aligned (`ali`) or misaligned (`mis`)
CorrectAnswer | whether the correct response was the same (`s`) or different (`d`)
Acc | whether the response was correct (`1`) or incorrect (`0`)
isSame | whether participant reported the same (`1`) or not (`0`) for that trial
RT | response time in milliseconds


4. 编辑README.md文件的同时预览效果

在编辑README.md文件的同时,你可以通过以下方式来预览效果:

  • Ctrl + Shift + V (Windows)快捷键
  • Cmd + Shift + V (Mac)快捷键
  • 右键点击README.md文件,选择Open Preview选项
右键点击`README.md`文件,选择`Open Preview`选项

图 6.6: 右键点击README.md文件,选择Open Preview选项

预览效果与下图类似:
预览md文件

图 6.7: 预览md文件


5. 将README.md文件保存为pdf文件

完成编辑README.md文件后,我们可以将其保存为或生成一个pdf文档。

5.1 在VS Code中安装Markdown PDF插件

VS Code中打开Extension

图 6.8: VS Code中打开Extension

在搜索框中输入Markdown PDF,并点击安装(Install):
搜索并安装Markdown PDF

图 6.9: 搜索并安装Markdown PDF

5.2 生成pdf文件

安装完成Markdown PDF插件后,请确保README.md已在VS Code中打开,然后通过View -> Command Palette打开Command Palette:
打开Command Palette

图 6.10: 打开Command Palette

然后在Command Palette中搜索并打开Markdown PDF: Export (pdf):
Markdown PDF Export (pdf)

图 6.11: Markdown PDF Export (pdf)

之后,你应该在VS Code右下角看到正在生成pdf文件的提示消息:
正在生成PDF文件...

图 6.12: 正在生成PDF文件…

提示消息消失后,你可以在README.md文件所在的文件夹中找到生成的pdf文件:
正在生成PDF文件...

图 6.13: 正在生成PDF文件…

生成的pdf文件效果如下:
PDF文件

图 6.14: PDF文件