diff options
author | 2025-01-07 12:36:05 +0800 | |
---|---|---|
committer | 2025-01-07 12:36:05 +0800 | |
commit | 4d88ef666eee1b6f191f6e85b00acf8d5a2d1899 (patch) | |
tree | 68391846bae84f9546b0d089c012afc336a6e6bd /code/cpppp.md | |
parent | 11e64c5804b696f170b9d5d881befbabc4a4e85c (diff) | |
download | myweb-new_highlightjs.tar.gz myweb-new_highlightjs.zip |
highlight don't use auto-detect but given languagenew_highlightjs
In this commit, lot's of things is changed. Hope they all runs
currectly.
Now highlight.js is supporting more and more proguam languages, but
the auto detection always go wrong, even for common languages like c,
bash, python, makefile.
Use Given Language
------------------
As you know, I always write markdown and convert to html by pandoc. In
the old, "```cpp" in markdown will be deleted first to keep the embeded
code clean and not highlighted, then I can use highlight.js. But this
causes that html document doesn't know the language.
This time, md2html.sh is changed: pandoc use "--no-highlight"
argument to keep code clean, and it will output like this:
```html
<pre class="cpp"><code>...</code></pre>
```
Although there may be other tags between `<code></code>`, it's clear
that `<pre class="xxx"><code>` is nested tightly, except some space
characters or \n.
Then, sed deal with the whole doc(not line by line), replace `<pre
class="xxx"><code>` with `<pre><code class="language-xxx">`. That's it!
Math Formula
------------
Math formular is also a problem during convertion by pandoc. In the old
it's dealed menually. Now pandoc use "--mathjax=none", then formula is
no longer showed by pandoc, but only `<span class="math xxx">\( formula \)</span>`.
And the math tool I used will deal with it.
Mermaid picture
----------------
pandoc doesn't support convert mermaid in markdown to html picture.
Let's have a warning!
Diffstat (limited to 'code/cpppp.md')
-rw-r--r-- | code/cpppp.md | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/code/cpppp.md b/code/cpppp.md index 50f5cba..046fcad 100644 --- a/code/cpppp.md +++ b/code/cpppp.md | |||
@@ -1,6 +1,6 @@ | |||
1 | # 第二章 | 1 | # 第二章 |
2 | 2 | ||
3 | - 在 C++中,$main$函数括号中使用`void`关键字表明拒绝任何参数,而空括号表示对是否接受参数保持沉默。 | 3 | - 在 C++中,`main`函数括号中使用`void`关键字表明拒绝任何参数,而空括号表示对是否接受参数保持沉默。 |
4 | - 连续赋值将从右向左进行。 | 4 | - 连续赋值将从右向左进行。 |
5 | - 输出拼接长字符串可以如下书写: | 5 | - 输出拼接长字符串可以如下书写: |
6 | 6 | ||
@@ -410,7 +410,7 @@ namespace std { | |||
410 | ## 基础知识 | 410 | ## 基础知识 |
411 | 411 | ||
412 | - 函数原型:说明函数名、形参类型/名称、返回值类型 | 412 | - 函数原型:说明函数名、形参类型/名称、返回值类型 |
413 | - 其实就是$main()$之前的函数声明 | 413 | - 其实就是`main()`之前的函数声明 |
414 | - 函数原型中的函数特征标(参数列表)可以省略标识符(形参名称)而只是指出其类型 | 414 | - 函数原型中的函数特征标(参数列表)可以省略标识符(形参名称)而只是指出其类型 |
415 | 415 | ||
416 | > ~其实就是那个二锅头,兑的那个白开水~ | 416 | > ~其实就是那个二锅头,兑的那个白开水~ |
@@ -446,7 +446,7 @@ int sum_arr(int* arr, int n); | |||
446 | 446 | ||
447 | ### 将 const 用于指针 | 447 | ### 将 const 用于指针 |
448 | 448 | ||
449 | - 指针指向$const$常量,防止修改 | 449 | - 指针指向`const`常量,防止修改 |
450 | - 传参将指针本身声明为常量,防止修改指针指向的位置,但可以修改内容 | 450 | - 传参将指针本身声明为常量,防止修改指针指向的位置,但可以修改内容 |
451 | 451 | ||
452 | 优点: | 452 | 优点: |
@@ -693,9 +693,9 @@ int main() | |||
693 | } | 693 | } |
694 | ``` | 694 | ``` |
695 | 695 | ||
696 | 这并不是通过传递参数实现,而是通过文本替换实现的——$x$是“参数”的符号标记。 | 696 | 这并不是通过传递参数实现,而是通过文本替换实现的——`x`是“参数”的符号标记。 |
697 | 697 | ||
698 | 上例只有$a$输出正确,可以用括号进行改进: | 698 | 上例只有`a`输出正确,可以用括号进行改进: |
699 | 699 | ||
700 | ```c | 700 | ```c |
701 | #define square(x) ((x) * (x)) | 701 | #define square(x) ((x) * (x)) |
@@ -981,7 +981,7 @@ C++文件操作头文件 fstream,也就是“文件流”。 | |||
981 | 981 | ||
982 | ## 对象声明 | 982 | ## 对象声明 |
983 | 983 | ||
984 | ```C++ | 984 | ```cpp |
985 | ofstream ofs;//执行写操作 | 985 | ofstream ofs;//执行写操作 |
986 | ifstream ifs;//执行读操作 | 986 | ifstream ifs;//执行读操作 |
987 | fstream file;//读写都可以 | 987 | fstream file;//读写都可以 |
@@ -1021,7 +1021,7 @@ fstream file;//读写都可以 | |||
1021 | 1021 | ||
1022 | 五种方法。例程如下: | 1022 | 五种方法。例程如下: |
1023 | 1023 | ||
1024 | ```C++ | 1024 | ```cpp |
1025 | #include <iostream> | 1025 | #include <iostream> |
1026 | #include <string> | 1026 | #include <string> |
1027 | #include <fstream> | 1027 | #include <fstream> |
@@ -1074,7 +1074,7 @@ int main() | |||
1074 | `对象名 << 写入的内容;` | 1074 | `对象名 << 写入的内容;` |
1075 | 如需换行,在写入内容后加 endl 即可。例程如下: | 1075 | 如需换行,在写入内容后加 endl 即可。例程如下: |
1076 | 1076 | ||
1077 | ```C++ | 1077 | ```cpp |
1078 | #include <iostream> | 1078 | #include <iostream> |
1079 | #include <string> | 1079 | #include <string> |
1080 | #include <fstream> | 1080 | #include <fstream> |