mirror of
https://git.pumpin.online/funkpower/catena.git
synced 2026-11-24 19:32:56 +00:00
bibclean: name a web address saved as a title, and leave it alone
url_title (weight 4): a title that is an http, file or www address. The underscore repair no longer runs on an address or a path, where it turned "stranger_than_fiction.htm" into "stranger than fiction.htm" and left something that was neither a title nor an address.
This commit is contained in:
3 files changed
+30
No files matched your search
@@ -34,6 +34,10 @@ static JUNK_TITLE: LazyLock<Boundaried> = LazyLock::new(|| {
|
||||
|
||||
/// A path sitting in the title field. Distinct from a filename, which is a
|
||||
/// bare name ending in an extension.
|
||||
/// A web address saved as the title: "http://www.voxfux.com/features/…".
|
||||
static URL_TITLE: LazyLock<Regex> =
|
||||
LazyLock::new(|| pattern(r"(?i)^\W*(?:https?://|file://|www\.)\S"));
|
||||
|
||||
static PATH_TITLE: LazyLock<Regex> =
|
||||
LazyLock::new(|| pattern(r"(^[A-Za-z]:[\\/])|(\\\\[^\\]+\\)|(^/(?:home|users|mnt|tmp|var)/)"));
|
||||
|
||||
@@ -173,6 +177,7 @@ const WEIGHTS: &[(&str, u32)] = &[
|
||||
("title_in_author", 3),
|
||||
("underscore_title", 1),
|
||||
("unknown_author", 3),
|
||||
("url_title", 4),
|
||||
];
|
||||
|
||||
/// Everything wrong with a record, named.
|
||||
@@ -199,6 +204,9 @@ pub fn problems(title: Option<&str>, author: Option<&str>, isbn: Option<&str>) -
|
||||
if PATH_TITLE.is_match(title) {
|
||||
reasons.push("path_title");
|
||||
}
|
||||
if URL_TITLE.is_match(title) {
|
||||
reasons.push("url_title");
|
||||
}
|
||||
if FILENAME_TITLE.is_match(title) {
|
||||
reasons.push("filename_title");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user