见我 杂函 思绪 造物 耕录

代码样式测试

2023 年 10 月 22 日

·

阅时约 3 分

时效性提醒: 本文写于 2 年前,基于当时的认知与背景。技术世界日新月异,在采纳文中观点时,敬请留意其时效性。

tl;dr: 测试一下代码样式

这是第一段代码

import { Suspense } from 'react'
import Message from './message'
import Skeleton from 'components/ui/skeleton'
import { getMessage } from './api'

export default function Page() {
  const promise = getMessage()
  return (
    <Suspense fallback={<Skeleton />}>
      <Message promise={promise} />
    </Suspense>
  )
}
console.log('标题属性示例')
<!-- src/content/index.html -->
<div>注释文件名示例</div>
echo "这个终端框架没有标题"
Write-Output "这个有一个标题!"
echo "看,没有框架!"
# 如果不覆盖,这将是一个终端框架
function Watch-Tail { Get-Content -Tail 20 -Wait $args }
New-Alias tail Watch-Tail
// Line 1 - targeted by line number
// Line 2
// Line 3
// Line 4 - targeted by line number
// Line 5
// Line 6
// Line 7 - targeted by range "7-8"
// Line 8 - targeted by range "7-8"
function demo() {
  console.log('该行被标记为已删除')
  // 这线和下一行被标记为插入
  console.log('这是第二个插入线')

  return '该行使用中性默认标记类型'
}
// labeled-line-markers.jsx
<button
  role="button"
  {...props}
  value={value}
  className={buttonClassName}
  disabled={disabled}
  active={active}
>
  {children &&
    !active &&
    (typeof children === 'string' ? <span>{children}</span> : children)}
</button>
// labeled-line-markers.jsx
<button
  role="button"
  {...props}

  value={value}
  className={buttonClassName}

  disabled={disabled}
  active={active}
>

  {children &&
    !active &&
    (typeof children === 'string' ? <span>{children}</span> : children)}
</button>
+ 该线将被标记为插入
- 这条线将被标记为已删除
  这是一条常规线
--- a/README.md
+++ b/README.md
@@ -1,3 +1,4 @@
+ 这是一个实际的差异文件
- 所有内容将保持不变
  也不会删除空格
  function thisIsJavaScript() {
    //整个块被突出显示为JavaScript,
    //我们仍然可以在其中添加差异标记!
-   console.log('要删除的旧代码')
+   console.log('新的闪亮代码!')
  }
function demo() {
  // Mark any given text inside lines
  return 'Multiple matches of the given text are supported';
}
console.log('The words yes and yep will be marked.')
echo "Test" > /home/test.txt
The word "yes" will have the letter "s" marked.
This also works for the "p" in "yep".
This block uses `/ye(?:s|p)/`, which causes the full
matching words "yes" and "yep" to be marked.
function demo() {
  console.log('These are inserted and deleted marker types');
  // The return statement uses the default marker type
  return true;
}
// Example with wrap
function getLongString() {
  return '这是一个很长的字符串,除非容器非常宽,否则很可能不适合可用空间。这是一个很长的字符串,除非容器非常宽,否则很可能不适合可用空间。'
}
// Example with wrap=false
function getLongString() {
  return '这是一个很长的字符串,除非容器非常宽,否则很可能不适合可用空间。这是一个很长的字符串,除非容器非常宽,否则很可能不适合可用空间。'
}
// 带有 preserverIndent 的示例(默认启用)
function getLongString() {
  return '这是一个很长的字符串,除非容器非常宽,否则很可能不适合可用空间。这是一个很长的字符串,除非容器非常宽,否则很可能不适合可用空间。'
}
// preserveIndent = false 的示例
function getLongString() {
  return '这是一个很长的字符串,除非容器非常宽,否则很可能不适合可用空间。这是一个很长的字符串,除非容器非常宽,否则很可能不适合可用空间。'
}
// All this boilerplate setup code will be collapsed
import { someBoilerplateEngine } from '@example/some-boilerplate'
import { evenMoreBoilerplate } from '@example/even-more-boilerplate'

const engine = someBoilerplateEngine(evenMoreBoilerplate())

// This part of the code will be visible by default
engine.doSomething(1, 2, 3, calcFn)

function calcFn() {
  // You can have multiple collapsed sections
  const a = 1
  const b = 2
  return a + b
}
// This code block will show line numbers
console.log('Greetings from line 2!')
console.log('I am on line 3')
// Line numbers are disabled for this block
console.log('Hello?')
console.log('Sorry, do you know what line I am on?')
console.log('Greetings from line 5!')
console.log('I am on line 6')