上QQ阅读APP看本书,新人免费读10天
设备和账号都新为新人
pre(预定义格式文本)
HTML<pre>
元素表示预定义格式文本。在该元素中的文本通常按照原文件中的编排,以等宽字体的形式展现出来,文本中的空白符(比如空格和换行符)都会显示出来。(紧跟在<pre>
开始标签后的换行符也会被省略)
复杂的例子
1. Plain text rendering - This is a simple text block in <pre> format. - All spaces, tabs, and newlines are preserved. 2. Code snippet for (int i = 0; i < 10; i++) { Console.WriteLine($"Value: {i}"); } 3. Tables with spaces for alignment Name Age Country John Doe 25 USA Alice Smith 30 UK 张伟 35 中国 4. ASCII art _______ / \ | O O | | ^ | <-- A simple face! \_______/ 5. Special characters - HTML entities: <, >, &, " - Unicode: ✔, ✘, ☺, ☀, ✈, 🧑💻 6. Mixed languages English: Hello, World! 中文: 你好,世界! 日本語: こんにちは、世界! Español: ¡Hola, Mundo! 7. Wide characters ┌───────────┬────────────┐ │ Header │ Values │ ├───────────┼────────────┤ │ Data A │ 1234567890 │ └───────────┴────────────┘ 8. Nested tags (escaped) - <b>Bold</b> - <i>Italic</i> - <a href='example.com'>Link</a> 9. Indentation and tabs Root ├── Child 1 │ ├── Subchild 1.1 │ └── Subchild 1.2 └── Child 2 └── Subchild 2.1
简单单行代码
cd $HOME && git clone https://github.com/black-forest-labs/flux
简单多行代码
from flux.api import ImageRequest # this will create an api request directly but not block until the generation is finished request = ImageRequest("A beautiful beach", name="flux.1.1-pro") # or: request = ImageRequest("A beautiful beach", name="flux.1.1-pro", api_key="your_key_here") # any of the following will block until the generation is finished request.url # -> https:<...>/sample.jpg request.bytes # -> b"..." bytes for the generated image request.save("outputs/api.jpg") # saves the sample to local storage request.image # -> a PIL image
多行代码带缩进
using System; class Program { static void Main(string[] args) { int[] array = { 34, 7, 23, 32, 5, 62 }; Console.WriteLine("Original array:"); PrintArray(array); QuickSort(array, 0, array.Length - 1); Console.WriteLine("Sorted array:"); PrintArray(array); } static void QuickSort(int[] array, int left, int right) { if (left < right) { int pivotIndex = Partition(array, left, right); QuickSort(array, left, pivotIndex - 1); // Sort left part QuickSort(array, pivotIndex + 1, right); // Sort right part } } static int Partition(int[] array, int left, int right) { int pivot = array[right]; int i = left - 1; for (int j = left; j < right; j++) { if (array[j] <= pivot) { i++; Swap(array, i, j); } } Swap(array, i + 1, right); return i + 1; } static void Swap(int[] array, int i, int j) { int temp = array[i]; array[i] = array[j]; array[j] = temp; } static void PrintArray(int[] array) { Console.WriteLine(string.Join(", ", array)); } }
超长代码压缩为一行
function bubbleSort(arr){for(let i=0;i<arr.length;i++){for(let j=0;j<arr.length-i-1;j++){if(arr[j]>arr[j+1]){let temp=arr[j];arr[j]=arr[j+1];arr[j+1]=temp;}}}return arr;}let array=[5,3,8,4,2];console.log("Original Array:",array);console.log("Sorted Array:",bubbleSort(array));
带制表符的大型文本
$ kr scan http://192.168.195.132:8090 -w ~/api/wordlists/data/kiterunner/routes-large.kite +----------------------+------------------------------------------------------------------ -------------------+------------------------------------------------------------------ | SETTING | VALUE | +----------------------+------------------------------------------------------------------ -------------------+------------------------------------------------------------------ | delay | 0s | | full-scan | false | | full-scan-requests | 1451872 | | headers | [x-forwarded-for:127.0.0.1] | | kitebuilder-apis | [/home/hapihacker/api/wordlists/data/kiterunner/routes-large.kite] | | max-conn-per-host | 3 | | max-parallel-host | 50 | | max-redirects | 3 | | max-timeout | 3s | | preflight-routes | 11 | | quarantine-threshold | 10 | | quick-scan-requests | 103427 | | read-body | false | | read-headers | false | | scan-depth | 1 | | skip-preflight | false | | target | http://192.168.195.132:8090 | | total-routes | 957191 | | user-agent | Chrome. Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36 | +----------------------+------------------------------------------------------------------ POST 400 [ 941, 46, 11] http://192.168.195.132:8090/trade/queryTransationRecords 0cf689f783e6dab12b6940616f005ecfcb3074c4 POST 400 [ 941, 46, 11] http://192.168.195.132:8090/event 0cf6890acb41b42f316e86efad29ad69f54408e6 GET 301 [ 243, 7, 10] http://192.168.195.132:8090/api-docs -> /api-docs/?group=
63578 528&route=33616912 0cf681b5cf6c877f2e620a8668a4abc7ad07e2db
预格式文本中添加背景色
[略]
带行号的代码以及连续两个代码块
在下面第8行后,是一个新的<pre>
元素。
1 #判断s的最大值 2 for s in range(1000): 3 r = 2**s 4 a = 104513 5 even = a - 1 6 7 if even%r == 0 and s != 0: 8 print('n-1 = ',even, ', s=',s , ', r的最大值是:', s-1 ,'d= ', even/r )
1 #米勒-拉宾素性检验 2 import random 3 4 def power(x, y, p): 5 """模幂运算""" 6 res = 1 #初始化结果 7 x = x % p #如果x大于或等于p,更新x 8 while (y > 0): 9 10 #如果y是奇数,乘以x 11 if (y & 1): 12 res = (res * x) % p 13 14 #如果y是偶数(也是必须的) 15 y = y>>1 # y = y/2 16 x = (x * x) % p 17 return res 18 19 def miillerTest(d, n): 20 """单次米勒-拉宾素性检验""" 21 22 #在区间[2..n-2]内随机选择a 23 a = 2 + random.randint(1, n - 4)#极端情况下,确保n > 4 24 x = power(a, d, n) #计算a^d % n 25 26 if (x == 1 or x == n - 1): 27 return True; 28 29 while (d != n - 1): 30 x = (x * x) % n 31 d *= 2 32 33 if (x == 1): 34 return False 35 if (x == n - 1): 36 return True 37 38 return False 39 40 def isPrime( n, k): 41 """判断是否是素数""" 42 43 #极端情况 44 if (n <= 1 or n == 4): 45 return False 46 if (n <= 3): 47 return True 48 49 #计算r和d 50 d = n - 1; 51 while (d % 2 == 0): 52 d //= 2 53 54 #迭代k次 55 for i in range(k): 56 if (miillerTest(d, n) == False): 57 return False 58 return True 59 60 k = 64 61 62 print(isPrime(int(a), k)) 63 print(isPrime(1000000000061, k)) 64 print(isPrime(1000000000063, k)) 65 print(isPrime(798263, k))
代码块中有超链接注释
[略]
代码块外套无样式<div>元素
from flux.api import ImageRequest # this will create an api request directly but not block until the generation is finished request = ImageRequest("A beautiful beach", name="flux.1.1-pro") # or: request = ImageRequest("A beautiful beach", name="flux.1.1-pro", api_key="your_key_here") # any of the following will block until the generation is finished request.url # -> https:<...>/sample.jpg request.bytes # -> b"..." bytes for the generated image request.save("outputs/api.jpg") # saves the sample to local storage request.image # -> a PIL image
代码块外套简单样式<div>元素
from flux.api import ImageRequest # this will create an api request directly but not block until the generation is finished request = ImageRequest("A beautiful beach", name="flux.1.1-pro") # or: request = ImageRequest("A beautiful beach", name="flux.1.1-pro", api_key="your_key_here") # any of the following will block until the generation is finished request.url # -> https:<...>/sample.jpg request.bytes # -> b"..." bytes for the generated image request.save("outputs/api.jpg") # saves the sample to local storage request.image # -> a PIL image
/usr/local/tomcat7/conf/为证书存放位置,编辑conf/server.xml文件,取消SSL配置的注释,并添加证书路径keystoreFile和密码 keystorePass。