Synchronising location in md file with preview?

54 views
Skip to first unread message

Rainer Krug

unread,
Jan 16, 2020, 7:10:15 AM1/16/20
to BBEdit Talk
Hi

until recently, I used Atom which has a great feature: it synchronises the location of the cursor in the md file with the location shown in the preview of the md file.

Is this also possible in BBEdit?

Thanks,

Rainer

PS: I moved towards BBEdit, because the startup of Atom was taking ages, because I always added new plugins, which I used once a month... In other words, I was fiddling with it in the same way I did with Emacs before that.

Steve deRosier

unread,
Jan 16, 2020, 10:48:48 AM1/16/20
to bbedit
Personally, I prefer using Marked 2 as my previewer. It can handle a wider variety of MD dialects. And while it can't synchronize the cursor, it does annotate the changed spot every time you save.

If you want to send in a feature request, the support email is at the bottom of this email.

- Steve


--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/829af20e-88e2-4045-89fe-e5666673fdbf%40googlegroups.com.

Christopher Finazzo

unread,
Jan 21, 2020, 2:23:04 PM1/21/20
to BBEdit Talk
I realize this is a pipe dream, but I would love to see something akin to Marked's ability to have a custom script handle the output and styling. In my case, I might run something like the following: 

% pdflatex $<

This produces a PDF from the filename and BBEdit's Preview could update to show the output. Currently, this requires a separate Terminal window to run the Makefile and Preview.app with the PDF open at the same time.

To that end, can a Unix worksheet do the same thing?


On Thursday, January 16, 2020 at 10:48:48 AM UTC-5, Steve wrote:
Personally, I prefer using Marked 2 as my previewer. It can handle a wider variety of MD dialects. And while it can't synchronize the cursor, it does annotate the changed spot every time you save.

If you want to send in a feature request, the support email is at the bottom of this email.

- Steve


On Thu, Jan 16, 2020 at 4:10 AM Rainer Krug <r.m....@gmail.com> wrote:
Hi

until recently, I used Atom which has a great feature: it synchronises the location of the cursor in the md file with the location shown in the preview of the md file.

Is this also possible in BBEdit?

Thanks,

Rainer

PS: I moved towards BBEdit, because the startup of Atom was taking ages, because I always added new plugins, which I used once a month... In other words, I was fiddling with it in the same way I did with Emacs before that.

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://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 bbe...@googlegroups.com.

Sam Hathaway

unread,
Jan 21, 2020, 2:52:47 PM1/21/20
to BBEdit Talk
Check out Preview Filters. See “Applying Preview Filters” in Chapter
11 of the manual.

Hope this helps.
-sam

Christopher Finazzo

unread,
Jan 21, 2020, 4:12:21 PM1/21/20
to BBEdit Talk
Oh. So. Close.

I can write a shell script that contains this line and make it execute but locating the pdftex executable in a way that TeX expects does not work. The preview window displays the console output of trying to run this against my input file.

#!/Library/TeX/texbin/pdflatex

pdflatex

Screen Shot 2020-01-21 at 3.30.51 PM.png

Patrick Woolsey

unread,
Jan 22, 2020, 2:52:41 PM1/22/20
to bbe...@googlegroups.com
On 1/21/20 at 3:32 PM, chris....@gmail.com (Christopher
Finazzo) wrote:

>Oh. So. Close.
>
>I can write a shell script that contains this line and make it
>execute but locating the pdftex executable in a way that TeX
>expects does not work. The preview window displays the console
>output of trying to run this against my input file.
>
>#!/Library/TeX/texbin/pdflatex
>
>pdflatex

I regret it's hard for me to usefully comment here since I'm not
familiar with your specific workflow; however, here's what
BBEdit expects from a preview filter. Cribbing from page 260 of
the current manual:

Creating and Using Preview Filters

Preview filters may consist of any of these three types:

* An AppleScript, with an entry point named "FilterTextForBBEditPreview".
This entry point will receive a 'unicode text' object which
is the
document's contents. If there is no
"FilterTextForBBEditPreview" entry
point, the script's run handler will be called with the
text. The script
should return a 'unicode text' result.

* A Unix executable or a symlink to any such item. (For
example, a copy
of the 'multimarkdown' binary.)

* A Unix script; for example, a Perl, Python, Ruby, or shell script.
(Any such script should contain a [ valid :-) ] shebang line.)

