This HTML code creates a web page with code formatting functionality. Here are the main components and their functions:
- Creates the structure of the page with the title "Code Formatter".
- Includes a text area for code input and buttons for formatting and copying the code.
- Defines styles for page elements, including the container, buttons, and notifications.
- Used to create a code editor with syntax highlighting and line numbers.
- Various modes are connected to support HTML, CSS, JavaScript, PHP, and other languages.
- A library for code formatting.
- Used for formatting HTML, CSS, JavaScript, PHP, and JSON.
- Initializes the CodeMirror editor.
- The
formatCode()
function formats the entered code depending on its type. - The
copyToClipboard()
function copies the formatted code to the clipboard and shows a notification.
- Enter the code in the text area.
- Click the "Format" button to format the code.
- The formatted code will appear below.
- Click the "Copy Code" button to copy the formatted code to the clipboard.