-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP]: Analysis Input - Simulates Rendered Text
Strips out link and image URLs, table markup, and other non-visible items that distract the analysis, giving false results. For example, URLs can be a source of many completion suggestions for numbers.
- Loading branch information
1 parent
c5be2f5
commit 9b430fd
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Extension { #name : #MailMessage } | ||
|
||
{ #category : #'*VirtualStash-Core' } | ||
MailMessage >> vsAnalysisInput [ | ||
|
||
^ self bodyRlHtml | ||
ifNotNil: [ :html | html vsAnalysisInput ] | ||
ifNil: [ self bodyTextFormatted ] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Extension { #name : #RlHTML } | ||
|
||
{ #category : #'*VirtualStash-Core' } | ||
RlHTML >> vsAnalysisInput [ | ||
"Return 'just the plain text the user would see if rendered'" | ||
|
||
^ PBApplication uniqueInstance newCommandStringFactory | ||
bindingAt: #htmlString put: self contents; | ||
script: 'import html2text | ||
text_maker = html2text.HTML2Text() | ||
text_maker.ignore_links = True | ||
text_maker.ignore_images = True | ||
text_maker.ignore_tables = True | ||
text_maker.ignore_emphasis = True'; | ||
resultExpression: 'text_maker.handle(htmlString)'; | ||
sendAndWait | ||
|
||
"Reference: https://github.com/Alir3z4/html2text/blob/master/docs/usage.md#using-options" | ||
] |