Skip to content

Commit

Permalink
We need to print the id so it can be excluded in the users mdlinker.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanpeach committed Nov 19, 2024
1 parent 8da486b commit 99c8873
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/rules/broken_wikilink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,16 @@ impl Visitor for BrokenWikilinkVisitor {
let wikilinks = self.wikilinks_visitor.wikilinks.clone();
for wikilink in wikilinks {
let alias = wikilink.alias;
let id = format!("{CODE}::{filename}::{alias}");
if !self.alias_table.contains_key(&alias) {
self.broken_wikilinks.push(
BrokenWikilink::builder()
.id(format!("{CODE}::{filename}::{alias}").into())
.src(NamedSource::new(path.to_string_lossy(), source.to_string()))
.wikilink(wikilink.span)
.advice(format!(
"Create a page or alias on an existing page for '{alias}' (case insensitive), or fix the wikilinks spelling"
"Create a page or alias on an existing page for '{alias}' (case insensitive), or fix the wikilinks spelling.\nid: {id:?}"
))
.id(id.into())
.src(NamedSource::new(path.to_string_lossy(), source.to_string()))
.wikilink(wikilink.span)
.alias(alias)
.build(),
);
Expand Down
6 changes: 6 additions & 0 deletions src/rules/duplicate_alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ pub enum DuplicateAlias {
/// Put an exact copy but using the other file in src
#[related]
other: Vec<Self>,

/// Just some advice
#[help]
advice: String,
},
}
impl ReportTrait for DuplicateAlias {
Expand Down Expand Up @@ -301,11 +305,13 @@ impl DuplicateAlias {
);

Ok(DuplicateAlias::FileContentContentDuplicate {
advice: format!("id: {id:?}"),
id: id.clone().into(),
other_filename: get_filename(file2_path),
src: NamedSource::new(file1_path.to_string_lossy(), file1_content.to_string()),
alias: file1_content_span,
other: vec![DuplicateAlias::FileContentContentDuplicate {
advice: format!("id: {id:?}"),
id: id.into(),
other_filename: get_filename(file1_path),
src: NamedSource::new(file2_path.to_string_lossy(), file2_content.to_string()),
Expand Down
9 changes: 5 additions & 4 deletions src/rules/unlinked_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,16 @@ impl Visitor for UnlinkedTextVisitor {
) -> std::result::Result<(), FinalizeError> {
for (alias, span) in &mut self.new_unlinked_texts {
let filename = get_filename(path);
let id = format!("{CODE}::{filename}::{alias}");
self.unlinked_texts.push(
UnlinkedText::builder()
.id(ErrorCode::new(format!("{CODE}::{filename}::{alias}")))
.advice(format!(
"Consider wrapping it in a wikilink, like: [[{alias}]]\nNOTE: If running in --fix, you may need to run fix more than once to fix all unlinked text errors.\n I recommend doing this one at a time.\nREF: https://github.com/ryanpeach/mdlinker/issues/44\nid: {id:?}"
))
.id(id.into())
.src(NamedSource::new(path.to_string_lossy(), source.to_string()))
.alias(alias.clone())
.span(*span)
.advice(format!(
"Consider wrapping it in a wikilink, like: [[{alias}]]\nNOTE: If running in --fix, you may need to run fix more than once to fix all unlinked text errors.\n I recommend doing this one at a time.\nREF: https://github.com/ryanpeach/mdlinker/issues/44"
))
.build(),
);
}
Expand Down

0 comments on commit 99c8873

Please sign in to comment.