Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3403f25

Browse files
authored
Fix ToC and touch up syntax highlighting (#1106)
1 parent55beb6b commit3403f25

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

‎pgml-dashboard/src/utils/markdown.rs‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ use crate::{templates::docs::TocLink, utils::config};
33
use std::cell::RefCell;
44
use std::collections::{HashMap,HashSet};
55
use std::path::{Path,PathBuf};
6-
use std::sync::Arc;
6+
use std::sync::{
7+
atomic::{AtomicUsize,Ordering},
8+
Arc,
9+
};
710

811
use aho_corasick::{AhoCorasick,AhoCorasickBuilder,MatchKind};
912
use anyhow::Result;
@@ -13,7 +16,6 @@ use comrak::{
1316
nodes::{Ast,AstNode,NodeValue},
1417
parse_document,Arena,ComrakExtensionOptions,ComrakOptions,ComrakRenderOptions,
1518
};
16-
use convert_case::Casing;
1719
use itertools::Itertools;
1820
use lazy_static::lazy_static;
1921
use tantivy::collector::TopDocs;
@@ -26,17 +28,23 @@ use url::Url;
2628
usecrate::templates::docs::NavLink;
2729
use std::fmt;
2830

29-
pubstructMarkdownHeadings{}
31+
pubstructMarkdownHeadings{
32+
counter:Arc<AtomicUsize>,
33+
}
3034

3135
implMarkdownHeadings{
3236
pubfnnew() ->Self{
33-
Self{}
37+
Self{
38+
counter:Arc::new(AtomicUsize::new(0)),
39+
}
3440
}
3541
}
3642

3743
implHeadingAdapterforMarkdownHeadings{
3844
fnenter(&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);
4048

4149
match meta.level{
4250
1 =>format!(r#"<h1 class="h1 mb-5" id="{id}">"#),
@@ -217,7 +225,9 @@ impl SyntaxHighlighterAdapter for SyntaxHighlighter {
217225
let code =match options.lang{
218226
"postgresql" |"sql" |"postgresql-line-nums" =>{
219227
lazy_static!{
220-
static refSQL_KEYS:[&'staticstr;66] =[
228+
static refSQL_KEYS:[&'staticstr;68] =[
229+
"PARTITION OF",
230+
"PARTITION BY",
221231
"CASCADE",
222232
"INNER ",
223233
"ON ",
@@ -285,7 +295,9 @@ impl SyntaxHighlighterAdapter for SyntaxHighlighter {
285295
"pgml.predict",
286296
"pgml.transform",
287297
];
288-
static refSQL_KEYS_REPLACEMENTS:[&'staticstr;66] =[
298+
static refSQL_KEYS_REPLACEMENTS:[&'staticstr;68] =[
299+
r#"<span class="syntax-highlight">PARTITION OF</span>"#,
300+
r#"<span class="syntax-highlight">PARTITION BY</span>"#,
289301
"<span class=\"syntax-highlight\">CASCADE</span>",
290302
"<span class=\"syntax-highlight\">INNER </span>",
291303
"<span class=\"syntax-highlight\">ON </span>",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp