আপনার Google ডক্স ডকুমেন্ট ফরম্যাট করা সহজ যতক্ষণ পর্যন্ত কোনো কোড ব্লক না থাকে। Google ডক্স কোড ব্লক যোগ করার জন্য একটি ডিফল্ট উপায় প্রদান করে না, এবং যদি আপনি তাদের সরাসরি অনুলিপি এবং পেস্ট করেন, ডিফল্ট বিন্যাসটি গন্ডগোল হয়ে যায়।
Google ডক্সে কোড স্নিপেটগুলি সঠিকভাবে ফর্ম্যাট করার জন্য, আমাদের হয় বিভিন্ন ম্যানুয়াল ওয়ার্কঅ্যারাউন্ড ব্যবহার করতে হবে বা অ্যাড-অনগুলির সাহায্য নিতে হবে৷
এই নিবন্ধটি আপনাকে দেখাবে কিভাবে Google ডক্সে ম্যানুয়ালি এবং অ্যাড-অন ব্যবহার করে কোড ব্লক ফরম্যাট করতে হয়।
গুগল ডক্সে ম্যানুয়ালি কোড ব্লকগুলি কীভাবে ফর্ম্যাট করবেন
Google ডক্সে কোড ব্লক ফরম্যাট করার বিভিন্ন উপায় আছে। তবুও, সমস্ত পদ্ধতিতে তৃতীয় পক্ষের সরঞ্জাম জড়িত। এর মানে হল যে আপনি যদি ওয়ার্কস্পেস না রেখে Google ডক্সে একটি কোড ব্লক ফর্ম্যাট করতে চান তবে তা হবে না।
Google ডক্সে একটি কোড ব্লক ম্যানুয়ালি ফর্ম্যাট করার জন্য নিম্নলিখিত তিনটি পদ্ধতি রয়েছে:
1. কিভাবে সিনট্যাক্স হাইলাইটার ব্যবহার করে Google ডক্সে কোড ব্লক ফরম্যাট করবেন
সিনট্যাক্স হাইলাইটার দিয়ে, কেউ সহজেই এর পাঠ্য বা কোডের স্টাইল পরিবর্তন করতে পারে। বেশ কিছু সিনট্যাক্স হাইলাইটার পাওয়া যায়; যাইহোক, আমরা এই উদাহরণের জন্য PinTools দ্বারা সিনট্যাক্স হাইলাইটার ব্যবহার করব।
উপরের ধাপগুলি আপনাকে এর HTML সহ হাইলাইট করা কোড প্রদান করবে।
যদিও আপনি হাইলাইট করা কোডটি সরাসরি Google ডক্সে পেস্ট করতে পারেন, তবে এটি শুধুমাত্র কোডটিকে হাইলাইট করবে এবং কোড লাইনের মধ্যে সাদা স্থান এখনও প্রদর্শিত হবে। অতএব, চূড়ান্ত বিন্যাসটি অগোছালো দেখায়, যেমনটি নীচে দেখানো হয়েছে।
আমরা শৈলীর জন্য কালো এবং ব্যাকগ্রাউন্ডের রঙের জন্য কালো বেছে নিয়েছি যাতে চূড়ান্ত আউটপুটটি নীচের মত দেখায়।
আপনি যদি সত্যিই আপনার নথির জন্য একটি উপযুক্ত বিন্যাস খুঁজে পেতে সংগ্রাম করছেন, আপনি একটি টেমপ্লেট ব্যবহার করতে পারেন। আপনার জীবনকে সহজ করতে আপনি Google ডক্সে ব্যবহার করতে পারেন এমন বিভিন্ন টেমপ্লেট কভার করে আমাদের নিবন্ধটি দেখুন।
2. কিভাবে HTML কোড ব্যবহার করে Google ডক্সে কোড ব্লক ফরম্যাট করবেন
Google ডক্সে একটি কোড ব্লক ফর্ম্যাট করার আরেকটি উপায় হল HTML কোড ব্যবহার করা। এটি করার জন্য, নিম্নলিখিত ধাপগুলি অনুসরণ করুন।
Google ডক্স সাধারণ HTML এর পরিবর্তে HTML কোড কার্যকর করার পরে ফাইলটিকে তার আসল বিন্যাসে খুলবে, যেমনটি আমরা নোটপ্যাড ফাইলে করেছি।
আপনি কোডটি অনুলিপি করতে পারেন, এটি আপনার আসল নথিতে পেস্ট করতে পারেন এবং কোড লাইন থেকে সাদা স্থান সরাতে উপরে বর্ণিত পদক্ষেপগুলি ব্যবহার করতে পারেন। ফলস্বরূপ, আপনি দেখতে পাবেন যে চূড়ান্ত আউটপুটটি পদ্ধতির সাথে প্রায় অভিন্ন।
If you don’t like changing the formatting with table properties, there is another way to do it. The goal is to format code placed in Google Docs using a Microsoft Word document. Here’s how you can go about it.
3. How to Format Code Blocks in Google Docs Using Microsoft Word
Microsoft Word allows you to copy highlighted code from the syntax highlighter directly into the document, and it keeps the background consistent without any whitespace between lines.
Therefore, it is possible to take advantage of this flexibility by formatting all the code blocks in a Microsoft Word document and later uploading that document to Google Docs.
Code added to Google Docs can be copied to other Docs documents while maintaining the formatting. So, either you can use this method to format Google Docs files or just format the code in a separate file and then copy-paste them to the original file.
Disadvantages of Manually Formatting Code Blocks in Google Docs
The major disadvantage of manually formatting code blocks in Google Docs is that all three methods will consume a significant amount of your time. Furthermore, changing any code style requires starting from scratch.
If the syntax highlighter does not support the programming language you are trying to format, there is a slight chance of error.
To overcome these limitations, you can use the Google Docs add-on. There are a variety of add-ons available for this task, but we’ll be using code blocks in this example.
Let’s see how you can use the add-on to format code blocks and what benefits it provides.
The steps above will format the code block as we did manually. Checking the No background checkbox just above the Format button lets you display code blocks formatted in plain text with no background.
Benefits of Formatting Code Blocks Using Add-ons
The add-on simplifies how you format code blocks, saving you a lot of time. In addition, you can quickly format code blocks in different languages in the same document without significantly changing the formatting settings in Syntax Highlighter.
So, if you want to save time and have better formatting control, using an add-on would be the way to go.
Even though Google Docs offers more flexibility, there are many other online word processing tools to choose from if you don’t like the look and feel of it.