Zoot Posted October 28, 2020 Share Posted October 28, 2020 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? Quote Link to comment Share on other sites More sharing options...
Old Bruce Posted October 28, 2020 Share Posted October 28, 2020 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. Quote 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 More sharing options...
Wenyin Wei Posted August 8, 2021 Share Posted August 8, 2021 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. Quote Link to comment Share on other sites More sharing options...
GarryP Posted August 8, 2021 Share Posted August 8, 2021 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? Quote Link to comment Share on other sites More sharing options...
Wenyin Wei Posted August 8, 2021 Share Posted August 8, 2021 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. Quote Link to comment Share on other sites More sharing options...
GarryP Posted August 8, 2021 Share Posted August 8, 2021 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.