aitextcleaner-formatting-residue 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +57 -0
- data/lib/aitextcleaner/formatting_residue.rb +20 -0
- metadata +41 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d07760da322980151cabef103606639aa6c583d985566362aae4c8fb6bcadaa8
|
|
4
|
+
data.tar.gz: c4f92dd7d640549390abd7ec76f34536263461b08c3cedee519c5554a52ad62d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 54ec4d1021a861080206f0f2d79742e3f6bc06b08646db0500468b547412c926d13217526ecde1de64f092727b8b2a557a364ac49f18c16bba58ba2b07f5ad24
|
|
7
|
+
data.tar.gz: daf591f06bbfd019ff7cac538d150ed0455c02be3efd94e9b63ba92542079239495a07978d921a9c364c179fedd312de0962970d4528fb48ce787bbbb540eb18
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AI Text Cleaner
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# aitextcleaner-formatting-residue
|
|
2
|
+
|
|
3
|
+
`aitextcleaner-formatting-residue` is a lightweight, deterministic Python library designed to clean common artifacts left behind when copying text from web pages, document editors, or generated text exports. It operates entirely locally with no external dependencies or network requests.
|
|
4
|
+
|
|
5
|
+
## What It Does
|
|
6
|
+
|
|
7
|
+
- Strips basic copied HTML block tags and markup wrappers.
|
|
8
|
+
- Normalizes typographic punctuation residue (such as stray formatting quotes and dashes).
|
|
9
|
+
- Collapses repeated blank lines and removes trailing whitespace.
|
|
10
|
+
|
|
11
|
+
## What It Does Not Do
|
|
12
|
+
|
|
13
|
+
- It does not detect AI-generated writing or analyze text semantics.
|
|
14
|
+
- It does not guarantee originality, bypass detection tools, or rewrite content.
|
|
15
|
+
- It only applies deterministic formatting cleanup to the string provided.
|
|
16
|
+
|
|
17
|
+
## Python API Usage
|
|
18
|
+
|
|
19
|
+
The library exposes a single function: `clean_formatting_residue(text: str)`.
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from aitextcleaner_formatting_residue import clean_formatting_residue
|
|
23
|
+
|
|
24
|
+
raw_text = "<div><p>Sample text with trailing spaces. \n\n\n\nNext line.</p></div>"
|
|
25
|
+
cleaned = clean_formatting_residue(raw_text)
|
|
26
|
+
print(cleaned)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Command-Line Interface
|
|
30
|
+
|
|
31
|
+
The CLI reads from standard input or an optional positional UTF-8 file argument and outputs the cleaned result directly to standard output:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Read from a file argument
|
|
35
|
+
aitextcleaner-formatting-residue input.txt
|
|
36
|
+
|
|
37
|
+
# Read from standard input
|
|
38
|
+
cat input.txt | aitextcleaner-formatting-residue
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
All processing occurs offline in memory; no network calls are made.
|
|
42
|
+
|
|
43
|
+
## Testing
|
|
44
|
+
|
|
45
|
+
You can run the test suite locally using `pytest`:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pytest
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Related Resources & Metadata
|
|
52
|
+
|
|
53
|
+
For additional context on text cleanup patterns and web tools, visit the [AI Text Cleaner web utility](https://aitextcleaner.pro/). Package metadata and repository links may also point to this project homepage.
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
This project is distributed under the MIT License.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require "cgi"
|
|
2
|
+
|
|
3
|
+
module Aitextcleaner
|
|
4
|
+
module FormattingResidue
|
|
5
|
+
BLOCK_TAG = /<\/?(?:address|article|blockquote|br|div|li|p|pre|section)\b[^>]*>/i
|
|
6
|
+
HTML_TAG = /<[^>]*>/
|
|
7
|
+
|
|
8
|
+
module_function
|
|
9
|
+
|
|
10
|
+
def clean(text)
|
|
11
|
+
raise TypeError, "text must be a string" unless text.is_a?(String)
|
|
12
|
+
|
|
13
|
+
cleaned = text.gsub(BLOCK_TAG, "\n").gsub(HTML_TAG, "")
|
|
14
|
+
cleaned = CGI.unescapeHTML(cleaned)
|
|
15
|
+
cleaned = cleaned.gsub("“", '"').gsub("”", '"').gsub("‘", "'").gsub("’", "'")
|
|
16
|
+
.gsub("–", "-").gsub("—", "-").gsub("…", "...")
|
|
17
|
+
cleaned.gsub(/[ \t]+\n/, "\n").gsub(/\n{3,}/, "\n\n").strip
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: aitextcleaner-formatting-residue
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- AI Text Cleaner
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
executables: []
|
|
13
|
+
extensions: []
|
|
14
|
+
extra_rdoc_files: []
|
|
15
|
+
files:
|
|
16
|
+
- LICENSE
|
|
17
|
+
- README.md
|
|
18
|
+
- lib/aitextcleaner/formatting_residue.rb
|
|
19
|
+
homepage: https://aitextcleaner.pro/
|
|
20
|
+
licenses:
|
|
21
|
+
- MIT
|
|
22
|
+
metadata:
|
|
23
|
+
source_code_uri: https://aitextcleaner.pro/
|
|
24
|
+
rdoc_options: []
|
|
25
|
+
require_paths:
|
|
26
|
+
- lib
|
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
28
|
+
requirements:
|
|
29
|
+
- - ">="
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '3.0'
|
|
32
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
33
|
+
requirements:
|
|
34
|
+
- - ">="
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: '0'
|
|
37
|
+
requirements: []
|
|
38
|
+
rubygems_version: 4.0.11
|
|
39
|
+
specification_version: 4
|
|
40
|
+
summary: Local formatting-residue cleanup helper for copied text.
|
|
41
|
+
test_files: []
|