If I want to _replace_ the contents of the current file, NOT create a
separate document, I thought this would be what I needed to do as a Text
Filter

/Users/luomat/Library/Application Support/BBEdit/Text Filters/html2text

is

/#!/bin/zsh -f
#
#
# From: Timothy J. Luoma
# Mail: luomat at gmail dot com
# Date: Mon, Apr 18, 2016 12:23

NAME="$0:t:r"

if [ -e "$HOME/.path" ]
then
source "$HOME/.path"
else
PATH=/usr/local/scripts:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
fi

/usr/local/bin/html2text "$BB_DOC_PATH"



exit 0
#
#EOF


But it does nothing.






--
TJ Luoma
TJ @ MacStories <http://www.macstories.net/author/tjluoma/>
Personal Website: luo.ma <http://luo.ma/> (aka RhymesWithDiploma.com
<http://rhymeswithdiploma.com/>)
Twitter: @tjluoma <http://twitter.com/tjluoma>


On Mon, Apr 18, 2016 at 11:35 AM, Brian Christiansen <bria...@gmail.com>
wrote:

> Patrick,
>
> Thanks for the reply, I appreciate your suggestions. Unfortunately,
> neither of those options are within my current skill set, nor do I have
> time to level them up; I am no scripter. I am a little surprised no one
> else in our community was using this script, as I thought it was fairly
> popular amongst the Markdown crowd, especially since it doesn't need
> anything setup on your Mac to run, except for having Python installed, as
> OS X has by default. You just drop the .py into the Text Filters folder,
> and the magic happens. Maybe my reply will bump this thread so someone
> familiar with this can offer how they've worked around it. If
> not, ¯\_(ツ)_/¯ and thanks for all the fish.
>
> Best,
> ~brian
>
>
>
> On Monday, April 11, 2016 at 5:10:11 PM UTC-4, Patrick Woolsey wrote:
>
>> Though I haven't used this particular tool before, I would like
>> to offer the following general observation:
>>
>> Please keep in mind that a text filter does not _have_ to be a
>> single executable file -- you can also symlink a binary, or use
>> an AppleScript, shell, or Unix code (Perl/Python/Ruby/etc)
>> `wrapper` to invoke _any_ desired executable -- and the only
>> hard requirement is that a text filter must accept input and
>> provide output as documented in the manual:
>>
>>     [from "Text Filters" on pg. 35]
>>
>>     When you apply such an item, BBEdit will pass either the
>> selected text
>>     (if any) or the contents of the entire document on STDIN to Unix
>>     executables and filters, as a reference to a 'RunFromBBEdit'
>> entry point
>>     in AppleScripts, as text input to Automator workflows, and
>> as a source
>>     to text factories. (An AppleScript script intended for use
>> as a text
>>     filter must have a 'RunFromBBEdit' handler.)
>>
>>     AppleScript scripts and Automator workflows should return a
>> string which
>>     BBEdit will use to replace the selection range, Unix filters should
>>     write to STDOUT, and the text emitted by a text factory will
>> replace the
>>     selection range.
>>
>> So, you should be able to just install the latest 'html2.txt.py'
>> as its directions indicate, and then create a suitable wrapper
>> to employ this tool as a text filter.
>>
>>
>> As an alternate approach, you could create a 'Scripts' menu
>> script to target the current (unedited) document's file via the
>> BB_DOC_PATH environment variable, then convert its contents and
>> e.g. automatically create a Markdown 'counterpart' file.
>>
>>
>> In closing, I hope this helps explain the options BBEdit offers
>> you (and anyone else inclined :) at least well enough to give
>> them a try. :-)
>>
>>
>> Regards,
>>
>>   Patrick Woolsey
>> ==
>> Bare Bones Software, Inc.             <http://www.barebones.com/>
>>
>>
>>
>> On 4/11/16 at 3:00 PM, bri...@gmail.com (Brian Christiansen) wrote:
>>
>> >For years, I used Aaron Swartz's (RIP) html2.txt.py to convert
>> >HTML docs to -- wait for it -- text. When working, it did a
>> >wonderful job leaving you with clean Markdown-formatted output,
>> >even if supplied with Google Docs' excuse for HTML export as
>> >its input.
>> >
>> ><https://github.com/html2text/html2text.py>
>> >
>> >At some point, this stopped functioning as a text filter. I'm
>> >not sure if it was a change to BBEdit or to OS X. It was
>> >probably a while ago because I tried it, it failed with an
>> >error, and I left it. Now, I have something it may be useful
>> >for, but the forks of the python script *appear* to have
>> >complexified it in a manner that it's not a single file I can
>> >just drop into the Text Filters folder of BBEdit.
>> >
>> ><https://github.com/Alir3z4/html2text/>
>> >
>> >(please correct me if I'm wrong on that one)
>> >
>> >Does anyone have this functioning on BBEdit 11.5.1 and OS X 10.11.4?
>> >
>> >Does anyone have a worthy replacement? (Converts HTML >
>> >Markdown-formatted plain text) I am aware of the the `Markup >
>> >Utilities > Translate HTML to Text…` feature of BBEdit, but
>> >unfortunately, it is not as capable. (I'd love to see the
>> >BBEdit crew bulk this up based on Aaron's work!)
>> >
>> >Thanks kindly,
>> >
>> >~brian
>> >briandigital.com | @briandigital
>>
>> --
> This is the BBEdit Talk public discussion group. If you have a
> feature request or would like to report a problem, please email
> "supp...@barebones.com" rather than posting to the group.
> Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
>
> ---
> You received this message because you are subscribed to the Google Groups
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to bbedit+unsubscr...@googlegroups.com.
> To post to this group, send email to bbedit@googlegroups.com.
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.

Reply via email to