- Работа с документами HTML в TextEdit на Mac
- Создание HTML-файла
- Просмотр документа HTML
- Как всегда открывать HTML-файлы в режиме редактирования кода
- Изменение формата при сохранении файлов HTML
- Turn TextEdit Into an HTML Source Viewer with a Simple Settings Change
- Change TextEdit to Display HTML Files as Code Rather Than Rendered Formatted Text
- Convert a Text File to RTF, HTML, DOC, and more via Command Line
- How to Convert Text File to RTF, HTML, DOC, etc from Mac Terminal
- Related
- Enjoy this tip? Subscribe to our newsletter!
- Thank you!
- Related articles:
- 9 Comments
- How to Convert TXT to HTML with Doxillion Document Converter Software
- 1. Download Doxillion Document Converter Software
- 2. Import TXT Files into the Program
- 3. Choose an Output Folder
- 4. Set the Output Format
- 5. Convert TXT to HTML
- Like what you see?
Работа с документами HTML в TextEdit на Mac
В TextEdit Вы можете редактировать или отображать документы HTML так, как они выглядят в браузере (изображения могут отсутствовать) или в режиме редактирования кода.
Примечание. При редактировании файла HTML в режиме форматированного текста круглые кавычки и длинные тире по умолчанию заменяются прямыми кавычками и дефисами. (В режиме редактирования кода используются прямые кавычки и дефисы.) Информацию о том, как изменить эту настройку, см. в разделе Параметры на вкладке «Новый документ».
Создание HTML-файла
- В приложении TextEdit на Mac выберите меню «Файл» > «Новый», затем выберите меню «Формат» > «Конвертировать в простой текст».
- Введите HTML-код.
- Выберите «Файл» > «Сохранить», введите название с расширением .html (например, введите index.html), затем нажмите «Сохранить».
- Когда отобразится запрос на выбор расширения, нажмите «Использовать .html».
Просмотр документа HTML
- В приложении TextEdit на Mac выберите меню «Файл» > «Открыть», затем выберите документ.
- Нажмите «Показать параметры» в нижней части диалогового окна TextEdit, затем выберите «Игнорировать команды RTF».
- Нажмите «Открыть».
Как всегда открывать HTML-файлы в режиме редактирования кода
- В приложении TextEdit на Mac выберите «TextEdit» > «Настройки», затем нажмите «Открытие и сохранение».
- Выберите вариант «Отображать файлы HTML в виде кода HTML, а не форматированного текста».
Изменение формата при сохранении файлов HTML
Настройки, влияющие на сохранение файлов HTML в TextEdit, можно изменить.
- В приложении TextEdit на Mac выберите «TextEdit» > «Настройки», затем нажмите «Открытие и сохранение».
- В разделе «Выбор параметров сохранения HTML-файлов» выберите тип документа, стиль для каскадных таблиц стилей и кодировку.
- Чтобы вставить код для сохранения незаполненных областей в документе, выберите «Сохранять отображение пробелов».
Если при открытии файла HTML не отображается код, в TextEdit задано отображение файла как в браузере (в виде форматированного текста).
Turn TextEdit Into an HTML Source Viewer with a Simple Settings Change
TextEdit is a reasonably decent text editing app that has been bundled along with just about every version of OS X since the beginning. If you’ve ever opened an HTML file with TextEdit you have probably discovered the app actually renders the HTML code, displaying the formatted text, rather than displaying the source itself. This is actually really simple to adjust, and all it takes is a settings change to turn TextEdit into an HTML code viewer rather, and as a side effect, a simple plain text code editor.
Change TextEdit to Display HTML Files as Code Rather Than Rendered Formatted Text
This is available in all modern versions of OS X:
- Open TextEdit and pull down the TextEdit menu to select Preferences
- Click the “Open and Save” tab and check the box next to “Display HTML files as HTML code instead of formatted text”
Open any HTML document into TextEdit to see the new document code and source view in place of rendered code.
The default font size for plain text documents like HTML is set to 11, which can be very small for some resolutions and screens like the 11.6″ MacBook Air. Extend the readability by adjusting that through “Preferences” and under the “New Document” tab click “Change” alongside the ‘Plain text font’ option – Menlo Regular 12 is quite a bit more readable, but adjust it as your eyes see fit.
Developers will find this is infinitely better than the default rendered HTML view, but it doesn’t offer syntax highlighting and other powerful features that those who work with the web generally need. If you’re serious about viewing source or changing code of any kind, do yourself a huge favor and download TextWrangler, it is by far the best free text editor for the Mac platform, it has syntax highlighting and SFTP support along with tons of other features, and it’s completely free.
Convert a Text File to RTF, HTML, DOC, and more via Command Line
Do you need to convert a text file to RTF, plain text TXT, HTML, DOC, or another familiar document format? The excellent textutil command line utility can make quick work of text file conversion and manipulation on the Mac, and there is no need to download any additional software or tools as it’s built right in to Mac OS.
How to Convert Text File to RTF, HTML, DOC, etc from Mac Terminal
To begin your text conversion, you will need a starting text document that you wish to convert. It can be any text format if you’re testing this out, or use it with a document created entirely for this purpose.
Launch the Terminal application as found in /Applications/Utilities/ and then use the following command syntax:
textutil -convert filetype filename
Conversion options are txt, rtf, rtfd, html, doc, docx, odt, wordml, and webarchive, here’s sample syntax converting a text file named test.txt to an rtf:
textutil -convert rtf test.txt
Textutil will automatically append the filename with the appropriate extension. If you want to give the file a new name in the conversion process, use the -output flag as follows:
textutil -convert rtf test.txt -output NewFileName.rtf
If there’s multiple text documents you want to join together into a single new file, use textutil’s built-in cat function:
textutil -cat rtf file1.txt file2.txt file3.txt -output combinedFiles.rtf
You can quickly verify the conversion was successful by opening the newly created rtf file in TextEdit with:
You can also go the other direction and convert from any of the aforementioned filetypes back to txt, just remember that plaintext does not support any styling so the document will be stripped of any unique fonts, font sizes, styling, or other aspects of a rich text file.
The command line tool textutil allows you to quickly convert text files to many other useful formats and perform other text manipulation tasks. Additional help and options for textutil can be found by summarizing the help tool, or referring to the man page:
Or to get the complete manual page on textutil:
Don’t forget that you can also convert a text file to a spoken audio file, this can be achieved through the command line or by using the simpler “Add to iTunes as Spoken Track” method.
Related
Enjoy this tip? Subscribe to our newsletter!
Get more of our great Apple tips, tricks, and important news delivered to your inbox with the OSXDaily newsletter.
Thank you!
You have successfully joined our subscriber list.
Related articles:
9 Comments
In what is probably my root directory is the answer. Glad to have that sorted! This might help another user:
Ann-Smiths-MacBook-Pro:~ tundern$ textutil -convert rtf Gugler.txt
Ann-Smiths-MacBook-Pro:~ tundern$
Where tundern is my user name. Cheers,
Ann
Doesn’t work for me as Terminal keeps reporting that it cannot find the .txt file. I tried moving it from its nested folder to the Desktop with the same negative result. Where does Terminal expect to find the file?
[…] You can also open an RTF document into TextEdit and perform the conversion directly on the file, saving the resulting file as a TXT document. The same conversions can also be achieved from the temrinal by using the textutil command. […]Here’s an Applescript droplet (OSX Lion) to package this up: (* ConvertFileFormat ©Lindsay Crawford, 2012
Based on William Pearson’s article https://osxdaily.com/2011/07/06/convert-a-text-file-to-rtf-html-doc-and-more-via-command-line/ and loosely, Apple’s Droplet with Settable Properties.app INSTRUCTIONS
Run the app to convert one file, or drop a group of files on the app. Converted files with same names but different extensions are left in the original folder.
Unconvertible files are ignored.
*) property type_list : on run — display description and get a file
try
open ()
end try
end run — This droplet processes files dropped onto the applet
on open these_items set convertTo to (choose from list type_list with title “Format Conversion” with prompt “Select the format to convert the file(s) to:” default items without multiple selections allowed) as text repeat with i from 1 to the count of these_items set this_item to item i of these_items — Get the info for the item
tell application “System Events”
set the item_info to (get the properties of this_item) set this_name to the name of the item_info
set this_place to the POSIX path of the container of the item_info
set ext to name extension of the item_info end tell — now check the file type
if (ext is in type_list) then
process_item(this_place, this_name, convertTo)
end if end repeat end open — this sub-routine processes files
on process_item(this_place, this_name, convertTo)
— this_place is a POSIX path to the folder for this file
— this_name is just the file name with extension
— convertTo is a text string containing the new file extension copy “cd ” & quoted form of this_place & “;textutil -convert ” & convertTo & space & quoted form of this_name to theCommand
do shell script theCommand end process_item
Loved it.. I am a completely new and first Time Mac User and have been a Windows User for almost 10 years.. Just loved learning all this stuff.. Used to do a lot of such things back when Learnt DOS in Windows
[…] addition to being able to convert TXT files to RTF or other filetypes, you can use textutil to convert the font family and font size of a document from the command […]viceroy – you can do the concatenation by just using cat being a unix admin I love learning new tricks and can see potential benefits in certain cases by using this thanks! I think this goes hand and hand with being able to manipulate images and convert to different types try the following to learn more about that.
sips –help
I like the concatenation aspect but I don’t think I would use the conversions when I can do it through other text editors.
How to Convert TXT to HTML with Doxillion Document Converter Software
Quickly convert TXT to HTML and other formats. TXT files are not supported by all applications, and so some may wish to convert their TXT files to HTML format or another format supported by their program or other use cases. This demonstration will teach you how to convert your TXT files to HTML so that you can continue your project with ease.
1. Download Doxillion Document Converter Software
Download Doxillion Document Converter Software. Follow the installation instructions and then launch/open the program on your computer after you have finished installing it.
2. Import TXT Files into the Program
Click on the green Add File(s) button, located in the main toolbar to open the file finder window. Find and select the TXT files on your computer and click Open to bring them into Doxillion to convert them to the HTML file format. You can also drag and drop your TXT files directly into the program to convert them as well.
3. Choose an Output Folder
Set the output destination where you would like your converted files to go after they have been converted from TXT to HTML format. Click on the Save to Folder or Output Folder drop-down arrow to view the drop-down menu and select a folder from this list. Click on the Browse button to the right of the arrow to open the file finder window and select a folder on your computer this way.
4. Set the Output Format
Click on the drop-down arrow on the left-hand side of the program next to the words «Output Format» to view the list of available document file formats. To convert your TXT files to HTML files, simply select the option from this list that says, «HTML.» All conversions performed will now be to the HTML document file format.
5. Convert TXT to HTML
Click on one of the Convert buttons, located in the bottom right-hand corner of the program or in the main toolbar. This will start the conversion process. You can select only one file to convert them one at a time or you can select all of them to perform easy batch HTML conversions.
Like what you see?
Document converter for Windows PC and Mac OS X. Convert document files to and from many different document formats, such as DOCX, DOC, PDF, ODT, WPD, WPS, RTF, HTML, TXT, EPUB, MOBI and many other document formats.