Jump to content
You must now use your email address to sign in [click for more info] ×

Workflow for color syntax-highlighted computer code into Publisher


Recommended Posts

I'm looking for the best way to bring preformatted computer source code into Publisher that has color syntax highlighting.

If I paste directly into Publisher I get no color from Jupyter Notebooks or from VS Code, but I can copy from VS Code, paste into Word, copy from Word, and paste into Publisher and I get color and fonts (yay!) but this is a bit of a pain.

Anyone have best-practices for this sort of thing?

Link to comment
Share on other sites

Is there no way to copy the Formatted Text from the two editors? BBEdit copies the formatted text and pastes it into the Publisher document as locally formatted text.

Otherwise ... You would need to build a word list and set of Character Styles with the appropriate fonts and colours for the various Keywords, Numbers, Variables... Then you would have to find all the variables in your word list, all the Comments and everything else. Just not worth it, let the code editor do the heavy lifting and just copy paste into Word if that is what is needed.

If you are writing a book on Syntax colouring then it would of course be worthwhile.

Mac Pro (Late 2013) Mac OS 12.7.4 
Affinity Designer 2.4.1 | Affinity Photo 2.4.1 | Affinity Publisher 2.4.1 | Beta versions as they appear.

I have never mastered color management, period, so I cannot help with that.

Link to comment
Share on other sites

  • 9 months later...

It is true that though I explicitly copy with syntax from VS code, I still fail to paste with syntax. The only clickable choices concerning paste under the Edit menu are `paste`, `paste special` and `paste without format`, none of which successfully pasted the formatted source code on Windows platform. Maybe Mac's BBEdit is smarter here. It seems that Windows users could only managed to do it by pasting into Office Word first and then pasteing to Affinity. I wish the Affinity could grow smarter in the next version, because the functionality of pasting formatted text matters for software engineers who needs to make posters.

Link to comment
Share on other sites

I’ve just copied some C# code from Visual Studio (not VS Code), on a Windows machine, and pasted it directly into Publisher and some things are coloured – comments, using, namespace, public, class, class names, etc. – while others are not – variable names, method names, etc.
There could be some settings in VS (or VS Code) which could make things come over better; have you looked at this?

Additional: Just out of curiosity, what kind of “posters” are you creating that need syntax-coloured code?

Link to comment
Share on other sites

Yes, VS did it! It seems that the copying with format functionality of VS code differs from VS. However, it is strange that even though I change color theme of VS, the pasted text in Affinity Publisher are still rendered by the default color theme. Maybe I will still choose to go to Office Word first and then Publisher from VS code.

The kind of posters I wanna make is the collection of some useful and relevant code snippets for C++ which follow a mature design pattern. I guess the posters would be terribly boring and suffering for readers without highlighted format.

Link to comment
Share on other sites

Ah, I think I understand.
Each poster gives the viewer a ‘best practice’ example which they can re-use (or modify for use) in their code.
I can imagine that having plain single-coloured code would probably look quite boring on a poster for that sort of thing.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | 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.