Both Unix scripts and Unix executables will receive the document's
contents as UTF-8 text on STDIN and should **return UTF-8 text
(ordinarily, in the form of an HTML document) to STDOUT**.
BBEdit will
then display that output in the Preview window.

so though you could also have your preview filter generate a PDF
and open that in Preview.app, these actions would necessarily be
external to BBEdit.

[PS: In place of your above, I would try a normal shell shebang
line and specify the full path to the desired binary in your
script, e.g.
====
#!/bin/sh
/Library/TeX/texbin/pdflatex
====
and if that doesn't help, then please drop a note to support
with more details and we'll be happy to take a look.]

Sam Hathaway

unread,
Jan 22, 2020, 3:33:41 PM1/22/20
to bbe...@googlegroups.com

In addition to what Patrick mentioned, I’ll add: I don’t think pdflatex is happy writing its output to stdout, or reading from stdin. You might have to write your latex code to a temporary file, call pdflatex, and then open the output file that pdflatex created and send that to stdout.

A simple script to do this would be:

#!/bin/sh

cat > tmp.latex # safe stdin (from bbedit) to a file
pdflatex tmp.latex >/dev/null # throw away pdflatex’s stdout
cat tmp.pdf # send generated pdf file to stdout (back to bbedit)

But the bigger problem is: I don’t think BBEdit can accept PDF data from a preview filter. It wants HTML. It might be possible to embed the PDF output in HTML, but I don’t know how to do that.

Personally I’d just use Skim to view the PDF output. It has an auto-reload function.

Hope this helps.
-sam

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/r480Ps-10146i-FBD1DE25A7B649DBA4FE0F9CF5BC7A3C%40Cylinder.local.

Maarten Sneep

unread,
Jan 22, 2020, 4:52:29 PM1/22/20
to bbe...@googlegroups.com
Hi,


On 2020-01-22, at 21:33, Sam Hathaway <list....@munkynet.org> wrote:

But the bigger problem is: I don’t think BBEdit can accept PDF data from a preview filter. It wants HTML. It might be possible to embed the PDF output in HTML, but I don’t know how to do that.

Personally I’d just use Skim to view the PDF output. It has an auto-reload function.



Not only that, it also is pretty easy to set up synchronisation of the cursor with your position in the preview, and the reverse: to go from preview to source.

You may want to try these scripts: https://msneep.home.xs4all.nl/latex/

Kind regards,

Maarten

Christopher Finazzo

unread,
Jan 24, 2020, 10:56:58 AM1/24/20
to BBEdit Talk
Still no luck.

As I mentioned before, the Makefile is darn close to UNIX 101: A default rule which calls pdtlatex on the input file via redirection. I realize my request is closer to something that Preview.app should handle, but short of filing a bug w/ Apple - which has even less chance of being seen - this is the next best outlet. Furthermore, I suspect that Sam is correct in his assertion about BBEdit's preview not understanding TeX input, even if it is contained in a shell script.

Maarten,

I think I remember coming across your scripts in the past but was unsure if they still worked on more modern versions of BBEdit, I'll give it a shot and see how things go.

Sam Hathaway

unread,
Jan 24, 2020, 11:19:10 AM1/24/20
to BBEdit Talk

Christopher,

Can you remind me exactly what you’re trying to do?

Is your goal to open a LaTeX file in BBEdit and select “Preview in BBEdit” to see the PDF document generated by pdflatex?

Thanks.
-sam

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://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+un...@googlegroups.com.

Rich Siegel

unread,
Jan 24, 2020, 11:22:37 AM1/24/20
to bbe...@googlegroups.com
On 1/21/20 at 3:32 PM, chris....@gmail.com (Christopher
Finazzo) wrote:

>I can write a shell script that contains this line and make it
>execute but locating the pdftex executable in a way that TeX
>expects does not work. The preview window displays the console
>output of trying to run this against my input file.

Pandoc <https://pandoc.org> can generate HTML from LaTeX, so a
filter with the correct invocation of `pandoc` may work.

R.
--
Rich Siegel Bare Bones Software, Inc.
<sie...@barebones.com> <http://www.barebones.com/>

Someday I'll look back on all this and laugh... until they
sedate me.

Christopher Finazzo

unread,
Jan 24, 2020, 11:55:16 AM1/24/20
to BBEdit Talk
That's the idea.

Per Rich's suggestion, I've tried sending this through Pandoc and it's definitely closer. My source file has a bunch of hand tweaked stuff in it, so I still need to figure out how to handle a number of special cases.
To unsubscribe from this group and stop receiving emails from it, send an email to bbe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages