mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-22 20:35:20 +00:00
fix: clean typlite markers from doc strings (#2017)
When there's HTML comments in list, the markdown syntax won't be parsed as expected. This pr cleans typlite markers from doc string to avoid this behavior. <img width="654" height="223" alt="bfedf840bc92a34c44212006232a7e17" src="https://github.com/user-attachments/assets/9015952b-a5de-4d59-a8ff-61a5e3d09d1b" /> <img width="641" height="257" alt="0267db904824cf09b67234bdcb0919e7" src="https://github.com/user-attachments/assets/938fabaa-d6fe-42d4-adca-6c96b59443e2" />
This commit is contained in:
parent
14c7a92944
commit
7a9e1cfb3c
4 changed files with 27 additions and 21 deletions
|
|
@ -13,6 +13,8 @@ use crate::docs::{file_id_repr, module_docs, DefDocs, PackageDefInfo};
|
|||
use crate::package::{get_manifest_id, PackageInfo};
|
||||
use crate::LocalContext;
|
||||
|
||||
use tinymist_analysis::docs::tidy::remove_list_annotations;
|
||||
|
||||
/// Generate full documents in markdown format
|
||||
pub fn package_docs(ctx: &mut LocalContext, spec: &PackageInfo) -> StrResult<String> {
|
||||
log::info!("generate_md_docs {spec:?}");
|
||||
|
|
@ -338,14 +340,6 @@ struct ConvertResult {
|
|||
errors: Vec<String>,
|
||||
}
|
||||
|
||||
fn remove_list_annotations(s: &str) -> String {
|
||||
let s = s.to_string();
|
||||
static REG: std::sync::LazyLock<regex::Regex> = std::sync::LazyLock::new(|| {
|
||||
regex::Regex::new(r"<!-- typlite:(?:begin|end):[\w\-]+ \d+ -->").unwrap()
|
||||
});
|
||||
REG.replace_all(&s, "").to_string()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use tinymist_world::package::{PackageRegistry, PackageSpec};
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
source: crates/tinymist-query/src/hover.rs
|
||||
expression: content
|
||||
input_file: crates/tinymist-query/src/fixtures/hover/render_equation.typ
|
||||
snapshot_kind: text
|
||||
---
|
||||
Range: 12:20:12:23
|
||||
|
||||
|
|
@ -31,7 +32,7 @@ type: type
|
|||
```
|
||||
|
||||
The type of the argument.
|
||||
- <!-- typlite:begin:list-item 1 -->It can be also regarded as the condition of the proposition.<!-- typlite:end:list-item 1 -->
|
||||
- It can be also regarded as the condition of the proposition.
|
||||
|
||||
## B (positional)
|
||||
|
||||
|
|
@ -40,4 +41,4 @@ type: type
|
|||
```
|
||||
|
||||
The type of the body.
|
||||
- <!-- typlite:begin:list-item 1 -->It can be also regarded as the conclusion of the proposition.<!-- typlite:end:list-item 1 -->
|
||||
- It can be also regarded as the conclusion of the proposition.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue