@@ -3,7 +3,10 @@ use crate::{templates::docs::TocLink, utils::config};
3
3
use std:: cell:: RefCell ;
4
4
use std:: collections:: { HashMap , HashSet } ;
5
5
use std:: path:: { Path , PathBuf } ;
6
- use std:: sync:: Arc ;
6
+ use std:: sync:: {
7
+ atomic:: { AtomicUsize , Ordering } ,
8
+ Arc ,
9
+ } ;
7
10
8
11
use aho_corasick:: { AhoCorasick , AhoCorasickBuilder , MatchKind } ;
9
12
use anyhow:: Result ;
@@ -13,7 +16,6 @@ use comrak::{
13
16
nodes:: { Ast , AstNode , NodeValue } ,
14
17
parse_document, Arena , ComrakExtensionOptions , ComrakOptions , ComrakRenderOptions ,
15
18
} ;
16
- use convert_case:: Casing ;
17
19
use itertools:: Itertools ;
18
20
use lazy_static:: lazy_static;
19
21
use tantivy:: collector:: TopDocs ;
@@ -26,17 +28,23 @@ use url::Url;
26
28
use crate :: templates:: docs:: NavLink ;
27
29
use std:: fmt;
28
30
29
- pub struct MarkdownHeadings { }
31
+ pub struct MarkdownHeadings {
32
+ counter : Arc < AtomicUsize > ,
33
+ }
30
34
31
35
impl MarkdownHeadings {
32
36
pub fn new ( ) -> Self {
33
- Self { }
37
+ Self {
38
+ counter : Arc :: new ( AtomicUsize :: new ( 0 ) ) ,
39
+ }
34
40
}
35
41
}
36
42
37
43
impl HeadingAdapter for MarkdownHeadings {
38
44
fn enter ( & self , meta : & HeadingMeta ) -> String {
39
- let id = meta. content . to_case ( convert_case:: Case :: Kebab ) ;
45
+ // let id = meta.content.to_case(convert_case::Case::Kebab);
46
+ let id = self . counter . fetch_add ( 1 , Ordering :: SeqCst ) ;
47
+ let id = format ! ( "header-{}" , id) ;
40
48
41
49
match meta. level {
42
50
1 => format ! ( r#"<h1 class="h1 mb-5" id="{id}">"# ) ,
@@ -217,7 +225,9 @@ impl SyntaxHighlighterAdapter for SyntaxHighlighter {
217
225
let code = match options. lang {
218
226
"postgresql" | "sql" | "postgresql-line-nums" => {
219
227
lazy_static ! {
220
- static ref SQL_KEYS : [ & ' static str ; 66 ] = [
228
+ static ref SQL_KEYS : [ & ' static str ; 68 ] = [
229
+ "PARTITION OF" ,
230
+ "PARTITION BY" ,
221
231
"CASCADE" ,
222
232
"INNER " ,
223
233
"ON " ,
@@ -285,7 +295,9 @@ impl SyntaxHighlighterAdapter for SyntaxHighlighter {
285
295
"pgml.predict" ,
286
296
"pgml.transform" ,
287
297
] ;
288
- static ref SQL_KEYS_REPLACEMENTS : [ & ' static str ; 66 ] = [
298
+ static ref SQL_KEYS_REPLACEMENTS : [ & ' static str ; 68 ] = [
299
+ r#"<span class="syntax-highlight">PARTITION OF</span>"# ,
300
+ r#"<span class="syntax-highlight">PARTITION BY</span>"# ,
289
301
"<span class=\" syntax-highlight\" >CASCADE</span>" ,
290
302
"<span class=\" syntax-highlight\" >INNER </span>" ,
291
303
"<span class=\" syntax-highlight\" >ON </span>" ,
0 commit comments