help log2md 中文版本

log2md

Title

log2md -- Creates enhanced logs in Markdown format with customizable features like titles, separators, and code block wrapping.

Syntax

log2md filename [, replace append title(string) ]

Options

Main

replace: Overwrite the existing file if it already exists. Cannot be used with append.

append: Append new content to an existing file. Cannot be used with replace.

title(string): Adds a custom title to the log file. Replace string with your desired title.

Description

The log2md command generates a Markdown-formatted log file. All command outputs are wrapped in code blocks, making them ideal for sharing on Markdown platforms such as GitHub or Jupyter Notebooks.

This command allows users to record logs easily, including custom titles, timestamps, and log modes (replace or append).

Usage Notes

- The log file is created in Markdown format and includes information such as timestamps, titles, and content wrapped in code blocks.

- Use log close to close the log file and complete the writing process.

- If neither replace nor append is specified, the default is replace.

- When using append, the specified file must exist; otherwise, an error will occur.

- The default separator is `---`, which corresponds to a Markdown horizontal line.

- The log2md logic for code block wrapping is as follows: After custom title input, the log content will be separated by the default `---` separator and wrapped in code blocks starting with “```”. The log ends with log close.

- When using the append option, the command will automatically check and ensure proper code block wrapping for the previous log.

- When using the replace option, only the beginning of the log will include the “```” code block marker.

Examples

Example 1 - Create a new log file with a custom title:

log2md mylog.md, replace title("My Analysis")

sysdir

sysuse auto, clear

describe

log close

- The following open2 command requires downloading, or you can manually open the Markdown file:

open2 mylog.md

shellout mylog.md

Example 2 - Append new content to an existing log file:

log2md mylog.md, append title("Additional Results")

set more on

set more off

dir

sysdir

- The following open command requires downloading.

- The open command lists and opens the current working directory and copies the directory path to the system clipboard:

sysuse auto, clear

open

log close

open2 mylog.md

Author

Wang Qiang , Xi’an Jiaotong University, China.

E-mail: 740130359@qq.com.

also see

Help:cnuse, topsis