works_ feb 21, 2025, 30263 bytes ::::: port init (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(backup-by-copying t) '(custom-enabled-themes '(modus-operandi-tinted)) '(delete-old-versions t) '(global-display-line-numbers-mode t) '(indent-tabs-mode nil) '(initial-buffer-choice "/sdcard/") '(kept-new-versions 3) '(kept-old-versions 3) '(make-backup-files t) '(modifier-bar-mode t) '(pop-up-frames 'graphic-only) '(tab-width 4) '(tool-bar-position 'bottom) '(touch-screen-display-keyboard t) '(touch-screen-extend-selection t) '(touch-screen-word-select t) '(truncate-lines nil) '(version-control t)) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. ) ;; removed settings ;; '(desktop-save-mode t) ;; https://stackoverflow.com/a/18330742 (defvar --backup-directory (concat user-emacs-directory "backups")) (if (not (file-exists-p --backup-directory)) (make-directory --backup-directory t)) (setq backup-directory-alist `(("." . ,--backup-directory))) ;; batch replacements (defun batch-replace-from-file () "Perform batch replacements using data from an input file and modify the target file in place." (interactive) ;; Prompt for input and target file paths (let ((input-file (read-file-name "Enter the input file path (search-replace pairs): ")) (target-file (read-file-name "Enter the target file path (file to modify): ")) (search-replace-pairs '())) ;; Read the input file and parse search-replace pairs (with-temp-buffer (insert-file-contents input-file) (goto-char (point-min)) (while (re-search-forward "^\\(.*?\\)\\s-*,\\(.*\\)$" nil t) (let ((search-term (match-string 1)) (replace-term (match-string 2))) (push (cons search-term replace-term) search-replace-pairs)))) ;; Reverse the list to maintain original order (setq search-replace-pairs (reverse search-replace-pairs)) ;; Read the target file and perform replacements (with-temp-buffer (insert-file-contents target-file) (goto-char (point-min)) ;; Perform replacements for each search-replace pair (dolist (pair search-replace-pairs) (let ((search-term (car pair)) (replace-term (cdr pair))) (goto-char (point-min)) (while (re-search-forward (concat "\\b" (regexp-quote search-term) "\\b") nil t) (replace-match replace-term)))) ;; Write the modified content back to the target file (write-region (point-min) (point-max) target-file)) (message "Batch replacements completed. Changes saved to %s" target-file))) ::::: termux init (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(backup-by-copying t) '(default-frame-alist '((fullwidth) (height . 32))) '(delete-old-versions t) '(desktop-save-mode t) '(global-display-line-numbers-mode t) '(indent-tabs-mode nil) '(initial-buffer-choice "/sdcard/") '(kept-new-versions 3) '(kept-old-versions 3) '(make-backup-files t) '(pop-up-frames 'graphic-only) '(tab-width 4) '(truncate-lines t) '(version-control t)) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. ) ;; https://stackoverflow.com/a/18330742 (defvar --backup-directory (concat user-emacs-directory "backups")) (if (not (file-exists-p --backup-directory)) (make-directory --backup-directory t)) (setq backup-directory-alist `(("." . ,--backup-directory))) ::::: perl scripts: ::::: for extracting citation text ::::: with or without dois found in references ::::: above each #!/usr/bin/perl there will be numbers ::::: numbers are issn numbers > 2321-1326 | 2394-112X ! 10.17727/JMSR.2022/10-36 #!/usr/bin/perl # 2321-1326 | 2394-112X ! 10.17727/JMSR.2022/10-36 use strict; use warnings; use utf8; use open ':std', ':encoding(UTF-8)'; use HTML::TreeBuilder; # For parsing HTML use HTML::Strip; # For stripping HTML tags # Hardcoded file paths my $input_file = "/storage/emulated/0/ccbys/up/oldoi.txt"; # Input file path my $output_file = "/storage/emulated/0/ccbys/up/otdoi.txt"; # Output file path my $debug_file = "/storage/emulated/0/ccbys/up/dgdoi.txt"; # Debug file path # Open input, output, and debug files open my $in_fh, '<', $input_file or die "Cannot open input file: $!"; open my $out_fh, '>', $output_file or die "Cannot open output file: $!"; open my $dbg_fh, '>', $debug_file or die "Cannot open debug file: $!"; my $citation_count = 0; # Read the entire input file into a scalar my $html_content = do { local $/; <$in_fh> }; # Parse the HTML content using HTML::TreeBuilder my $tree = HTML::TreeBuilder->new_from_content($html_content); # Initialize HTML::Strip for removing HTML tags my $hs = HTML::Strip->new(); # Find all

tags in the HTML for my $p_tag ($tree->find_by_tag_name('p')) { # Get the text content of the

tag my $citation = $p_tag->as_text(); # Remove HTML tags using HTML::Strip $citation = $hs->parse($citation); $hs->eof; # Debug: Print the processed citation print $dbg_fh "Processing citation: $citation\n"; # Skip empty citations (e.g.,

 

) next if $citation =~ /^\s*$/; # Remove [1], [2], etc., from the citation text # Updated regex to handle cases like [11], [12], etc. $citation =~ s/^\s*\[\d+\]\s*//; # Extract DOI if present my $doi = ''; if ($citation =~ /https:\/\/doi\.org\/([^\s]+)/) { $doi = $1; print $dbg_fh "Extracted DOI: $doi\n"; } # Format the output my $output_line; if ($doi) { # If DOI is present, include DOI URLs $output_line = sprintf("q%d, {%d} %s https://chooser.crossref.org/?doi=%s ! https://crossmark.crossref.org/dialog?doi=%s\n", $citation_count + 1, $citation_count + 1, $citation, $doi, $doi); } else { # If no DOI is present, exclude DOI URLs $output_line = sprintf("q%d, {%d} %s\n", $citation_count + 1, $citation_count + 1, $citation); } # Write to output file print $out_fh $output_line; print $dbg_fh "Wrote to output file: $output_line"; # Increment citation count $citation_count++; } # Clean up $tree->delete; close $in_fh; close $out_fh; close $dbg_fh; print "Processing complete. Output written to $output_file. Debug information written to $debug_file.\n"; > 0976-5042 | 0976-5050, 0973-0508 | 2213-3739 #!/usr/bin/perl # 0976-5042 | 0976-5050 ! 10.1055/s-0042-1759510 # 0973-0508 | 2213-3739 ! 10.1055/s-0041-1739477 use strict; use warnings; use utf8; use open ':std', ':encoding(UTF-8)'; use HTML::Strip; # Define input, output, and debug file paths my $input_file = "/storage/emulated/0/ccbys/up/oldoi.txt" || die "Usage: $0 \n"; my $output_file = "/storage/emulated/0/ccbys/up/otdoi.txt" || die "Usage: $0 \n"; my $debug_file = "/storage/emulated/0/ccbys/up/dgdoi.txt" || die "Usage: $0 \n"; # Open files open(my $in_fh, '<', $input_file) or die "Could not open input file '$input_file' $!"; open(my $out_fh, '>', $output_file) or die "Could not open output file '$output_file' $!"; open(my $dbg_fh, '>', $debug_file) or die "Could not open debug file '$debug_file' $!"; # Read the entire file content my $file_content = do { local $/; <$in_fh> }; # Initialize HTML stripper my $hs = HTML::Strip->new(); # Extract each citation block my @citation_blocks = split(/<\/li>/, $file_content); # Process each citation block my $count = 1; foreach my $block (@citation_blocks) { # Skip empty blocks next unless $block =~ /\S/; # Extract the DOI from within