Jump to content
meyer.wil

Syntax highlight, or style which does not alter font

Recommended Posts

10 minutes ago, walt.farrell said:

I'm curious, Mike, whether you need to use Paste Special? I would think it would be better for Publisher to automatically picks the most feature-rich version in the clipboard, but if that were happening you should just be able to do a Paste.

No, I don't because APub will paste by default the top choice, which is RTF in this case. Mainly I was just pointing out that if RTF is available from the host application, it will be available to the receiving application and so shows up as a choice when using Paste Special.

My text editor places both the formats on the clipboard if choosing to do so, else only Unicode format is copied. And while that works great for what I usually use, it is unformatted text.

But really, the paste to Word/LibreOffice Writer, copy/paste into APub takes just a second or two longer and that should work for everyone. As I showed above, then the style desired can be applied and Bob's your uncle...

Share this post


Link to post
Share on other sites
39 minutes ago, MikeW said:

My programming text editor on the right, APub on the left and I had already used Paste Special.

Uhm, I may be missing something here – can I ask you where to find Paste Special? I seem unable to open the dialog your screenshot shows.

Thanks!

Share this post


Link to post
Share on other sites

I use a PC...it may be a Mac thing as to it not being available. Bummer.

So does pasting into Word or LibreOffice Writer carry over the syntax colors? If so, does copying/pasting from either word processor into APub work? 

Share this post


Link to post
Share on other sites

Very weird indeed! I would have expected a 1:1 match between platforms.

I've not used Word or LibreOffice as a bridge but Apple Pages (so it's VSCode -> Pages -> APub), and it seems to work. As I wrote, even if I do some InDesign stuff I'm not experienced enough to know how page design applications deal with code syntax highlighting, hence the question about the opportunity of a feat. request.

Thanks!

Share this post


Link to post
Share on other sites
Just now, Davide.Barranca said:

... I'm not experienced enough to know how page design applications deal with code syntax highlighting ...

Good there is a work-around that works. I would recommend actually creating a new post in the Request forum.

fwiw, neither ID nor QXP have Paste Special and the actual RTF coding is what is pasted. RTF files are basically plain text with formatting code. Whether I'm using a snippet or full code, I paste code into Word from my editor. Then that Word file gets converted to tagged text, which is then placed into the layout application.

Share this post


Link to post
Share on other sites
On 9/19/2019 at 1:12 AM, Davide.Barranca said:

I've not used Word or LibreOffice as a bridge but Apple Pages (so it's VSCode -> Pages -> APub), and it seems to work. As I wrote, even if I do some InDesign stuff I'm not experienced enough to know how page design applications deal with code syntax highlighting, hence the question about the opportunity of a feat. request.

It much depends. I use mostly Visual Studio and copy pasting using the Clipboard from there to InDesign and Affinity Publisher works really well, as the formatting comes as RTF:

syntax_coloring_vs_apub.thumb.jpg.9e3b97bf1884c649102e68131351e55a.jpg

syntax_coloring_vs_id.thumb.jpg.29605ab0bec2726ec44e251e154153d8.jpg

Visual Studio Code seems to use HTML when copying the code to Clipboard, so that would not result in syntax coloring be retained, neither in InDesign (CS6), nor in Affinity Publisher, but if the receiving app supports HTML, like Word, pasting first there, and copying again (as RTF) would allow you to paste syntax coloring also in InDesign  or Affinity Publisher.

As for other code editors, e.g. Notepad++, which supports syntax coloring for many languages, I have not managed to copy paste information including syntax coloring to neither InDesign or Affinity Publisher. The same applies to Brackets.

QuarkXPress (2018) does not seem to support pasting of colored RTF, at all.

So if there is no plugin in the code-editor that supports RTF when copying syntax colored code to the Clipboard, I guess there is not an easy way to get colored code in page layout apps. HTML would work if you use Word (or Pages) as an intermediary tool.

EDIT: Using LibreOffice seems to work equally well as an intermediary editor. I do not have currently XCode installed on my mac so I could not test this but if XCode is not an overkill for the job, I'd suppose it supports RTF when exchanging data via Clipboard.

 

Share this post


Link to post
Share on other sites
1 hour ago, Lagarto said:

...QuarkXPress (2018) does not seem to support pasting of colored RTF, at all.

I don't know if formatting will come into Q2019 with the October update from a text editor, but it will bring with it the copy/paste of rtf from Word itself.

Share this post


Link to post
Share on other sites
18 minutes ago, MikeW said:

I don't know if formatting will come into Q2019 with the October update from a text editor, but it will bring with it the copy/paste of rtf from Word itself.

Good to know. And I'd suppose it does, as I do not think that it matters which application is the source for the RTF formatted data placed on the Clipboard(?).

Share this post


Link to post
Share on other sites
On 9/12/2019 at 11:59 PM, meyer.wil said:

From Delphi, using a plug-in which copies formatted to the clipboard.

Which plug-in? There is one that is free and supports both HTML and RTF formatting (available for all Delphi versions starting from 3 and up to 10.1):

https://www.tmssoftware.com/site/tmsiderichclip.asp

I have pretty old Delphi (XE7), but it works just fine, and you can copy syntax highlighted code directly from Delphi to Affinity Publisher or InDesign:

syntax_coloring_delphi.jpg.d1650c643feb406b6086629018cb1e52.jpg

syntax_coloring_delphi_apub.thumb.jpg.b267678b44e8bb83f2e410836aa731ea.jpg

Share this post


Link to post
Share on other sites
1 hour ago, Davide.Barranca said:

I doubt it would ever have high priority, but one should always try.

I replied on that forum, but repeat the same information here, too: on macOS, you can use Xcode to copy paste syntax colored code directly from the editor to Affinity Publisher. That is, Xcode does support RTF formatting when it copies the code onto the Clipboard. HTML and Markdown support, in due time, would of course be a nice addition!

Share this post


Link to post
Share on other sites

An update worth noting if you're using Notepad++ (v 7.7.0 or 7.7.1 ). The currrent version of the NppExport plug-in (0.2.8) that is supposed to be copy syntax highlighting in RTF (and HTML format) does not include coloring, but an updated version (not yet automatically managed by Notepad++) 0.2.9 does (as do earlier versions of Notepad ++ with earlier plug-in versions):

https://github.com/chcg/NPP_ExportPlugin/releases/tag/0.2.9.21

This is probably the most versatile tool for transferring customizable code highlighting of any of the many supported languages (or ones for which you have added support yourself) from a source file to Affinity Publisher.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

These are the Terms of Use you will be asked to agree to if you join the forum. | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.